I have a button inside gridview and i am trying to redirect it to a page. The following is my code for the template view.
<asp:TemplateField ShowHeader="False">
<ItemTemplate>
<asp:Button ID="btnView" runat="server" CausesValidation="false" OnClick="btnView_Click" Text="View" Font-Size="Small"></asp:Button>
</ItemTemplate>
</asp:TemplateField>
I tried the following solution for the OnClick.
protected void btnView_Click(object sender, EventArgs e)
{
Button btn = (Button)sender;
GridViewRow row = (GridViewRow)btn.NamingContainer;
Response.Redirect("Customer.aspx" );
}
My code isn't working fro some reason and the button doesn't redirect. I looked at other solutions as well but I they are not working for me. Can someone please let me know what I am missing here. Thank you.