我已经实现了某种功能我隐藏,它工作正常用语言,但不能与数字... 如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