c# - Using datasource with CheckBoxList -


i use checkboxlist in windows forms application , trying apply datasource it.

having datatable, 'dt', columns id, name , ischecked, use such code:

((listbox)mycheckboxlist).datasource = dt; ((listbox)mycheckboxlist).displaymember = "name"; ((listbox)mycheckboxlist).valuemember = "id"; 

how set checkstate items in mycheckboxlist?

i keep value in datatable , want link them mycheckboxlist.

i've decided problem in 2 steps. first, applied datasource, , in circle set checked property each item in following code:

((listbox)mycheckboxlist).datasource = dt; ((listbox)mycheckboxlist).displaymember = "name";                     ...  (int = 0; < folloving.items.count; i++ ) {     datarowview row = (datarowview)mycheckboxlist.items[i];     bool ischecked = convert.toboolean(row["checked"]);     mycheckboxlist.setitemchecked(i, ischecked); } 

Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -