I am getting an error while filling combobox values during the time when i read values from database table to the combobox
Error:
cannot bind to the new display member. parameter name newdisplaymember
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Satyapriya NayakRank #47 · 31.5K reputationPosted Oct 11, 2012, 11:33 PM EDT
Priya LingeRank #785 · 2.9K reputationPosted Oct 11, 2012, 11:37 PM EDT
Hi,
I bind combobox as follow,
Dataset ds=new Dataset();
DataTable dt;
string query="Select Emp_ID,Emp_name from Employee;
sqlcommand cmd=new sqlcommand(query,con);
sqlDataAdapter da=new sqlDataAdapter();
da.SelectCommand = cmd;
da.fill(ds);
dt=ds.Tables[0];
CmbEmpName.ValueMember = "Emp_ID"
CmbEmpName.DisplayMember = "Emp_name"
CmbEmpName.DataSource = dt;
I set the DisplayMember and ValueMember before setting the DataSource.
Hope this will help you.
Thanks.
Satyapriya NayakRank #47 · 31.5K reputationPosted Oct 11, 2012, 11:48 PM EDT