Friday, June 29, 2012

How to bind dataset to checkedlistbox in C#.net

How to bind dataset to checkedlistbox in C#.net

You can assign the data set to checkedlistbox also but the Intellisense is not showing the Data source property to the checkedlistbox.Below is the example.

//example

 checkedListBox1.DataSource = ds.Tables["t1"];
            checkedListBox1.DisplayMember = "t1";

This will surely works happy coding.



How to assign same dataset to multiple Comboboxes in C#.net

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";


amazon

Sukanya Samriddhi Account - SBI

SUKANYA SAMRIDDHI Account information by SBI SUKANYA SAMRIDDHI ACCOUNT : FACILITY AVAILABLE AT ALL BRANCHES OF SBI Sukanya Samriddhi ...