Click here to Skip to main content
15,918,275 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello
i have two datatable (dt,dt1) in which to different value is selected.
in dt="gov_center_Name" and dt1="pri_center_Name" these two value are selected.

now i merge this datatable and bind a value into combobox.
but both value are not coming.
can you suggest me how to do.
Posted
Updated 27-Jul-12 2:40am
v2

Is this the way you bind the datatable?

C#
cmb.DisplayMember = "Colname1";
cmb.ValueMember = "Colname2";            
cmb.DataSource = dt;
 
Share this answer
 
Comments
Rohit Sharma706 27-Jul-12 8:54am    
i done in this way but only single value is fetch

use just see that....
sqlSelect = "select AI_Center_Name from tbl_CenterEntry";
dt = cls.FetchDataTable(sqlSelect);
sqlSelect = "select AI_PriCenter_Name from tbl_PrivateCenterEntry";
dt1 = cls.FetchDataTable(sqlSelect);
dt.Merge(dt1);
dt3 = dt;

drpCenter.DisplayMember = "AI_PriCenter_Name";
drpCenter.ValueMember = "AI_Center_Name";
drpCenter.DataSource = dt3;
C#
dt.Merge(dt1);
           dt.Columns.Add("Center", typeof(string));
           foreach (DataRow dr in dt.Rows)
           {
               dr["Center"] = dr["gov_center_Name"].ToString();
           }
           foreach (DataRow dr in dt.Rows)
           {
               if (dr["Center"] == "")
                   dr["Center"] = dr["pri_center_Name"].ToString();
           }
           comboBox1.DataSource = dt;
           comboBox1.DisplayMember = "Center";
 
Share this answer
 
Comments
Rohit Sharma706 28-Jul-12 0:12am    
Thaks Santosh ji.
its working.Thanks a lot.
Santhosh Kumar Jayaraman 28-Jul-12 0:13am    
welcome

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900