I am developing an asp.net website I have created a template with gridview and I put a button in the template and I want to browse to another page by clicking on the button by Row ID .I need your help
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="ID" DataSourceID="SqlDataSource2" CellPadding="4" ForeColor="#333333" GridLines="None" Width="100%" OnRowCommand="GridView1_RowCommand" >
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:TemplateField>
<AlternatingItemTemplate>
<table class="nav-justified">
<tr>
<td class="auto-style5" dir="rtl" style="text-align: justify; vertical-align: top">
<asp:Image ID="Image7" runat="server" ImageUrl='<%# "~/images/"+(string)Eval("img") %>' Width="150px" />
</td>
<td class="auto-style6" dir="rtl" style="text-align: justify; vertical-align: top"> </td>
<td dir="rtl" style="text-align: justify; vertical-align: top">
<table class="nav-justified">
<tr>
<td>
<asp:Label ID="Label1" runat="server" Text='<%# (string)Eval("onvan") %>'></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label2" runat="server" Text='<%# Eval("comment").ToString().Length<=100?Eval("comment"):Eval("comment").ToString().Substring(0,100) %>'></asp:Label>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="auto-style5"> </td>
<td class="auto-style6"> </td>
<td dir="rtl" style="vertical-align: top; text-align: justify">
<asp:Label ID="Label3" runat="server" Text='<%# Eval("datetime") %>'></asp:Label>
</td>
</tr>
<tr>
<td class="auto-style5">
<asp:Button ID="Button1" runat="server" CssClass="btn" Text="Button" />
</td>
<td class="auto-style6"> </td>
<td> </td>
</tr>
</table>
</AlternatingItemTemplate>
<ItemTemplate>
<table class="nav-justified">
<tr>
<td class="auto-style3" dir="rtl" style="text-align: justify; vertical-align: top">
<asp:Image ID="Image8" runat="server" ImageUrl='<%# "~/images/"+(string)Eval("img") %>' Width="150px" />
</td>
<td class="auto-style4" dir="rtl" style="text-align: justify; vertical-align: top">
</td>
<td dir="rtl" style="text-align: justify; vertical-align: top">
<table class="nav-justified">
<tr>
<td>
<asp:Label ID="Label5" runat="server" Text='<%# (string)Eval("onvan") %>'></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label6" runat="server" Text='<%# Eval("comment").ToString().Length<=100?Eval("comment"):Eval("comment").ToString().Substring(0,100) %>'></asp:Label>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="auto-style3"> </td>
<td class="auto-style4"> </td>
<td dir="rtl" style="vertical-align: top; text-align: justify">
<asp:Label ID="Label4" runat="server" Text='<%# Eval("datetime") %>'></asp:Label>
</td>
</tr>
<tr>
<td class="auto-style3">
<asp:Button ID="Button2" runat="server" CommandArgument="<%# ((GridViewRow) Container).RowIndex%>" CommandName="nav" Text="Browse" CssClass="btn" />
</td>
<td class="auto-style4"> </td>
<td> </td>
</tr>
</table>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<EditRowStyle BackColor="#7C6F57" />
<FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#E3EAEB" />
<SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#F8FAFA" />
<SortedAscendingHeaderStyle BackColor="#246B61" />
<SortedDescendingCellStyle BackColor="#D4DFE1" />
<SortedDescendingHeaderStyle BackColor="#15524A" />
</asp:GridView>
--> Add OnRowDataBound Method in GridView.
--> And Code in Your C# Page.
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "ID")) > 0)
{
Response.Redirect(Link);
}