473,472 Members | 2,208 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

gridview filterexpression problem

I have a gridview object with a sqldatasource as its sourceid.
Everything was going so well until I came across this problem.

My SELECTCOMMAND for my sqldatasource is:
select alertid,subject,createdt,eventid,eventname, statuscd,trgid from
vwAlerts order by createdt desc

Now, based on a fiew input fields, I put together a WHERE clause for
the filterexpression. For example, this filterexpression works great:

createdt >= '1/1/2007' and createdt <= '1/31/2007'

Simple so far. I also have an input field which is actually a field
in a child table (emaildistribution). If they put anything in this
field, the filterexpression needs to do an IN clause like this:

createdt >= '1/1/2007' and createdt <= '1/31/2007' AND alertid
IN(select alertid from emaildistribution where emailaddress like
'%yahoo.com%'

When I run this, I get an "Missing operand after 'alertid' operator"
error. Doesn't matter if I use LIKE or = in the IN clause. Is there
any way to make this work? I hate to go back to the manual binding
method.

Thanks for any help!
--Curt

Feb 21 '07 #1
3 5151
Hi

Can you post yor aspx page code?
Regards

"Curt" <ad***********@sshomes.netwrote in message
news:11**********************@j27g2000cwj.googlegr oups.com...
>I have a gridview object with a sqldatasource as its sourceid.
Everything was going so well until I came across this problem.

My SELECTCOMMAND for my sqldatasource is:
select alertid,subject,createdt,eventid,eventname, statuscd,trgid from
vwAlerts order by createdt desc

Now, based on a fiew input fields, I put together a WHERE clause for
the filterexpression. For example, this filterexpression works great:

createdt >= '1/1/2007' and createdt <= '1/31/2007'

Simple so far. I also have an input field which is actually a field
in a child table (emaildistribution). If they put anything in this
field, the filterexpression needs to do an IN clause like this:

createdt >= '1/1/2007' and createdt <= '1/31/2007' AND alertid
IN(select alertid from emaildistribution where emailaddress like
'%yahoo.com%'

When I run this, I get an "Missing operand after 'alertid' operator"
error. Doesn't matter if I use LIKE or = in the IN clause. Is there
any way to make this work? I hate to go back to the manual binding
method.

Thanks for any help!
--Curt

Feb 21 '07 #2
Curt,

The FilterExpression applies to the dataset after it gets loaded from the
database. It doesn't effect the select statement. Rather the select gets the
data inside the dataset and then the FilterExpression hides undesired rows.
Based on this understanding, putting another select in the IN operator
should not work since the select is intended to run against the database,
not against the dataset.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Curt" <ad***********@sshomes.netwrote in message
news:11**********************@j27g2000cwj.googlegr oups.com...
>I have a gridview object with a sqldatasource as its sourceid.
Everything was going so well until I came across this problem.

My SELECTCOMMAND for my sqldatasource is:
select alertid,subject,createdt,eventid,eventname, statuscd,trgid from
vwAlerts order by createdt desc

Now, based on a fiew input fields, I put together a WHERE clause for
the filterexpression. For example, this filterexpression works great:

createdt >= '1/1/2007' and createdt <= '1/31/2007'

Simple so far. I also have an input field which is actually a field
in a child table (emaildistribution). If they put anything in this
field, the filterexpression needs to do an IN clause like this:

createdt >= '1/1/2007' and createdt <= '1/31/2007' AND alertid
IN(select alertid from emaildistribution where emailaddress like
'%yahoo.com%'

When I run this, I get an "Missing operand after 'alertid' operator"
error. Doesn't matter if I use LIKE or = in the IN clause. Is there
any way to make this work? I hate to go back to the manual binding
method.

Thanks for any help!
--Curt

Feb 21 '07 #3
Thanks for your replies.

I got it to work. Eliyahu your reply got me thinking...I never
considered changing the SELECT command if the user enters any
information in a certain field. Now I just change the select command
to include the IN clause...this works great.

Thanks !

-Curt


Feb 21 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: | last post by:
Hello, Does anyone have an idea on how I can filter the data in the gridview control that was returned by an sql query? I have a gridview that works fine when I populate it with data. Now I...
7
by: Ken | last post by:
Hi All - I have a filtered GridView. This GridView has a check box in the first column. This check box is used to identify specific rows for delete operations. On the button click event I...
2
by: Bill Manring | last post by:
I am writing a very simple web application using VS 2005 and a SQL Server Database. I am just starting to experiment wth .NET 2.0 and I am trying out the supposedly improved databinding. I...
1
by: Henry Habermacher [MVP Access] | last post by:
Environment: VS2005, ASP.Net 2.0, SQLServer 2000, VB.Net, IIS6 I use a GridView Control which is based on a SQLDataSource. The datasource is based on a Select statement and is filtered by the...
1
by: Andrew Nav | last post by:
I dragged a table from a datasource on to my web form and the GridView cpntrol was created. I turned on paging, and Edit and Delete buttons. I ran the app and everything worked great - not a...
4
by: P. Yanzick | last post by:
Hello, I've been playing with master/detail views as well as editing in the gridview, and I ran across a strange problem that I am not exactly sure where to go to try to solve. I have 2...
2
by: DummyDumb | last post by:
Hi, I've got a Gridview utilizing a filterexpression: <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" OnDeleted="ItemDeleted" EnableCaching="true"...
4
by: Bishop | last post by:
I have a number of simple select queries that a user needs to be able to execute and display the data on the screen in a gridview. My thought was that I could use a Gridview set to dymanically...
2
by: mike | last post by:
I have a page with a LoginView which contains a Gridview and a DetailsView, each in its own UpdatePanel The problem that I am experiencing is that when I select a record in the Gridview (using a...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.