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.
Unfortunately, activation email could not send to your email. Please try again.

Sorting Date field in GDBG

Thread ID:

Created:

Updated:

Platform:

Replies:

34066 Sep 1,2005 07:31 AM Sep 5,2005 07:35 AM Windows Forms 7
loading
Tags: GridControl
Atith Pagdi
Asked On September 1, 2005 07:31 AM

I have a field in the GDBG that comes in as a date (dd mmm yyyy) without hyphens. When I click the header column tab to sort, the date is treated as a string and sorted. How can I actually sort by date. Thanks, Atith

Administrator [Syncfusion]
Replied On September 1, 2005 07:50 AM

The GridDataBoundGrid really does not do any sorting. It delegates the sorting to the IBindingList datasource. So, if you are using a DataTable as the grid''s datasource, it is the dataTable.DefaultView that is doing the sorting. So, if you are seeing the dates being sorted like strings, it suggests that the type of this DataColumn in the DataTable is a string object and not a DateTime object. If this is the case, the simplest way to handle the problem would be to store the value as a DataTime and set GridBoundColumn.StyleInfo.Format to tell the grid to display the DateTime value with a particular format. If this is not possible, then you would have to do some work to work around the string type being set in the datasource. Here is a forum thread that discusses a couple of ways to do this and has sample information. But changing the DataColumn type will be the simplest solution.

Administrator [Syncfusion]
Replied On September 2, 2005 11:49 AM

Could you please give the link to the discussion thread you mentioned above. Thanks, Bits.

Administrator [Syncfusion]
Replied On September 2, 2005 11:56 AM

Sorry. http://www.syncfusion.com/Support/Forums/message.aspx?MessageID=21940

Atith Pagdi
Replied On September 5, 2005 06:33 AM

Clay, I''m getting this date field from the DB, but the GDBG shows it in the format mm/dd/yyyy while I want the format dd-mmm-yyyy. How can I achieve this? Thanks.

Administrator [Syncfusion]
Replied On September 5, 2005 06:51 AM

You set the GridBoundColumn.StyleInfo.Format to specify the format you want to see, and you make sure GridBoundColumn.StyleInfo.CellValueType is being set to typeof(DateTime). It should be if the column in your datatable is DateTime.

Atith Pagdi
Replied On September 5, 2005 06:53 AM

Any code sample for this? I do not have grid bound columns.

Administrator [Syncfusion]
Replied On September 5, 2005 07:35 AM

grid.Binder.InternalColumns["someColumnName"].StyleInfo.Format = "yyyy-MM-dd"; See this KB. http://www.syncfusion.com/support/kb/grid/Default.aspx?ToDo=view&questId=85

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;