Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > FilterExpression - AccessDataSource

Reply
Thread Tools

FilterExpression - AccessDataSource

 
 
mosscliffe
Guest
Posts: n/a
 
      05-29-2006
I am trying to filter an accessdatsource by adding a FilterExpression

If I have Field = 2 It works fine
If I have Field IN (1,5,7) it works fine

So now I want it to reference a dropdownlist

so I try Field = ddlCats.SelectedValue - Fails Miserably

So I read further and try

Field='@FieldID'
and then in FilterParameters I have FieldID pointing at
ddlCats.SelectedValue

SelectedValue and the field being tested are INTS

SourceCode Generated
<asp:AccessDataSource ID="accGetMatched" runat="server"
DataFile="~/AppData/lists.mdb"
SelectCommand="SELECT[ListID], [CatID], [Category],
[Title], [Details] FROM [PublicLists] WHERE (([Title] LIKE '%' + ? +
'%') OR ([Details] LIKE '%' + ? + '%'))" FilterExpression="CatID =
'@CatID'">
<SelectParameters>
<asp:ControlParameter ControlID="tbxLookup"
Name="Title" PropertyName="Text" Type="String" />
<asp:ControlParameter ControlID="tbxLookup"
Name="Details" PropertyName="Text" Type="String" />
</SelectParameters>
<FilterParameters>
<asp:ControlParameter ControlID="ddlCats" Name="CatID"
PropertyName="SelectedValue" />
</FilterParameters>


</asp:AccessDataSource>
-------------------------------------------------------------------------------------------------

I get the following error message:
Cannot perform '=' operation on System.Int32 and System.String

The Like tests based on the textboxes all work it is only when I try to
filter on the value of the dropdownlist do I get the error.

I may be completely wrong in how I am attempting to do this filter, but
I will always do the LIKE Filtering, but only occasionally the
FilterEpression. When I get it working I will attempt to fill the
properties programmatically.

If I do not have the quotes around 'FieldID' it gives the error: Can't
find Column FieldID

Any pointers or example syntax, would be gratefully received.

 
Reply With Quote
 
 
 
 
mosscliffe
Guest
Posts: n/a
 
      05-30-2006
On further research it may be because SelectedValue is a string, but
when I try my filter as

<asp:AccessDataSource ID="accGetMatched" runat="server"
DataFile="~/AppData/lists.mdb"
SelectCommand="SELECT[ListID], [CatID], [Category],
[Title], [Details] FROM [PublicLists] WHERE (([Title] LIKE '%' + ? +
'%') OR ([Details] LIKE '%' + ? + '%')) order by category,
title" FilterExpression="CatID ='@CatID'">
<SelectParameters>
<asp:ControlParameter ControlID="tbxLookup"
Name="Title" PropertyName="Text" Type="String" />
<asp:ControlParameter ControlID="tbxLookup"
Name="Details" PropertyName="Text" Type="String" />
</SelectParameters>
<FilterParameters>
<asparameter
DefaultValue="Int32.Parse(ddlCats.SelectedValue)" Name="CatID" />
</FilterParameters>

Cannot perform '=' operation on System.Int32 and System.String

Please help, I am wasting so much time,

 
Reply With Quote
 
 
 
Reply

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
GridView - Changing FilterExpression of SQLDataSource and Paging Henry Habermacher [MVP Access] ASP .Net 2 07-31-2007 04:05 AM
Re: Number of rows returned from ObjectDataSource.FilterExpression John ASP .Net 2 03-18-2006 02:52 PM
Gridview - Convert Data Type in filterexpression DummyDumb ASP .Net 2 02-13-2006 08:17 AM
Programmatically set FilterExpression and FilterParameters of SqlDataSource fuchs.markus@gmail.com ASP .Net 1 08-25-2005 02:24 PM
FilterExpression for table RA ASP .Net 0 11-05-2004 05:08 PM



Advertisments