c# CheckedListbox values -


when want put values in array selected checkedlistbox. , say:

messagebox.show(values[0]);

it's saying : system.data.datarowview

this current code:

        string[] itemarr = new string[clbtables.checkeditems.count];         int counter = 0;         foreach (object item in this.clbtables.checkeditems)         {             string temp = convert.tostring(item);             itemarr[counter] = temp;             counter++;         }         metromessagebox.show(this, itemarr[0].tostring()); 

what doing wrong here>?

edit ::

clbtables.datasource = sqldisplaycontent.connectdatatable("select ('tafelnr: '+ convert(varchar,tafelnr)+' zitplaatsen: '+ convert(varchar,zitplaatsen)) dispvalue,tafelnr  tabel"); clbtables.displaymember = "dispvalue"; clbtables.valuemember = "tafelnr";    class sqldisplaycontent         {             public static datatable connectdatatable(string query)             {                 sqlcommand comm= sqlcrud.returnsqlcommand(query);                 sqldataadapter sda = new sqldataadapter(comm);                 datatable dt = new datatable();                 sda.fill(dt);                 return dt;             }         }  thankss 

the issue that:

convert.tostring(item); 

will call tostring() method of object , store that, in case, giving object's type. in case, type system.data.datarowview. suggest access specific field in row want using:

((datarowview)item).row["fieldname"].tostring(); 

instead. want replace "fieldname" whatever name of column wanting is. additionally, can use int index instead of string reference. of course, if need access multiple fields, can simple string concatenation. issue need access specific field want. not entire row on.

i hope helps!

a couple references: datarow, datarowview


Comments

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - Function overwritting -

php - Find a regex to take part of Email -