Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I apply FilterExpression values but when I want to change page the filter is cleared.
What can I do to avoid this?

I set filter this way:
SqlDataSource1.FilterExpression = "type= 10";  


The GridView is in
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
   <contenttemplate>
        MyGridView.
   </contenttemplate>

Thank you.

[edit]Code block added, "Ignore HTML..." option disabled - OriginalGriff[/edit]
Posted
Updated 13-Jul-11 4:25am
v2

1 solution

I do this Workaround and works:

on click event after:
C#
{
   .....
   SqlDataSource1.FilterExpression = "some expression";
   ViewState.Add("filter", SqlDataSource1.FilterExpression);
 }
Page_Load {
    if (Page.IsPostBack) {
        if (ViewState["filter"] != null) {
            SqlDataSource1.FilterExpression = ViewState["filter"].ToString();
        }
    }
}
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900