How to prevent old data from displaying on form resubmit?
<p>I have a form where when the user clicks the compare button, depending on whether the compare mode is set to "Full" or "Partial", different code will execute and display data in a GridView. </p>

<p><img src="http://i.stack.imgur.com/rP2SM.jpg" alt="enter image description here"></p>

<p>This is set up in an if/else block. I have two GridViews, one displaying the results for a "partial" comparison and one for "full" comparison. Everything works fine, except when the user changes the compare mode and clicks the compare button again (i.e. without closing the window and rerunning the program), both GridViews display at once, even though they are bound to the DataTable in separate blocks (one in the if, the other in the else) and therefore <em>should never appear at the same time</em>.</p>

<p><img src="http://i.stack.imgur.com/qIVL8.jpg" alt=""> </p>

<p>I tried hiding the other gridview using <code>gridview1.Visible = false;</code> so that, for example, the gridview for full compare is invisible when the partial compare option is selected, and vice versa. This doesn't work - it makes both invisible so you don't see anything!</p>

<pre><code>protected void Run_Comparison(object sender, EventArgs e)
{
    DataTable dt = new DataTable();

    if (CompareMode.SelectedValue.Equals("Partial"))
    {
        gridview2.Visible = false; // trying to make full compare gridview invisible

        // populate dt and execute partial compare  

        gridview1.DataSource = dt;
        gridview1.DataBind();
    }
    else if (CompareMode.SelectedValue.Equals("Full"))
    {
        gridview1.Visible = false; // trying to make partial compare gridview invisible

        // populate dt and execute full compare  

        gridview2.DataSource = dt;
        gridview2.DataBind();
    }
}
</code></pre>

<p>I looked into postback and still am not sure how to handle this issue, or even what to title this question for that matter. Any ideas?</p>
