Click here to Skip to main content
15,913,027 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi i am developing an application which requires to display data in date format. I am using sharpdevelop and msaccess for database.

I am extracting the data from the database and adding it into datagrid. One of the field is date, the data for this field is stored in date format in database. While adding the date data to the date column of the datagrid i am using cdate function to convert it into date. and also that column datatype is been mention as date. Data is been populated properly but at run time when i click on the date column of datagrid it sort it considering it as string and produces wrong search result. can any1 guide related to same.

While adding data to the datagrid im converting the data to date
Format(cdate(dr(6)),"dd/MM/yyyy")

and the datatype of the datagrid column in which date is going to be stored is in date format.
Posted
Updated 10-Dec-11 5:02am
v2
Comments
Abhinav S 10-Dec-11 8:22am    
Post some of your code here. Without looking at code, its difficult to make out where things could be going wrong.
RaviRanjanKr 10-Dec-11 9:10am    
will you show your effort please :)

To specify how items are sorted in a DataGrid, you use the SortDescription type to sort the items in the source view.
For more information See :
http://msdn.microsoft.com/en-us/library/dd833072(v=vs.95).aspx[^]
http://www.ehow.com/how_6585975_sort-columns-datagrid.html[^]
 
Share this answer
 
Comments
RaviRanjanKr 10-Dec-11 9:10am    
My 5!
Manoj K Bhoir 11-Dec-11 0:47am    
Thank You RaviRanjankr!
I have added 1 more column in the data grid keeping that as date and when ever custom date column is been sorted i have filtered the result on the date column.
 
Share this answer
 
Hi,
Try this:

VB
DGV.Sort(DGV.Columns("Column_Name"), System.ComponentModel.ListSortDirection.Ascending)
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900