Gridview_RowCommand getting executed after loading of pop up window
<p>I have a search screen where I am using a GridView, in GridView I have <code>&lt;asp:LinkButton&gt;</code> and in its command argument I am using value for that column and <code>(Container.DataItemIndex+1)</code> to find the row number of item on which I have clicked. In <code>Gridview_RowCommand</code> I am assigning these values in session variable so that they could be passed to pop up window.</p>

<p>Let's say my search screen has populated two rows, on click of first row it works fine and I can access session variables in pop up window; however when I click on 2nd row's linkbutton pop up window gets refreshed first and then <code>Gridview_RowCommand</code> gets executed later because of which I am not getting updated values in my session variables.</p>

<p>Below is my linkbutton in aspx page: Popup window which gets invoked on click of link button is an HTML page having two frames each containing on aspx page.</p>

<pre><code>&lt;Columns&gt;
    &lt;asp:TemplateField HeaderText="File Name" ItemStyle-HorizontalAlign="Center"&gt;
        &lt;ItemTemplate&gt;
            &lt;asp:LinkButton ID="btn"  runat="server" Text='&lt;%#Eval("Empid")%&gt;'
CommandName="Click" CommandArgument='&lt;%#Eval("Empid") + "," 
+ (Container.DataItemIndex+1)%&gt;' OnClientClick='&lt;%# Eval("Empid",
"window.open(\"abc.html\",null,\"location=0,status=0,toolbar=0
,menubar=0,resizable=1\",\"true\");")%&gt;'/&gt;
        &lt;/ItemTemplate&gt;  
&lt;/Columns&gt;
</code></pre>

<p>Below code is aspx.cs code where I am storing values of empid and Container.DataItemIndex+1 in session variables.</p>

<pre><code>protected void grdDisplayResult_RowCommand(object sender, GridViewCommandEventArgs e)
{
    switch (e.CommandName)
    {
        case "Click":
        {
            string[] arg = new string[1];
            arg = e.CommandArgument.ToString().Split(',');
            Session["Empid"] = arg[0];
            Session["RowNum"] = arg[1];
            break;
        }
        default:
            break;
    }
}
</code></pre>

<p>I also have a pop up window which gets popped up when user clicks on link button.</p>
