SelectedValue is empty in DropDownList when updating in EditItemTemplate of FormView
Posted on 2009-04-30
I have a formview where data is entered. Within the formview's InsertItemTemplate a DropDownList is populated from an EntityDataSource. I fill out the form with all values and select Insert(linkbutton). The data is inserted appropriately and then I have the mode changed to ReadOnly(ItemTemplate). The formview is set to have edit capabilities. When I click Edit the formview sends me to the EditItemTemplate with all of the correct data in the fields, including the DropDownList. Whether I make a different selection or leave the selection as is and select Update, an error is thrown because there is no value in the SelectedValue property of the DropDownList: <Error while setting property 'AG_ddl_Reviewer.ReviewerID': ' is not a valid value for Int32.'.>
What is happening is the dropdownlist is losing it's value's(SelectedValue, DataValue, TextValue) when it changes to the EditItemTemplate, however, it displays the DataTextFields in the DropDownList appropriately. I even traced this in the ItemUpdating event(Please See Attached ScreenShot). How can I fix this?