Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Update SqlDataSource with value of DropDownList in EditTemplate on GridView

Thread Tools

Update SqlDataSource with value of DropDownList in EditTemplate on GridView

Posts: n/a
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%>"
UpdateCommand="Update SalesRegion Set SalesRegionTypeID = @SalesRegionTypeID, SalesRegionCD = @SalesRegionCD, SalesRegion = @SalesRegion Where SalesRegionID = @SalesRegionID"

<asparameter Type="int32" Name="SalesRegionID" />

<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" />


<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"

<asp:TemplateField HeaderText="Rep Type">
<asp:Label Text='<%#Eval("SalesRegionType") %>' runat="server" />
<aspropDownList ID="dlRepType" runat="server" DataSourceID="sdRepType" DataTextField="SalesRegionType"
DataValueField="SalesRegionTypeID" SelectedValue='<%#Bind("SalesRegionTypeID") %>' />
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?



Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
problem with populating a dropdownlist in editTemplate of detailsview Jan ASP .Net 2 08-12-2007 10:52 AM
Problem Using SqlDataSource to automatically Update Value of item in Gridview Row Vaughn Haybittle ASP .Net Datagrid Control 0 04-02-2007 10:56 PM
Formview EditTemplate Dropdownlist Joe Reiss ASP .Net Web Controls 0 02-20-2007 02:34 PM
EditTemplate - Dropdownlist Krish ASP .Net 0 09-21-2005 03:22 PM
DropdownList in EditTemplate Yan Wang ASP .Net 2 05-24-2004 05:09 AM