I am developing a C#.net 2k5 winform app, I have a query to retrieve the data from database:
SELECT staff_no + ' - ' + title + ' - ' + name + ' - ' + profession AS staff_combo, staff_id
FROM staff
ORDER BY staff_id
I want to bind this staff_combo to my combobox1.display member, and staff to the combobox1.valuemember. I tried this line below, it didnt work, plz help:
this.staffTableAdapter.FillByStaffCombo( this.hPMDataSet.staff );

combobox databinding to display more than one values
redcodes
My data is defined such way:
interface IData {
IDataPrimaryKey PrimaryKey { get; }
string Label { get; }
string Code { get; }
}
my datasource is IList<IData>.
I need to display String.Format("{0} ({1})", data.Code, data.Label) as visible value in my combo
box.
How would I do this since I can't use DisplayMember, is there any event I can handle or any other solution
Thanks.
Savindra
can u plz demonstrate all steps take to display the staff_combo in my combobox
someone suggest fill it manually with dataReader ,i am confused...
PrashanthBlog
try this
combobox1.DataSource = ds; //datasource
combobox1.DisplayMember = "staff.staff_combo";
combobox1.ValueMember = "staff.staff_id";