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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Sorting Date field in GDBG

Thread ID:





34066 Sep 1,2005 11:31 AM UTC Sep 5,2005 11:35 AM UTC WinForms 7
Tags: GridControl
Atith Pagdi
Asked On September 1, 2005 11:31 AM UTC

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 11:50 AM UTC

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 03:49 PM UTC

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

Administrator [Syncfusion]
Replied On September 2, 2005 03:56 PM UTC

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

Atith Pagdi
Replied On September 5, 2005 10:33 AM UTC

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 10:51 AM UTC

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 10:53 AM UTC

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

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

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


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon 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.Close Icon