Access selected items' (ListItems) VALUES of dynamically generated CheckBoxList on postBack

  • Thread starter Thread starter Boris
  • Start date Start date
B

Boris

When I dynamically create CheckButtonList, I add ListItem(s) to my
CheckButtonList object chkList

chkList.Items.Add(new ListItem("My Text", "My Value"));

The resulting HTML doesn't contain value="My Value". Therefore, I can't
access "My Value" with Request.Form on post back.

I do get the desired outcome with my RadioButtonList object radioList when I
do
radioList.Items.Add(new ListItem("My Text", "My Value"));
because for RadioButtonList, I get "My Value" in html.

How can I make it work for CheckBoxList? What I am trying to achive is to
get the values associated with checked items of my dynamically generated
CheckBoxList through Request.Form. I could do it with RradioButtonList but
not with CheckBoxList. I don't want to have to persist my dynamically
generated CheckBoxList into Session.

Thank you,
-Boris
 
Back
Top