在Gridview ASP.Net中排序 [英] Sorting in Gridview ASP.Net
本文介绍了在Gridview ASP.Net中排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨朋友们,
DataView dv = ds.Tables [0] .DefaultView;
dv.Sort = ViewState [Sort ] .ToString();
或
ds.Tables [0] .DefaultView.Sort = ViewState [Sort]。ToString();
当我使用第一个命令gridview成功排序但是第二个命令gridview没有排序?
我做错了,如果代码错误?
Hi friends,
DataView dv = ds.Tables[0].DefaultView;
dv.Sort = ViewState["Sort"].ToString();
OR
ds.Tables[0].DefaultView.Sort=ViewState["Sort"].ToString();
when i use first command gridview successfully sorted but the second command the gridview not sorting?
Where i done a mistake, if the code is wrong?
推荐答案
你必须将你的代码置于加载事件....或者在页面加载中调用你的绑定函数...
GridView分页和排序 [ ^ ]
http://www.dotnetgallery.com /kb/resource12-How-to-implement-paging-and-sorting-in-aspnet-Gridview-control.aspx [ ^ ]
you must place your code in load event....or call your bind function in page load...
GridView Paging and Sorting[^]
http://www.dotnetgallery.com/kb/resource12-How-to-implement-paging-and-sorting-in-aspnet-Gridview-control.aspx[^]
删除!在回发中尝试一次:
Remove ! in postback and try once:
if (IsPostBack)
{
ViewState["Sort"] = Sort;
bind_gridView();
}
我得到了解决方案:)
ds.Tables [0 ] .DefaultView.Sort = ViewState [" Sort"]。ToString();
GridView1.DataSource = ds.Tables [0];
工作我....
感谢您的评论Deenuji
谢谢和问候,
Somasundharam Arjunan
I got the Solution :)
ds.Tables[0].DefaultView.Sort = ViewState["Sort"].ToString();
GridView1.DataSource = ds.Tables[0];
Its working me....
Thanks for your comment Deenuji
Thanks and Regards,
Somasundharam Arjunan
这篇关于在Gridview ASP.Net中排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文