GridView-SortExpression [英] GridView - SortExpression

查看:142
本文介绍了GridView-SortExpression的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Grid View的所有列中都使用了SortExpression.当我对任何列进行排序并进行编辑时,页面将得到回发(在我的情况下需要回发),并在排序之前向我显示选择用于编辑的旧值.回发后不保留排序.我认为在回发后保持排序将很有用,但我不明白.
请帮助我该怎么做,或者如果您有其他新方法可以使用.

I have used SortExpression in all of my columns in Grid View. When I Sort any of the column and than do edit of the column ,the page gets Postback(It needs to be postback in my case)and It displays me the old value selected for editing, before Sorting. Sorting is not maintained after PostBack. I think that to maintain Sorting after Postback will be helpful but I am not getting it.
Please help me how to do that or if you have any new way to do.

推荐答案

您必须将sortexpression存储在本地,以便每当有回发时,您都可以-应用相同.

试试:
You have to store the sortexpression locally such that whenever there is postback you can re-apply the same.

Try:
public string SortExpression {
    get {
        if (ViewState("SortExpression") == null) {
            ViewState("SortExpression") = "LastName ASC";
        }
        return ViewState("SortExpression").ToString;
    }
    set { ViewState("SortExpression") = value; }
}


每次加载/填充gridview时都应用此SortExpression.


Apply this SortExpression every time you load/populate your gridview.


这篇关于GridView-SortExpression的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆