Click here to Skip to main content
15,881,380 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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

1 solution

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:
SQL
SELECT 
   EmpId, Employeename, JoinDate
FROM
   MyEmployeeTable
WHERE
   JoinDate BETWEEN @FromDate AND @ToDate
 
Share this answer
 
Comments
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.

Thanks.
_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.

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900