When populating a dropdownlist control the selected index changes, which triggers the action I have setup for the index changing... however when I initially populate the dropdownlist by setting a datatable as its datasource and defining the display and value members, the radDropDownList.SelectedItem.Value is a DataRowView object. After it's populated, though, the radDropDownList.SelectedItem.Value is an integer as it should be. Can this be explained to me why this is happening and the best way to work with it?
My code currently is this, and it will only work when I initially set the datasource:
Thanks for your time
My code currently is this, and it will only work when I initially set the datasource:
private void someOtherMethod (){ sysParentDropDown.DataSource = dt; sysParentDropDown.DisplayMember = "name"; sysParentDropDown.ValueMember = "panelid"; sysParentDropDown.SelectedIndex = -1;}private void sysParentDropDown_SelectedIndexChanged(object sender, Telerik.WinControls.UI.Data.PositionChangedEventArgs e) { if (this.sysParentDropDown.SelectedIndex > -1) { sysDeviceDropDown.Enabled = true; try { sysDeviceDropDown.DataSource = null; sysDeviceDropDown.Text = null; sysInputDropDown.DataSource = null; sysInputDropDown.Text = null; DataRowView drv = (DataRowView)this.sysParentDropDown.SelectedItem.Value; string s = "(panelid = " + drv.Row["panelid"].ToString() + ") AND (devid <> 0) AND (inputdevid = 0)"; DataRow[] foundRows = deviceNames.Select(s, "name asc"); DataTable dt = new DataTable("temp"); dt.Columns.Add("name"); dt.Columns.Add("devid"); foreach (DataRow dr in foundRows) { dt.ImportRow(dr); } DataRow row = dt.NewRow(); row["name"] = ""; row["devid"] = " "; dt.Rows.InsertAt(row, 0); sysDeviceDropDown.DisplayMember = "name"; sysDeviceDropDown.ValueMember = "devid"; sysDeviceDropDown.DataSource = dt; } catch (Exception ex) { MessageBox.Show(ex.Message); } } else { sysDeviceDropDown.Enabled = false; sysDeviceDropDown.SelectedText = null; sysInputDropDown.Enabled = false; sysInputDropDown.SelectedText = null; } }Thanks for your time