DataGrid数据排序
小弟初学VS2003
不知如何将绑定于DataGrid里的学生成绩排序?
考虑先排序好再传到DataGrid里,但视图不支持ORDER BY(因为DataGrid里的数据列来自不同表,所以临时创建视图)
请求高手解答如何排序,另外如何在DataGrid首列加一个名次列?
------解决方案--------------------数据库的视图不可排序,但内存的dataview是可排序的.
如:
DataView dv = dt.DefaultView;
dv.Sort = "字段 "
this.DataGrid1.DataSoruce = dv;
------解决方案--------------------mysql = "select id as 编号,Name as 姓名,sex as 性别, address as 地址,tel as 电话,Email from student "
'排序
Select Case viewstate( "Sort ")
Case "编号 "
mysql = mysql & " order by ID "
Case "姓名 "
mysql = mysql & " order by Name "
Case "性别 "
mysql = mysql & " order by sex "
Case "地址 "
mysql = mysql & " order by address "
Case "电话 "
mysql = mysql & " order by tel "
Case "Email "
mysql = mysql & " order by Email "
End Select
mysql = mysql & viewstate( "OrderBy ")
-------------
用SQL比较简单