Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET WinForm
Hi Guys , i was spent more on these requirement, but i doesn't get the answer.
 
I Have a DataGrid with columns Like BENCHMARKNO ,BENCHMARKNAME ,CLIENTCODE ,NOFILES ,REFERENCENO ,NORESOURCES ,STARTDATE, FINISHDATE, AUTHORIZEDBY.

 
Except STARTDATE and FINISHDATE Columns , Remaining all columns are sorted successfully.
 

I am getting the Date Formats like these
 

01-March-2010
 
05-February-2009

13-January-2009
 
07-July-2013
 

I Want like these :
 
13-January-2009
05-February-2009
 
01-March-2010
 
07-July-2013
 

Please any one help me.
Posted 20-Mar-13 2:32am
Edited 20-Mar-13 2:33am
v2
Comments
ryanb31 at 20-Mar-13 9:02am
   
Please post the relevant code for the sorting and your aspx columns of the datagrid.
Prasad Khandekar at 20-Mar-13 17:22pm
   
Check whether startdate & finishdate columns in database are of correct data type and You have also specified the correct data type of respective columns in DataGridView. The error you are facing mostly occurs because of incorrect data type or a string value in column.
José Amílcar Ferreira Casimiro at 20-Mar-13 17:23pm
   
You get this order result, because the ordering of dates is being done by string type.
Sort for a different data type, or format the date in a way that the ordering is correct.
CH Guravaiah at 21-Mar-13 2:48am
   
Starttime and finishtime are DateTime Datatype
   
Probably the sorting operation is done by javascript (client-side), right ? This way your code is sorting the date column as string.

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

I'm not sure what about you're asking for...
 
You can sort data in 2 methods:
1) using DataGridView properties: Sorting Data in WinForms DataGridView Control[^]
or
2) sorting its datasource:
SELECT Field1, Field2, ...
FROM YourDataBase
ORDER BY StartDate, EndDate
 
Date format has nothing to do with it.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 390
1 Jochen Arndt 150
2 Richard MacCutchan 135
3 DamithSL 95
4 Garth J Lancaster 90
0 OriginalGriff 6,045
1 DamithSL 4,601
2 Maciej Los 4,087
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,260


Advertise | Privacy | Mobile
Web04 | 2.8.141220.1 | Last Updated 21 Mar 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100