problem in FilterParameters

  • Thread starter Bruno Alexandre
  • Start date
B

Bruno Alexandre

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)
 
G

gavin.stevens

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
(e-mail address removed)
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,817
Latest member
DicWeils

Latest Threads

Top