problem in FilterParameters

Discussion in 'ASP .Net Datagrid Control' started by Bruno Alexandre, Apr 5, 2006.

  1. Hi guys...

    I have this

    <asp:SqlDataSource ID="dsProdutos2" runat="server"

    SelectCommand="SELECT * FROM [stoProducts]"

    FilterExpression="idProduct='@idProduct'"

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

    <FilterParameters>

    <asp:ControlParameter Name="idProduct" ControlID="MasterGrid"

    PropertyName="SelectedValue" Type="Int16" />

    </FilterParameters>

    </asp:SqlDataSource>


    And I get this Error:

    System.Data.EvaluateException: Is not possible to execute the operation '='
    in System.Decimal and System.String.


    i have DataKeyNames="idProduct" and the ShowSelectButton="True" in the
    MasterGrid gridview control

    but in the Database is an integer with AutoIncrement...

    How can I manage this, why is saying that it's a string? How can I cast it
    to integer?

    I already tried to change FilterExpression=" idProduct = '@idProduct' " to
    FilterExpression=" idProduct = @idProduct "
    but then I get an error that it couldnt find the column idProduct

    --


    Thank you in Advance.

    Bruno Alexandre
    (a Portuguese in Denmark)
    Bruno Alexandre, Apr 5, 2006
    #1
    1. Advertising

  2. Bruno Alexandre

    Guest

    I was experiencing the same problem. I had originally had this code:

    <asp:SqlDataSource ID="SqlDataSource4"
    runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString
    %>"
    SelectCommand="SELECT * FROM [Sites]" FilterExpression="SiteID =
    '@SiteID'">
    <FilterParameters>
    <asp:ControlParameter Name="SiteID" Type=Int32
    ControlID="GridView1" PropertyName="SelectedValue" />
    </FilterParameters>

    which gave me the error you described:

    I changed the code to:
    <asp:SqlDataSource ID="SqlDataSource4"
    runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString
    %>"
    SelectCommand="SELECT * FROM [Sites]" FilterExpression="SiteID =
    '{0}'">
    <FilterParameters>
    <asp:ControlParameter Type=Int32 ControlID="GridView1"
    PropertyName="SelectedValue" />
    </FilterParameters>

    ie: Changing the @SiteID parameter to {0} and removing the name from
    the FileterParameter.

    This must be a bug, it should have worked the other way also.

    Gavin Stevens
    MCSD.NET, MCAD.NET, MCSD






    Bruno Alexandre wrote:
    > Hi guys...
    >
    > I have this
    >
    > <asp:SqlDataSource ID="dsProdutos2" runat="server"
    >
    > SelectCommand="SELECT * FROM [stoProducts]"
    >
    > FilterExpression="idProduct='@idProduct'"
    >
    > ConnectionString="<%$ ConnectionStrings:DBConn %>" >
    >
    > <FilterParameters>
    >
    > <asp:ControlParameter Name="idProduct" ControlID="MasterGrid"
    >
    > PropertyName="SelectedValue" Type="Int16" />
    >
    > </FilterParameters>
    >
    > </asp:SqlDataSource>
    >
    >
    > And I get this Error:
    >
    > System.Data.EvaluateException: Is not possible to execute the operation '='
    > in System.Decimal and System.String.
    >
    >
    > i have DataKeyNames="idProduct" and the ShowSelectButton="True" in the
    > MasterGrid gridview control
    >
    > but in the Database is an integer with AutoIncrement...
    >
    > How can I manage this, why is saying that it's a string? How can I cast it
    > to integer?
    >
    > I already tried to change FilterExpression=" idProduct = '@idProduct' " to
    > FilterExpression=" idProduct = @idProduct "
    > but then I get an error that it couldnt find the column idProduct
    >
    > --
    >
    >
    > Thank you in Advance.
    >
    > Bruno Alexandre
    > (a Portuguese in Denmark)
    , Apr 25, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Random

    2.0 FilterParameters bug

    Random, Jun 7, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    517
    Juan T. Llibre
    Jun 7, 2005
  2. Replies:
    1
    Views:
    7,412
    Markus
    Aug 25, 2005
  3. Andre

    FilterParameters

    Andre, Jan 10, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    672
    Andre
    Jan 10, 2006
  4. Bruno Alexandre

    problem in FilterParameters

    Bruno Alexandre, Apr 5, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    2,163
  5. David
    Replies:
    0
    Views:
    660
    David
    Apr 19, 2006
Loading...

Share This Page