Wrox Programmer Forums
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 20th, 2007, 08:43 PM
Authorized User
 
Join Date: Nov 2005
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default Filter dataset by Date?

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?
 
Old January 23rd, 2007, 07:17 PM
Authorized User
 
Join Date: Apr 2005
Posts: 94
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Help for Select SQL Query with date filter pushpa SQL Server DTS 0 February 6th, 2007 10:06 AM
Filter form with date fields problem!! chiefouko Access 2 August 14th, 2006 10:15 AM
Macro/Date/Advanced Filter alexyss15 Excel VBA 1 March 30th, 2006 01:06 PM
sql date filter keyvanjan Classic ASP Databases 3 March 8th, 2006 10:17 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.