Try it like this .... Don't Define Click Event Button .... Define Button Like It ...
<asp:ImageButton ID="imgEditApp" runat="server" ImageUrl="~/Images/AppSetup/Action-edit-icon.png" Height="18px" ToolTip="Edit Application" CssClass="grdImageAlign" CommandName="Edit"/>
A Define the GridView RowEditing event Like this ....
protected void gv_RowEditing(object sender, GridViewEditEventArgs e) { Response.Redirect("/Secured/EditApplication.aspx?AppID="+YourGridViewId.Rows[e.NewEditIndex].Cells[1].Text); }
Edit: I think you have a problem in a specific RowEditingEvent ..... ok, you can do it ... nothing to change just write this code in you Click event ...
protected void btnEdit_Click(object sender, EventArgs e) { ImageButton ib = sender as ImageButton; GridViewRow row = ib.NamingContainer as GridViewRow; Response.Redirect("/Secured/EditApplication.aspx?AppID="+YourGridViewId.Rows[row.RowIndex].Cells[1].Text); }
Edit 2
<asp:ImageButton ID="imgEditApp" runat="server" ImageUrl="~/Images/AppSetup/Action-edit-icon.png" Height="18px" ToolTip="Edit Application" CssClass="grdImageAlign" CommandName="Edit" CommandArgument='<%#Eval("AppID") %>'/> protected void btnEdit_Click(object sender, EventArgs e) { string appid= (sender as ImageButton).CommandArgument; Response.Redirect("/Secured/EditApplication.aspx?AppID="+appid }
source share