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