c# - returning text values from CheckBoxList -


i'm new coding missing obvious. i've tried searching here , various other resources can't code want i'm hoping can help.

i have checkbox list populated sql query based on user input. intention user can check 1 or more items on list , sql stored procedure run each checked item value of selected item passed parameter value. so, if there 6 items in list , 3 checked code loop through list , each checked item run sp item's value parameter value before moving on next item in list.

as first step in testing logic have code below supposed pass selected item's text label when button clicked, rather checked box's text value getting 'system.data.datarowview'

int checkcount = chcklist.items.count; (int = 0; < checkcount; i++) {     if (chcklist.getitemchecked(i))      {         string str = chcklist.items[i].tostring();         label23.text =  str;     } } 

if change assignment of string str value 'string str = chcklist.getitemtext(i).tostring();' number of item (i.e. if there 6 values , fist checked '0', if second checked '1', etc.)

the checkboxlist is, i've said, filled sql query based on user input, method doing is:

connection.open();         using (sqldataadapter adapter = new sqldataadapter())         {             datatable dattbl = new datatable();             adapter.selectcommand = mycommand;                 {                 adapter.fill(dattbl);                 chcklist.datasource = dattbl;                 chcklist.displaymember = dattbl.columns[1].columnname;                  }         } connection.close(); 

can help? doing wrong?

thanks

if items collection of datarowview objects, gets specific datarowview , calls tostring() on it, returns qualified name of object:

string str = chcklist.items[i].tostring(); 

try accessing specific column:

string str = ((datarowview)chcklist.items[i])["somecolumnname"].tostring(); 

Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -