Gridview:捕获排序方向
我在更新面板中有一个启用排序的网格视图和一个事件处理程序,如下所示:
protected void MyGridSort(object sender, GridViewSortEventArgs e)
{
var TheDirection = (e.SortDirection).ToString();
var TheColumn = (e.SortExpression).ToString();
}
我在这些行之后放置了一个断点。每次我按下列标题时,我的变量 TheDirection 总是显示升序。
为什么它不能从升序切换到降序并返回?
谢谢。
I have a gridview in an updatepanel with sorting enabled and an event handler as follows:
protected void MyGridSort(object sender, GridViewSortEventArgs e)
{
var TheDirection = (e.SortDirection).ToString();
var TheColumn = (e.SortExpression).ToString();
}
I put a breakpoint just after these lines. Every time I press the column header, my variable TheDirection is always showing Ascending.
Why is it not toggling from ascending to descending and back?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我一直在阅读,当您手动向 gridview 提供数据源时,排序似乎会中断。不确定这是否是你的情况,但这对我有用......
希望它有帮助
I've been reading and the sorting seems to break when you are manually providing the gridview a datasource. Not sure if that is your case, but this works for me..
hope it helps
您可以将方向保留在 ViewState 或 Session 中。像这样(未经测试的代码):
You could keep the direction in the ViewState or the Session. Like this (Untested Code):