So I have some GridView. When you edit a row, a particular column changes from a label to a DropDownList. The content of this drop down is populated via some SQL data source.
The user may make a selection choice and click “Update”.
How can I actually get at the SelectedValue property of the drop down?
I thought this would work:
<asp:GridView ... >
<Columns>
...
<EditItemTemplate>
<asp:DropDownList ID="ServiceCategoriesGvDropDown" AutoPostBack="True" .../>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ... />
</ItemTemplate>
</asp:TemplateField>
...
</Columns>
</asp:GridView>
And then wire it up with a ControlParameter in my SqlDataSource:
<UpdateParameters>
...
<asp:ControlParameter ControlID="ServiceCategoriesGvDropDown" PropertyName="SelectedValue" ... />
</UpdateParameters>
However, I get the following exception:
System.InvalidOperationException: Could not find control ‘ServiceCategoriesGvDropDown’ in ControlParameter ‘ServiceCategoriesID’.
So clearly my drop down doesn’t get found. Perhaps it’s been destroyed by this point?
try this in the updating event of the grid.