CheckBoxList contorl's selected items, problem

G

Guest

How can I check which items has been selected in CheckBoxList control when I bind data to it from SQL Server? The code I use works fine when I add manually items into checkboxlist control, but does not work when I bind it.

String s = "Selected items:<br>"

for (int i=0; i < CheckBoxList1.Items.Count; i++)

if ( CheckBoxList1.Items[ i ].Selected )

// List the selected item
s = s + CheckBoxList1.Items.Text
s = s + "<br>"
}
 
G

Guest

Sorry, my fault, I forgot to put if (IsPostBack==false) in PageLoad(). I got it work now :)
 

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,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top