Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
Dear All, Good Day !!
 
Am working on Asp.net , C# , SqlServer 2005.
 
I need to Search the Records From Gridview based on the Dates ( From and To)
 
on my webpage I have a Gridview and Textboxes as
 
From : DDTextbox MMTextbox YYTextbox To :DD1textbox MM1txtbox YY1txtbox - SearchButton
 
if the user enters FROM date and TO Date and Clicks on search button it should search all the records to that entered dates
 
for example : if the user wants to search From : 29/07/2012 TO : 29/08/2012
 
it must display these FROM and TO Records....what ever he searches.
 
In gridview I have a Fields as EmpId,EmployeeName,JoinDate...
 
Now i need to search the join dates ( FROM and TO)
 

Please help.
 
Thanks for ever.
Posted 28-Aug-12 21:13pm

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

All you need is a query with search parameters in it that will fetch records. Once fetched, you need to bind them to the grid.
 
Query would be something like:
SELECT 
   EmpId, Employeename, JoinDate
FROM
   MyEmployeeTable
WHERE
   JoinDate BETWEEN @FromDate AND @ToDate
  Permalink  
Comments
Ranjith Reddy CSE at 29-Aug-12 2:40am
   
Boss, In query how should i enter from date and to date.
 
For example I wnat to search From : 29/07/2012 TO : 29/08/2012.......So how to do this.
 
Please help me.
 
Thanks.
_Amy at 29-Aug-12 2:47am
   
Use SQL Parameter to add your parameters.
Sandeep Mewara at 29-Aug-12 2:48am
   
1. You should use single textbox (or a datepicker!) for one date and not three - kinda clean UI
2. Even if you take 3 textbox for 1 date, before passing it to DB query, form a proper date from the three textbox.
Ranjith Reddy CSE at 29-Aug-12 2:46am
   
I took total 6 textboxes
From : DDtextbox/MMtextbox/YYtextbox
To : DD1textbox /MM1textbox/YY1textbox
 

and a Search button to search these entered Dates in textboxes
Sandeep Mewara at 29-Aug-12 2:49am
   
As already said not a good way to take date inputs, there will be lots of validation involved if 6 textboxes!
 
Further, once you have date, assign/pass it as a proper to/from date.
_Amy at 29-Aug-12 2:48am
   
Good Answer. +5. :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 6,055
1 DamithSL 4,621
2 Maciej Los 4,087
3 Kornfeld Eliyahu Peter 3,500
4 Sergey Alexandrovich Kryukov 3,294


Advertise | Privacy | Mobile
Web01 | 2.8.141220.1 | Last Updated 29 Aug 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100