John Brooking

John Brooking

  • NA
  • 1
  • 863

Unbound list box controls in Request.Params?

Mar 24 2015 3:27 PM
I'm not a regular .Net programmer but do have some HTTP experience in the past, and I have a very basic question: Do <asp:listbox> controls need to be databound in order to be sent to another page via Request.Params?

Here's the situation: I'm trying to write a form with two selection listboxes. The left-hand one is databound to a database view to get employee names. The right-hand one is unbound. Buttons are provided to move names from the databound box to the unbound box, to build up a selection list. I implemented the movement in client-side Javascript because that's what I already know, and also I didn't want to make a round-trip to the server just to move names back and forth. A submit button submits to a second page, whose code-behind handles the submission.

On the handling page, the selected value from the databound listbox appears in the Request.Params collection, but the values in the unbound box do not. The name of the databound list box appears in the AllKeys collection, but the name of the unbound list box does not. All the properties are identical between the two list boxes, except of course the ID and Name, and that one is databound and the other is not.

As an experiment, I then made a simpler form that has only two unbound list boxes and a submit button, again submitting to another handling page. In this handling page, neither of the two list boxes are mentioned in Request.Params. So is a listbox required to be databound to show up in the Request.Params of a submitted page?

On a broader level, maybe I'm not thinking about this in a very .Net way. (More of my experience is PHP circa 2000, and Classic ASP.) Maybe all submissions should be back to the same page, instead of to a second page? Would that help?