ASP.NET と C# を使用しています。これが私のコードです。
private const string ASCENDING = "ASC";
private const string DESCENDING = "DESC";
public SortDirection GridViewSortDirection
{
get
{
if (ViewState["sortDirection"] == null)
ViewState["sortDirection"] = SortDirection.Ascending;
return (SortDirection) ViewState["sortDirection"];
}
set { ViewState["sortDirection"] = value; }
}
public string SortExpression
{
get
{
if (ViewState["sortExpression"] == null)
ViewState["sortExpression"] = "JobNumber";
return ViewState["sortExpression"] as string;
}
set { ViewState["sortExpression"] = value; }
}
protected void OnSorting(object sender, GridViewSortEventArgs e)
{
SortExpression = e.SortExpression;
if (GridViewSortDirection == SortDirection.Ascending)
{
GridViewSortDirection = SortDirection.Descending;
}
else
{
GridViewSortDirection = SortDirection.Ascending;
}
BindGrid();
}
すべての列に並べ替えを適用し、正常に動作しています。しかし、日付列では、この順序(dd / mm / yyyy)のようです。
- 2012/11/30
- 2012/10/12
2012 年 9 月 10 日
<asp:BoundField DataField="ReportedDate" HeaderText="Reported Date" SortExpression="ReportedDate" DataFormatString="{0:DD/MM/YYYY}" HtmlEncode="false" />
この列のデータ型は日付です。
これを行う方法?私は間違っていますか?