Winform comboBox returns dataRowView
Posted on 2008-10-01
I have a dataset bound to comboBox1 with records.
In a certain scenario I have to reload the dataset with some other data if combo2 is selected.
So When combo2 is selected I set the bindings off for the comboBox1 and reload a fresh dataset again.
In the selected change event I try to get the student_id when a name is selected. but it returns system.data.RowView
Its bound for the first time like this
this.combobox1.DataSource = _ds.Tables;
this.combobox1.DisplayMember = "Student_name";
this.combobox1.ValueMember = "student_id";
this.combobox1.SelectedIndex = -1;
this.combobox1.SelectedIndexChanged += new System.EventHandlerthis.combobox1_SelectedIndexChanged);
this.combobox1.SelectedIndex = 0;
Now when Combo2 is selected and combobox1 is clicked IN CLICK EVENT OF of comboBox1
I set the bindings off and bind again in the above way to another dataset as It has to be done on fly (ie when combo2 is selected Combo1 has to load some other data)
In the selected change event I try to get the student_ID but it returns data.row.dataviewrow
private void Combobo1_SelectedIndexChanged(object sender, EventArgs e)
if ( combobox1.SelectedIndex > 0 || combobox1.selectedindex !=-1)
// this.txtStudentID.Text = combobox1.SelectedItem.ToString();