passing an ID between pages
<p>I have a <code>Default.aspx</code> page in which I have bind a Grid.  In the Grid is a button named Details. </p>

<p>I also have a <code>Details.aspx</code> which has a GridView. If I click the button that exist in Default.aspx, there appears an <code>Details.aspx</code> page which appears empty. </p>

<p>When click the Detail button of a specific row, there appears the details of that button clicked. I am not understanding on how to pass the ID to <code>Details.aspx</code>. </p>

<p>Can anybody guide me to this please?</p>

<p><strong>Details.aspx</strong></p>

<pre><code>&lt;asp:GridView ID="DetailsGridView" runat="server" BackColor="White" AutoGenerateColumns="false" 
            BorderColor="#DEDFDE" BorderStyle="None" BorderWidth="1px" CellPadding="4" DataKeyNames="ID"
            ForeColor="Black" GridLines="Vertical"&gt;
          &lt;FooterStyle BackColor="#CCCC99" /&gt;
        &lt;PagerStyle BackColor="#F7F7DE" ForeColor="Black" HorizontalAlign="Right" /&gt;
        &lt;SelectedRowStyle BackColor="#CE5D5A" Font-Bold="True" ForeColor="White" /&gt;
        &lt;HeaderStyle BackColor="#6B696B" Font-Bold="True" ForeColor="White" /&gt;
        &lt;AlternatingRowStyle BackColor="White" /&gt;
        &lt;/asp:GridView&gt;
</code></pre>

<p><strong>Default.aspx:</strong> 
    
            
                </p>

<pre><code>            &lt;Columns&gt;
                &lt;asp:BoundField HeaderText="First Name" DataField="FirstName" /&gt;
                &lt;asp:BoundField HeaderText="Last Name" DataField = "LastName" /&gt;
                &lt;asp:BoundField HeaderText="HomePhoneNumber" DataField="HomePhoneNumber" /&gt;
                &lt;asp:TemplateField HeaderText="ViewDetails"&gt;
                &lt;ItemTemplate&gt;
                &lt;asp:Button ID="Deatils" runat="server" Text="Details" /&gt;
                &lt;/ItemTemplate&gt;    

                &lt;/asp:TemplateField&gt;

                &lt;asp:TemplateField HeaderText="Actions"&gt;
                &lt;ItemTemplate&gt;
                &lt;asp:Button ID="Modify" runat="server" Text="Modify" /&gt;
                &lt;asp:Button ID="Delete" runat="server" Text="Delete" /&gt;

                &lt;/ItemTemplate&gt;
                &lt;/asp:TemplateField&gt;                   
            &lt;/Columns&gt;


            &lt;FooterStyle BackColor="#CCCC99" /&gt;
            &lt;PagerStyle BackColor="#F7F7DE" ForeColor="Black" HorizontalAlign="Right" /&gt;
            &lt;SelectedRowStyle BackColor="#CE5D5A" Font-Bold="True" ForeColor="White" /&gt;
            &lt;HeaderStyle BackColor="#6B696B" Font-Bold="True" ForeColor="White" /&gt;
            &lt;AlternatingRowStyle BackColor="White" /&gt;
        &lt;/asp:GridView&gt;
    &lt;/div&gt;
</code></pre>

<p><strong>JavaScript</strong></p>

<pre><code>&lt;script type="text/javascript"&gt;
function viewProfile(index)
{
        var GridID = document.getElementById("PersonGridView");
        var row=GridID.rows[parseInt(index)+1];
        window.open('Details.aspx?coaid'+row);
}
&lt;/script&gt;
</code></pre>

<p><strong>Code Behind of Default.aspx:</strong></p>

<pre><code>protected void PersonGridView_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                var DataKeys = PersonGridView.DataKeys[e.Row.RowIndex];
                DataKeys.Value.ToString();
                var ID = DataKeys["ID"].ToString();
                Button btnDetails = (Button)e.Row.FindControl("Deatils");
                Button btnModify = (Button)e.Row.FindControl("Modify");
                Button btnDelete = (Button)e.Row.FindControl("Delete");
                btnModify.CommandName = "Modify";
                btnDelete.CommandName = "Delete";
                btnDetails.CommandName = "Deatils";
                btnDelete.CommandArgument = btnModify.CommandArgument = btnDetails.CommandArgument = string.Format("{0}", ID);
                btnDetails.Attributes["onclick"] = string.Format("viewProfile({0}); return false;", e.Row.RowIndex);
            }
        }
</code></pre>
