Click here to Skip to main content
13,139,834 members (42,961 online)
Rate this:
Please Sign up or sign in to vote.
Dear All, Good Day !!

Am working on , 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 20:13pm

1 solution

Rate this: bad
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:
   EmpId, Employeename, JoinDate
   JoinDate BETWEEN @FromDate AND @ToDate
Ranjith Reddy CSE 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.

_Amy 29-Aug-12 2:47am
Use SQL Parameter to add your parameters.
Sandeep Mewara 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 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 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 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
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01 | 2.8.170915.1 | Last Updated 29 Aug 2012
Copyright © CodeProject, 1999-2017
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