c# - Dynamic binding to CheckedListBox using entity model -


i using checkedlistbox control in windows forms. need bind checkedlistbox dynamically using entity model.

my query:

private void bindtax()         {             try             {                 etax tax = new etax();                 ctax ctax= new ctax();                 list<etax> objtax = ctax.gettax(egentities);                 tax.categoryid = convert.toint32("-1");                 tax.categoryname = "--select--";                 objtax.insert(0, tax);                 foreach (etax item in objtax)                 {                     lstchktax.items.add(item.taxname);                  }                            }             catch (exception ex)             {                messagebox.show(ex.message.tostring());             }          } 

i getting dispayname i'm not getting selectedvalue. not finding data source property control. please tell me how can this?

thanking in advance.

you have cast listbox binding work. i'm not sure why. code this...

((listbox)lstchktax).datasource=objtax; ((listbox)lstchktax).displaymember="categoryname"; ((listbox)lstchktax).valuemember="categoryid"; 

a longer example can found here.


Comments

Popular posts from this blog

matlab - Deleting rows with specific rules -

php - MySQLi multi_query results for later use -