TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Martin Swanston
NA
4
361
Sort DataGrid using DateTime Field
Apr 5 2006 10:02 AM
Hi
Am new to C#/ASP, but am working on stuff to get me up to speed. My project for this week involves retreiving data from a SQL server, and then displaying it in a datagrid. Now the data is sorted within the SQL string, and then sorted again when filled as a dataset, but as the dates/times are many lines of the same day, it seems to mess ths sorting up - it ignores the format of the dataset columns (as the data has not yet been bound to it), but I need it to sort correctly by date time, but it comes out like this:
05-Apr-2006 11:23:49.48
05-Apr-2006 11:04:48.61
05-Apr-2006 10:04:12.27
05-Apr-2006 09:58:27.54
05-Apr-2006 09:56:54.42
05-Apr-2006 10:38:18.04
The code to write the dataset to the datagrid is as follows:
using
( vAdapt
as
IDisposable ) {
DataSet vDS =
new
DataSet();
vAdapt.Fill( vDS );
vDS.Tables[0].DefaultView.Sort = "LoginTime DESC";
MetricsDataGrid.DataSource = vDS.Tables[0].DefaultView;
MetricsDataGrid.DataBind();
MetricsDataGrid.Visible =
true
;
}
Can anyone help me ensure the data is sorted correctly?
Regards
Martin
Reply
Answers (
0
)
My.Log.WriteException not writing to Event Log with ASP.Net 2.0
Downloading Content to MS Word