Update database using SQLDatasource with Stored procedure & Gridview

Posted on 2009-05-01
Last Modified: 2013-11-07
I've got a Gridview using a SQL Datasource and I have an update stored procedure.  I'm getting an error when I click the "Update" on a row.  Then error is:
Could not find control 'fID' in ControlParameter 'featureID'.
<asp:SqlDataSource ID="SqlDataSource1" runat="server" 

                    ConnectionString="<%$ ConnectionStrings:myDB1 %>"

                    SelectCommand="QryFeatures" SelectCommandType="StoredProcedure" 

                    UpdateCommandType="StoredProcedure" UpdateCommand="UptFeature"

                    DeleteCommandType="storedProcedure" DeleteCommand="DelFeature">


                        <asp:ControlParameter ControlID="fID"  Name="featureID" PropertyName="text"/>

                       <asp:ControlParameter ControlID="fText"  Name="featureText" PropertyName="text"/>



<asp:GridView ID="gvFeatures" runat="server" DataSourceID="SqlDataSource1" AutoGenerateColumns="false" DataKeyNames="featureID">


                        <asp:BoundField DataField="featureID" />


                        <asp:TemplateField HeaderText="Feature">

                            <ItemStyle Width="200px" />


                                <asp:Label ID="lblFeature" runat="server" Text='<%# Eval("featureText") %>'></asp:Label>



                                <asp:TextBox ID="fText" runat="server" Text='<%# Bind("featureText") %>'></asp:TextBox>



			 <asp:TemplateField HeaderText="Edit">


                                <asp:LinkButton ID="LinkButton1" runat="server" Text="Edit" CommandName="Edit" CausesValidation="false" />



                                <asp:LinkButton ID="LinkButton3" runat="server" Text="Update" CommandName="Update"

                                    CausesValidation="true" />

                                <asp:LinkButton ID="LinkButton4" runat="server" Text="Cancel" CommandName="Cancel"

                                    CausesValidation="false" />





Open in new window

Question by:robnhood00
    LVL 9

    Accepted Solution

    LVL 28

    Expert Comment

    It's because you are using a ControlParameter bound to a control with ID="fID". Since I don't see that control anywhere in the Edit template, i'm assuming you aren't actually setting the value.

    You can also look into setting up the datakeys in the gridview so it automatically passes the primary key value to an update or delete.

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Join & Write a Comment

    Suggested Solutions

    In my previous two articles we discussed Binary Serialization ( and XML Serialization ( In this article we will try to know more about SOAP (Simple Object Acces…
    Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    how to add IIS SMTP to handle application/Scanner relays into office 365.

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now