|
Subject:
|
Filter dataset by Date?
|
|
Posted By:
|
spacky001
|
Post Date:
|
1/20/2007 7:43:06 PM
|
I have a datagrid displaying entries by users showing user, amount of time, date entered, and description bound to a dataset. Im trying to filter the dataset on the DateTime column but get an error. Here's the code: private void dgSummaryFilter(string SortColumn, string strFilter) { // Apply filter to the Job Summary dataset, enable button to remove filter, and bind Job Summary datagrid if (SortColumn=="TimeStamp") { Global.dsJobSummary.Tables[0].DefaultView.RowFilter = SortColumn + " = " + strFilter; } else { Global.dsJobSummary.Tables[0].DefaultView.RowFilter = SortColumn + " LIKE '*" + strFilter + "*'"; } btnShowAll.Enabled=true; dgSummary.DataSource = Global.dsJobSummary.Tables[0].DefaultView; dgSummary.DataBind(); }
Im pretty sure its to do with the filter string on the datetime column. How do i concatenate the string?
|
|
Reply By:
|
Quick209
|
Reply Date:
|
1/23/2007 6:17:54 PM
|
Hmm, looks like it should work but I will drop just a few suggestions you could try.
For concatentating the date, you will have to put it into a DateTime object class and then output it with the "YourDateTimeObject.ToShortDateString()" method to get the short date format which should be MM/DD/YYYY.
Next, I don't know for sure but do you need a pair of single tickets encapsulated by quotes around your strFilter on the line above the one that looks for the wildcard? I haven't really filtered from the dataset. I read somewhere that the app server isn't built for that and should be best left to SQL if you have a lot of EU.
|
|