We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

GridFilterBar and Date/Time fields

I have a databound grid control where one of the columns is a datetime field. When I use the gridfilterbar and wire it to the control all is fine until I select an entry for the date/time from the list of entries instead of giving a range or something. It always comes up with an empty grid. FYI: The field does not display seconds the drop down does.

7 Replies

AD Administrator Syncfusion Team June 16, 2003 08:18 PM UTC

The orders table in the \Syncfusion\Essential Suite\Grid\Samples\DataBound\FilterBarGrid has date columns that do not have this problem. Are you setting the CellValueType for the column to typeof(DateTime)? The sample uses code like: gbcc["RequiredDate"].StyleInfo.Format = "d"; gbcc["RequiredDate"].StyleInfo.CellValueType = typeof(DateTime); If setting the CellValueType does not handle the problrm, can you attach a sample?

CC Charles Carlin June 17, 2003 11:25 AM UTC

This is a real simple project. It is connecting to a MS-SQL database. The table definition is: CREATE TABLE [dbo].[cg_audit_trail] ( [table_name] [varchar] (50) NOT NULL , [row_id] [bigint] NOT NULL , [action_type] [char] (1) NOT NULL , [datetime_stamp] [datetime] NOT NULL , [user_id] [varchar] (50) NOT NULL , [data] [varchar] (2000) NULL ) ON [PRIMARY] GO

AD Administrator Syncfusion Team June 17, 2003 12:47 PM UTC

Chuck, Your code works OK for me. I don't get the empty grid. What regional setting are you using? For data, I entered values in SQL Manager that were just dates and dates with times, an dit did not seem to affect the filtering as you described.

AD Administrator Syncfusion Team June 17, 2003 12:56 PM UTC

Also, what version of teh grid are you using? I tried it both with and 1.6.

CC Charles Carlin June 17, 2003 02:02 PM UTC

Try using GETDATE() to set the datetime field. If I manually just put in an entry without the full time filled in it seems to work. It seems like the decimal values after the seconds if they are not 000 then the values are not found correctly. Is there anyway to format the date so it would work. It seems like the format only effects the display and not the filter.

AD Administrator Syncfusion Team June 17, 2003 02:57 PM UTC

OK, I can see the problem by adding a line like ds.Tables[sName].Rows[0][3] = DateTime.Now; to set one of the field to a DateTime value. The DataView.RowFilter is failing in this situation. If you replace the grid with a DataGrid and just try to apply the DataView.RowFilter there as well, it also fails in this same situation. I think it is rthe milliseconds that is causing the problem. Instead of the code above, if I use this code to set the value (with zero milliseconds), things work OK.
DateTime dt = DateTime.Now;
ds.Tables[sName].Rows[0][3] = new DateTime(dt.Year, dt.Month, dt.Day, dt.Hour, dt.Minute, dt.Second, 0);
We will look into what can be done to avoiod this problem.

CC Charles Carlin June 17, 2003 04:37 PM UTC

OK I will truncate the milliseconds off for the meantime.

Live Chat Icon For mobile
Up arrow icon