I have two grids on the page. Both are configured to use the OnNeedDataSource event. The detail grid is rebound in the OnSelectedIndexChange of the master grid. The detail grid has an edit template with a dropdownlist. The dropdown list is bound to an ObjectDataSource. I'm attempting to bind the dropdownlist in the following event handler;
However, before it can get here, I get an error: "Sys.WebForms.PageRequestManagerServerErrorException: 'ddlAssetType' has a SelectedValue which is invalid because it does not exist in the list of items."
The code doesn't hit a breakpoint set in the OnSelect method of the ObjectDataSource, so the dropdownlist hasn't been bound yet. What am I doing wrong?
protected void ModelGrid_OnItemDataBound(object sender, GridItemEventArgs e){ if ((e.Item is GridEditFormItem) && (e.Item.IsInEditMode)) { GridEditFormItem editform = (GridEditFormItem)e.Item; DropDownList ddlAType = (DropDownList)editform.FindControl("ddlAssetType"); if (ddlAType != null) ddlAType.DataBind(); }}However, before it can get here, I get an error: "Sys.WebForms.PageRequestManagerServerErrorException: 'ddlAssetType' has a SelectedValue which is invalid because it does not exist in the list of items."
The code doesn't hit a breakpoint set in the OnSelect method of the ObjectDataSource, so the dropdownlist hasn't been bound yet. What am I doing wrong?