I'm having a problem with my dropdownlist. The problem is that when the edit button is clicked from my gridview and the value isn't in the dropdownlist (then)
I get the following:
ar' has a SelectedValue which is invalid because it does not exist in the list of items.
I want to catch this in a try block but am having problems figuring out which directives to use. I need to use the FindControl function because the dropdown is only visible after the edit button is clicked.
I'm not sure how to accomplish this and need some advice. Please see the below code to get an idea about what I need to accomplish. The statement in the catch has a red line under 'SelectedValue'.
protected void GridviewBuses_RowEditing(object sender, GridViewEditEventArgs e)
FindControl("DropDownListPurchaseYear").SelectedValue = "";