I'm getting a Selection Out of Range error when trying to do something very simple with the DropDown control.
Based on a radio selection list, the items in the drop down list should change. The items are retrieved from a datasource, however i manually add the "All" item to the list. The code is below:
Similar code is called when the page first loads (!IsPostBack), and there is no problem. The exception is thrown once it tries to execute the FilterCombo.DataBind() method.
Any help would be appreciated
Based on a radio selection list, the items in the drop down list should change. The items are retrieved from a datasource, however i manually add the "All" item to the list. The code is below:
void JobsList_SelectedIndexChanged(object sender, EventArgs e) |
{ |
FilterCombo.AppendDataBoundItems = true; |
FilterCombo.Items.Clear(); |
RadComboBoxItem myItem = new RadComboBoxItem("All", "-1"); |
FilterCombo.Items.Insert(0, myItem); |
FilterCombo.Items[0].Selected = true; |
if (JobsList.SelectedValue == "1") |
{ |
FilterCombo.DataSource = TechniciansSource; |
FilterCombo.DataTextField = "TechName"; |
FilterCombo.DataValueField = "TechnicianId"; |
FilterCombo.DataBind(); |
} |
else |
{ |
FilterCombo.DataSource = SuburbSource; |
FilterCombo.DataTextField = "Suburb"; |
FilterCombo.DataValueField = "SuburbId"; |
FilterCombo.DataBind(); |
} |
} |
Similar code is called when the page first loads (!IsPostBack), and there is no problem. The exception is thrown once it tries to execute the FilterCombo.DataBind() method.
Any help would be appreciated