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

A

Amelyan

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,
-Bob
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top