I'm trying to update data from a listview whilst passing the value of a dropdownlist within the edittemplate.
Sample code:
The drop down list populates ok when the edit button is clicked in the listview but the following error is generated when clicking the update button
Could not find control 'dropDownList1' in ControlParameter 'ddl_value'
I've Googled the problem for the last few hours with no meaningful results so any help would be gratefully received.
Sample code:
Code:
<asp:SqlDataSource runat="server" id="SqlDataSource1" ConnectionString="<%$ ConnectionStrings:ConnectionString1 %>"
SelectCommand="SELECT * FROM [table1]"
UpdateCommand="UPDATE [table1] SET [table1.column1] = @ddl_value">
<UpdateParameters>
<asp:controlparameter ControlID="dropDownList1" Name="ddl_value" Type="Int32" />
</UpdateParameters>
</asp:SqlDataSource>
<asp:SqlDataSource id="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString1 %>"
SelectCommand="SELECT [table2.column1] FROM [table2]">
</asp:SqlDataSource>
<asp:ListView id="ListView1" runat="server" DataSourceID="SqlDataSource1" >
...
<EditItemTemplate>
<tr style="">
<td>
<asp:button id="UpdateButton" runat="server" CommandName="Update" Text="Update" />
<asp:button id="CancelButton" runat="server" CommandName="Cancel" Text="Cancel" />
</td>
<td>
<asp:dropDownList runat="server" DataSourceID="SqlDataSource2" id="dropDownList1"
DataTextField="column1" DataValueField="column1" SelectedValue='<%# Bind("column1")%>' />
</td>
</tr>
</EditItemTemplate>
...
<asp:listview>
The drop down list populates ok when the edit button is clicked in the listview but the following error is generated when clicking the update button
Could not find control 'dropDownList1' in ControlParameter 'ddl_value'
I've Googled the problem for the last few hours with no meaningful results so any help would be gratefully received.