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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Satyapriya NayakPosted Oct 12, 2012, 3:48 AM
Priya LingePosted Oct 12, 2012, 3:37 AM
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 NayakPosted Oct 12, 2012, 3:33 AM