I am sorting my incoming files by my 'Submitted'开发者_JAVA技巧 column (which is a date/time stamp field), however I need it to be in descending order with the most recent file on top. From my research, it looked like I would simply do this: view.Sort = "Submitted desc";
Is there something I'm missing? Here's the entire method:
private void PopulatePendingQueryGridView()
{
DataTable dt = new DataTable();
DataColumn col1 = new DataColumn("Spreadsheet", typeof(string));
dt.Columns.Add(col1);
DataColumn col2 = new DataColumn("Submitted", typeof(string));
dt.Columns.Add(col2);
string folder = Path.Combine(config.BulkQueryUploadFolder, CurrentUser);
if (Directory.Exists(folder))
{
string[] qryFiles = Directory.GetFiles(folder, "*.xlsx");
foreach (string qryFile in qryFiles)
{
FileInfo info = new FileInfo(qryFile);
DataRow row = dt.NewRow();
row["Spreadsheet"] = info.Name;
row["Submitted"] = info.CreationTime.ToString("yyyy/MM/dd HH:mm:ss");
dt.Rows.Add(row);
}
}
DataView view = new DataView(dt);
view.Sort = "Submitted desc";
pendingQryGridView.DataSource = view;
pendingQryGridView.DataBind();
gridUpdatePanel.Update();
}
Change your Submitted column data type to datetime. the sort direction shouldn't be case sensitive, but I'm not sure.
If needed you can set your datagrid field with a specified format.
精彩评论