Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
I have form for monthly payments on salary for workers
workers take payments on their salary within month
my form consists textboz for insert payment value and datetimpepicker for insert payment date and combobox returns workers names
after inserting all data I view inseted rows in datagridview
my question is I want to search all payments between two dates for example I want to view in datagridview all payments between 08-01-2014 and 08-31-2014 for all workers
how to create search in form
must I put two datetimepick controls in the form the first datetimepicker for start date and the second datetimepicker for end date or there is another way for search
Posted
Comments
PIEBALDconsult 18-Sep-14 10:06am    
I assume the DataGridView is bound to a DataTable. (It should actually be bound to the DefaultView of the DataTable.) You should be able to set the RowFilter property of the DefaultView.
http://msdn.microsoft.com/en-us/library/system.data.dataview.rowfilter(v=vs.110).aspx
http://msdn.microsoft.com/en-us/library/system.data.datacolumn.expression(v=vs.110).aspx
sometable.DefaultView.RowFilter = "somedate BETWEEN '2014-08-01' AND '2014-08-31'"
Some experimentation may be required.
ChauhanAjay 18-Sep-14 12:28pm    
Yes you will have two date picker controls and basing on the selection you can filter your datatable between the date's and bind it back to the datagridview.
Er. Puneet Goel 19-Sep-14 2:35am    
Have you prepared the sql stored procedure for that ?
NekoNao 19-Sep-14 2:42am    
Yeah, I guess you should try SQL Queries

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