how to display two column value in combobox DisplayMember
-
hi i'm having hard time on how to display two column values in combox display member..like custID and custName...any sample code plz help
Hi, Not sure how you would do it using the .NET toolkit (ComboBox), but if you make use of the control toolkit from DevExpress (which has 60 free controls), you can make use of their LookUpEdit control, which has this type of functionality. Here is an example if you are interested: LookUpEdit Control[^] Kind regards,
-
hi i'm having hard time on how to display two column values in combox display member..like custID and custName...any sample code plz help
Its quite simple actually :
//Create a DataTable for binding to combobox
DataTable dt = new DataTable();
dt.Columns.Add("ID");
dt.Columns.Add("Name");//Read values from dbase and fill it in datatable
//I am taking DataReader herewhile(reader.Read())
{
DataRow dr = dt.NewRow();
dr["ID"] = reader.GetValue(0);
dr["Name"] = reader.GetValue(0) + reader.GetValue(1);
dt.Rows.Add(dr);
}combobox.DataSource = dt;
combobox.DataBind();Hope this helps you. :)