locked
Sql db parser error RRS feed

  • Question

  • User351843852 posted

    I keep getting the folloowing error:  I am taking it from my textbook assignment

    Server Error in '/' Application.


    Parser Error

    Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately. 

    Parser Error Message: Unknown server tag 'asp:ControlParameters'.

    Source Error: 

    Line 38:         Runat="server">
    Line 39:         <FilterParameters>
    Line 40: <asp:ControlParameters Name="Name" ControlID="txtGrain" /> Line 41:             </FilterParamaters>
    Line 42:             </asp:SqlDataSource>


    Source File: /Unit7.aspx    Line: 40

    My code is:

    <%@ Page Language="C#" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
    <style type="text/css">
    td, th
    {
    padding:10px;
    }
    </style>
    <title>Show Filter Expression</title>
    </head>
    <body>
    <form id="form1" runat="server">
    <div>
    <asp:TextBox
    id="txtGrain"
    Runat="server" />

    <asp:Button
    id="btnMatch"
    Text="Match"
    Runat="server" />
    <hr />

    <asp:Gridview
    id="grdGrain"
    DataSourceID="srdGrain"
    Runat="server" />
    <asp:SqlDataSource
    id="srcGrain"
    SelectCommand="SELECT Id, Name, Color, Gravity, Type FROM Grain"
    FilterExpression="Name LIKE '{0}%'"
    ConnectionString="<% ConnectionStrings:Grain %>"
    Runat="server">
    <FilterParameters>
    <asp:ControlParameters Name="Name" ControlID="txtGrain" />
    </FilterParamaters>
    </asp:SqlDataSource>
    </div>
    </form>
    </body>

    </html>

    Saturday, February 23, 2013 5:02 PM

Answers

  • User-1618234021 posted

    Use <asp:ControlsParameter ...> There is an an extra 's' in the end.

    Following is example code for SqlDataSource for your scenario:

    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:yourConnectionString %>" 
            SelectCommand="SELECT * FROM [Customer] WHERE ([FirstName] LIKE '%' + @FirstName + '%')">
            <SelectParameters>
                <asp:ControlParameter ControlID="TextBox1" Name="FirstName" PropertyName="Text" 
                    Type="String" />
            </SelectParameters>
        </asp:SqlDataSource>



    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, February 24, 2013 3:24 AM