How can I prevent the LinqDataSource Where clause from being reset after returning?

I am trying to set the where clause in a LinqDataSource object related to the GridView programmatically with a click of a button, but when the GridView cross-checks the data (for example, when the user sorts) the Where clause is dumped back to the empty string, is there a way to prevent this, or is there a better way to filter my results?

+3
source share
1 answer

Perhaps you just added the ViewState property to your page / user control and then bring it back in all posts 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;
}

, , , LinqDataSource.Selecting fetch viewstate where??

+3

Source: https://habr.com/ru/post/1728358/


All Articles