When to populate DetailsView DropDownList?

tfowler

Regular
Joined
Aug 16, 2005
Messages
84
Location
Columbus, OH
I'm having some problems with a DropDownList in a DetailsView. I am populating the list at run-time based on other selections by the user. It works great until I select a row in the corresponding GridView to edit. I then get the error: "System.ArgumentOutOfRangeException: 'ddlTableColumn' has a SelectedValue which is invalid because it does not exist in the list of items. Parameter name: value". My guess is that this error occurs because the DropDownList is not yet populated before the edited row is binded to it.

I am currently populating the DropDownList in the Page_PreRenderComplete event. I have also tried placing it in the DetailsView PreRender event, which has the same effect. Placing it in the DetailsView DataBinding or Load events results in an empty DropDownList control.

My question is, where should I populate the DropDownList so that it gets loaded properly, and is available for binding the edited row? After 3 days of messing with this and searching the web for answers, I am getting extremely frustrated! :( This should be simple enough.

Todd
 
Back
Top