c# - How to get checkboxlist item value -


this how adding values , text checkboxlist in c#

private void populatefruitlist() {     string selectcommand = "select fruitname, fruitid fruit_crate";      using (sqldatasource ds = new sqldatasource(connectionstring(), selectcommand)) {         checkboxlist1.datasource = ds;         checkboxlist1.datatextfield = "fruitname";         checkboxlist1.datavaluefield = "fruitid";         checkboxlist1.databind();     } } 

this how trying value intellisence not helping,

foreach (checkbox cb in checkboxlist1.items) {     if(cb.checked)         mylist.add(cb.value); // says wrong syntax 

can direct me right syntax please?

simple.

checkboxlist not contain checkbox items (or shouldn't), it's collection of listitems. should this: -

foreach (listitem cb in checkboxlist1.items)  {     if(cb.selected)     {          mylist.add(cb.value);     } } 

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -