I have a drop down list that I have bound to a table. When I pick the
dropdownlist, I would like to fetch the following:
- Index, which I can achieve through the SelectedIndex
- Value, which I can get from the SelectedValue
- Column, a specific column value from the bound data
Tim Mackey - 31 Aug 2005 15:06 GMT
hi John,
remember that your combobox is bound to a datatable, and each menu item
corresponds to a datarow. you have access to the SelectedItem property,
which is an object, in your case it is a DataRowView because of the
databinding. you can use the following code to access other items in the
datarow:
DataRowView dr = this.comboBox1.SelectedItem as DataRowView;
string whatever = dr["ColumnName"].ToString();
...
hope this helps
tim
blog: http://tim.mackey.ie