我已經實現了某種功能我隱藏,它工作正常用語言,但不能與數字... 如GridView的排序不工作的數字
4,693
1,494
23
當我解決這我得到
> 1,494
> 23
> 4,693
所以這意味着它只是檢查的第一個數字....
我對排序的代碼是:
protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)
{
if (IsPostBack)
{
DataTable dt = Session["TaskTable"] as DataTable;
if (dt != null)
{
//Sort the data.
dt.DefaultView.Sort = e.SortExpression + " " + GetSortDirection(e.SortExpression);
GridView1.DataSource = Session["TaskTable"];
GridView1.DataBind();
}
}
else
{
Response.Redirect("~/Reports1mod.aspx");
}
}
private string GetSortDirection(string column)
{
// By default, set the sort direction to ascending.
string sortDirection = "ASC";
// Retrieve the last column that was sorted.
string sortExpression = ViewState["SortExpression"] as string;
if (sortExpression != null)
{
// Check if the same column is being sorted.
// Otherwise, the default value can be returned.
if (sortExpression == column)
{
string lastDirection = ViewState["SortDirection"] as string;
if ((lastDirection != null) && (lastDirection == "ASC"))
{
sortDirection = "DESC";
}
}
}
// Save new values in ViewState.
ViewState["SortDirection"] = sortDirection;
ViewState["SortExpression"] = column;
return sortDirection;
}
這可能是因爲表中包含字符串,而不是整數。 – 2009-12-18 07:56:55
您是如何填充字段的......您是否使用dataformat字符串填充爲數字,或者將數字轉換爲字符串以添加逗號,然後填充Grid View列? – 2009-12-18 08:13:37