How to assign same dataset to multiple Comboboxes in C#.net
1.You can assign same dataset to the multiple comboboxes or multiple list box, or checkedlistboxes. Every one is getting a problem is while selecting a value in one combo box the same value is also changed in remaining comboboxes (i,e,. it reflects other comboboxes also that are binding to the same dataset).
2. To over come this problem while assigning data source to the control u have to wrote a single line of code as below
if u use BindingContext u can overcome the problem.By using this u can assign the same datasource to multiple controls.
//example
combobox1.BindingContext=new BindingContext();
combobox1.Datasource=ds.Tables["t1"];
combobx1.DispalyMember="t1";
//assigning same dataset to another combobox as below
combobox2.BindingContext=new BindingContext();
combobox2.Datasource=ds.Tables["t1"];
comboobx2.DisplayMember="t1";
Thanks a lot. Your stuff resolved my problem in 1 min... :) :)
ReplyDeleteTnaks
Deletethanks, your article resolved my problem too
ReplyDeleteThis comment has been removed by the author.
ReplyDelete