【发布时间】:2013-06-01 17:59:57
【问题描述】:
我想对我的整数数据进行排序,但我想让它更易于阅读,如果我有像 1000000000 这样的数据,我希望它显示 1,000,000,000 所以我在 mysql 中使用这个查询;
format(col_name,0)
我尝试在 C# 中使用 gridview 使用 sort 函数对其进行排序,我使用它对 gridview 进行排序;
protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)
{
tempExp = e.SortExpression;
Session["sort"] = tempExp;
showData();
}
void showData()
{
tempExp = (string)Session["sort"];
sortProperty = SortDirection.Descending;
sortedView = new DataView(dataset);
sortedView.Sort = tempExp + " Desc";
GridView1.DataSource = sortedView;
GridView1.DataBind();
}
但这就是我尝试对 data2 进行排序时发生的情况;
+================+=================+
| data1 | data2 |
+================+=================+
| 21,039,000 | 6 |
| 30,080,000 | 4,062 |
| 209,120,040 | 28,692 |
| 201,200,900 | 2,115 |
| 1,100,900 | 15,858 |
+================+=================+
我该如何解决?
【问题讨论】:
-
如果你不应用排序功能,你怎么能期望它被排序?
-
一般来说,我不会在 SQL 查询中应用数字格式。这就是用户界面的用途。有一个How to: Format Data in the Windows Forms DataGridView Control 可能会对您有所帮助。
-
为什么这个标签是 MySQL?如果您可以在 SQL 中进行排序,请显示查询。如果没有,请删除标签。
-
我阅读了How to: Format Data in the Windows Forms DataGridView Control 并使用了
this.dataGridView1.Columns["UnitPrice"].DefaultCellStyle.Format = "c";我已经添加了namspaceSystem.Windows.Forms并添加了引用System.Windows.Forms.dll但仍然找不到DefaultCellStyle -
为什么不在 mySQL 中对其进行排序,然后再将其传递给 DataGridView?