一个有关GridView中排序的问题
if (ViewState[ "Order "] == null)
{
ViewState[ "Order "] = "DESC ";
}
else
{
ViewState[ "Order "] = (ViewState[ "Order "].ToString() == "DESC ") ? "ASC " : "DESC ";
}
DataTable tbSPY = new DataTable();
tbSPY = TRNSPY.QrySPY().Copy();
DataSet ds = new DataSet();
ds = tbSPY.Copy();//这里有错他说不能隐式的把DataTable转换Dataset
ds.Tables[ "PBESPY "].DefaultView.Sort = e.SortExpression + " " + ViewState[ "Order "].ToString();
gvSpyList.DataSource = ds.Tables[ "PBESPY "].DefaultView;
gvSpyList.DataBind();
其实我是不知道DataTable里面有什么方法可以实现,所以才想要转换的,希望高手帮下忙。
------解决方案--------------------不用转换 直接用datatable
tbSPY.DefaultView.Sort 就应该可以啊 有什么问题么?
------解决方案--------------------DataSet ds = new DataSet();
ds.Tables.Add(tbSPY.Copy());//这里有错他说不能隐式的把DataTable转换Dataset
------解决方案--------------------DataSet ds = new DataSet();
ds.Tables.Add(tbSPY.Copy());
------解决方案--------------------// 做了一堆无用功
> > >
DataTable tbSPY = TRNSPY.QrySPY()
DataView dv = tbSPY.DefaultView;
dv.Sort = e.SortExpression + " " + ViewState[ "Order "].ToString();
gvSpyList.DataSource = dv;
gvSpyList.DataBind();