How can I prevent the LinqDataSource Where clause from resetting on postback?

核能气质少年 提交于 2019-12-05 19:18:46
justin.lovell

Perhaps you just add a ViewState property into your page/user control and then retrieve it on all post back?

public string MyLinqSourceWhere 
{
    get { return (string)this.ViewState["MyLinqSourceWhere"]; }
    set { this.ViewState["MyLinqSourceWhere"] = value; }
}

public void Page_Load(object sender, EventArgs e) 
{
    this.myLinqSource.Where = this.MyLinqSourceWhere;
}

public void Button1_Click(object sender, EventArgs e) 
{
    this.MyLinqSourceWhere = " .... ";
    this.myLinqSource.Where = this.MyLinqSourceWhere;
}

If that doesn't work, then perhaps bind on the LinqDataSource.Selecting event the fetch property from the viewstate to your where clause?? It all depends

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!