checking if gridview has a selected item
<p>I have a grideview and 2 buttons. I need to only show the buttons when the gridview has a selected item. My code looks like this: </p>

<pre><code>protected void Page_Load(object sender, EventArgs e)
{
    btactivate.Visible = false;
    btdeactivate.Visible = false;
    //Show Activate and Deactivate Buttons only if an item in the gridview is selected
    if (GridView1.SelectedIndex != -1)
    {
        btactivate.Visible = true;
        btdeactivate.Visible = true;
    }
    else
    {
        btactivate.Visible = false;
        btdeactivate.Visible = false;
    }
}   
</code></pre>

<p>But the problem I have now is that only when I select the second time a item in the gridview the buttons show up. I need to have the the buttons show when I select the first time. I have tried changing the selected index to "-0" but that shows the buttons all the time (even when I dont have something selected). Can anyone please help?</p>
