views:

48

answers:

3

I have 3 GridViews in my page.

Using the SelectedIndexChanged event I put GridView2 and GridView3 data in GridView1 but when I restart my application GridView1 data is still persisted in browser.

I used a session variable to store the data. How can I clear GridView1

A: 

Before restarting your application, you've got to clear out your sessions if that's how you're storing the data. Clearing these session variables will clear your gridview.

Inside of your page load, you can do this.

if(!IsPostBack)
{
  Session["mySessionVariable"] = null;
  //...do this for each session variable you need to clear.
}
Aaron
A: 

put a new dataset or null value in your session.

masoud ramezani
+1  A: 

You can try to clear the GridView1 itself every time you start the application:

protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                GridView1.DataSource = null;
                GridView1.DataBind();
            }

        }
Ricardo