我在网页上有这个代码,请看看:
var d = from p in db.Questions
where p.CatId == Convert.ToInt32(s)
select p;
DataTable datatable =d as DataTable;
DataView dataview = new DataView(datatable);
dataview.Sort ="id DESC" ;
GridView1.DataSource =dataview;
GridView1.DataBind();
我在“问题”表中有一个名为“id”的列,我想在pageload上对gridview进行排序。 编译期间出现以下错误:
请帮助。
答案 0 :(得分:0)
var d = from p in db.Questions
orderby p.Dtime descending
where p.CatId == Convert.ToInt32(s)
select p;
DataTable datatable =d as DataTable;
DataView dataview = new DataView(datatable);
dataview.Sort ="id DESC" ;
GridView1.DataSource =dataview;
GridView1.DataBind();