E
ES
Hello,
I have a GridView with a DropDownList in the EditTemplate of one if my columns. I've got the drop down displaying the correct data, but need to do an update when the user changes the value and updates the row. I'm having difficulty getting the GridView's SqlDataSource UpdateParameter to see the DropDownList. Here is how it's set up:
<asp:SqlDataSource runat="server" ID="SqlData1" ConnectionString="<%$ ConnectionStrings:myconn%>"
SelectCommand="..."
DeleteCommand="..."
InsertCommand="...
UpdateCommand="Update SalesRegion Set SalesRegionTypeID = @SalesRegionTypeID, SalesRegionCD = @SalesRegionCD, SalesRegion = @SalesRegion Where SalesRegionID = @SalesRegionID"
<DeleteParameters>
<asparameter Type="int32" Name="SalesRegionID" />
</DeleteParameters>
<UpdateParameters>
<asparameter Type="int32" Name="SalesRegionID" />
<asparameter Type="string" Name="SalesRegionCD" />
<asparameter Type="string" Name="SalesRegion" />
<asp:ControlParameter ControlID="dlRepType" Type="string" PropertyName="SelectedValue" Name="SalesRegionTypeID" />
</UpdateParameters>
</asp:SqlDataSource>
<asp:GridView runat="server" ID="GV" DataSourceID="SqlData1" AutoGenerateColumns="false"
DataKeyNames="SalesRegionID" HeaderStyle-CssClass="GVHead" RowStyle-CssClass="GVBody"
EditRowStyle-CssClass="GVBodyEdit" CssClass="GV" AutoGenerateEditButton="true"<Columns>
...
<asp:TemplateField HeaderText="Rep Type">
<ItemTemplate>
<asp:Label Text='<%#Eval("SalesRegionType") %>' runat="server" />
</ItemTemplate>
<EditItemTemplate>
<aspropDownList ID="dlRepType" runat="server" DataSourceID="sdRepType" DataTextField="SalesRegionType"
DataValueField="SalesRegionTypeID" SelectedValue='<%#Bind("SalesRegionTypeID") %>' />
</EditItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
When update is clicked, the page throws
System.InvalidOperationException: Could not find control 'dlRepType' in ControlParameter 'SalesRegionTypeID'.
Any idea how to link this drop down to the update?
Thanks,
EE
I have a GridView with a DropDownList in the EditTemplate of one if my columns. I've got the drop down displaying the correct data, but need to do an update when the user changes the value and updates the row. I'm having difficulty getting the GridView's SqlDataSource UpdateParameter to see the DropDownList. Here is how it's set up:
<asp:SqlDataSource runat="server" ID="SqlData1" ConnectionString="<%$ ConnectionStrings:myconn%>"
SelectCommand="..."
DeleteCommand="..."
InsertCommand="...
UpdateCommand="Update SalesRegion Set SalesRegionTypeID = @SalesRegionTypeID, SalesRegionCD = @SalesRegionCD, SalesRegion = @SalesRegion Where SalesRegionID = @SalesRegionID"
<DeleteParameters>
<asparameter Type="int32" Name="SalesRegionID" />
</DeleteParameters>
<UpdateParameters>
<asparameter Type="int32" Name="SalesRegionID" />
<asparameter Type="string" Name="SalesRegionCD" />
<asparameter Type="string" Name="SalesRegion" />
<asp:ControlParameter ControlID="dlRepType" Type="string" PropertyName="SelectedValue" Name="SalesRegionTypeID" />
</UpdateParameters>
</asp:SqlDataSource>
<asp:GridView runat="server" ID="GV" DataSourceID="SqlData1" AutoGenerateColumns="false"
DataKeyNames="SalesRegionID" HeaderStyle-CssClass="GVHead" RowStyle-CssClass="GVBody"
EditRowStyle-CssClass="GVBodyEdit" CssClass="GV" AutoGenerateEditButton="true"<Columns>
...
<asp:TemplateField HeaderText="Rep Type">
<ItemTemplate>
<asp:Label Text='<%#Eval("SalesRegionType") %>' runat="server" />
</ItemTemplate>
<EditItemTemplate>
<aspropDownList ID="dlRepType" runat="server" DataSourceID="sdRepType" DataTextField="SalesRegionType"
DataValueField="SalesRegionTypeID" SelectedValue='<%#Bind("SalesRegionTypeID") %>' />
</EditItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
When update is clicked, the page throws
System.InvalidOperationException: Could not find control 'dlRepType' in ControlParameter 'SalesRegionTypeID'.
Any idea how to link this drop down to the update?
Thanks,
EE