Filtering a GridView by A Name and Two Dates

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Sep 2008
Posts: 1
Reputation: JDMartin is an unknown quantity at this point 
Solved Threads: 0
JDMartin JDMartin is offline Offline
Newbie Poster

Filtering a GridView by A Name and Two Dates

 
0
  #1
Sep 9th, 2008
I have a GridView, bound to a SqlDataSource. The SqlDataSource points to a table with seveeral fields, including an Activity Date field and a Name field.

By default I want it to display every entry in the table, but I want to be able to dynamically filter it with three possible variables: A Before date, an After date, and a Name, all of which are selected from separate DropDown lists. For example, if a user picks a Before Date, I want to filter out all entries with dates prior to the Before Date. If the user selects an After date, I want to filter out all entries with dates later than the After date. If both are selected, then both. And at any time, I want to limit all entries to those with the specified Name.

I have written the following Filter Expression:

  1. [Name] = '(0}' AND [Activity Date] > '{1}' AND [Activity Date] < '{2}'

'(0)' = A Name selected value of a DropDownList.

'{1}' = Date,, which is selected on a Calendar and written to a Field.

'{2}' = Date, which is selected on a Calendar and written to a Field.

The problem is this: Dates are only applied to the Filter if a Name has already been selected. Ex. If I pick Before and After dates, nothing happens, but if I then pick a Name, then all three are applied. If I pick a Name first, it is applied. Any Dates I select after that are also applied.

Why would it be working this way, and is there a better method than that which I am using?
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the VB.NET Forum
Thread Tools Search this Thread



Tag cloud for VB.NET
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC