grid view delete and edit
i am using image button for edit and delete as item template and i give command name as edit, delete.. but my delete and edit operation not performed please help me
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
kalu singh raoPosted Aug 2, 2016, 1:41 AM
Santosh SasupalliPosted Aug 2, 2016, 1:53 AM
BorderStyle="None" AutoGenerateEditButton="false" AutoGenerateDeleteButton="false" BorderWidth="2px" CellPadding="3" CellSpacing="2" AutoGenerateColumns="true" AlternatingRowStyle-Font-Italic="true"
Font-Names="Verdana" Font-Size="Small" AlternatingRowStyle-BackColor="Yellow" OnRowDeleting="edituser_RowDeleting" OnRowEditing="edituser_RowEditing">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:ImageButton ID="edit" runat="server" CommandName="Edit" CommandArgument='<%# Eval("uid") %>' text="edit" ImageUrl="content/images/file_edit.ico" ToolTip="Edit" Height="20px" Width="20px" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:ImageButton ID="delete" runat="server" CommandName="Delete" CommandArgument='<%# Eval("uid") %>' text="delete" ImageUrl="content/images/Delete_Icon.jpg" ToolTip="Delete" Height="20px" Width="20px" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
{
formvalue = Convert.ToInt32(edituser.DataKeys[e.NewEditIndex].Values["uid"].ToString());
Response.Redirect("user_edit.aspx");
}
protected void edituser_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
int i = Convert.ToInt32(edituser.DataKeys[e.RowIndex].Values["uid"].ToString());
usertable.deleteuser(i);
Response.Redirect("editusers.aspx");
}
protected void edituser_RowDataBound(object sender, GridViewRowEventArgs e)
{
e.Row.Cells[2].Visible = false;
if (e.Row.RowType == DataControlRowType.DataRow)
{
string item = e.Row.Cells[3].Text;
ImageButton imgbtn = (ImageButton)e.Row.Cells[1].FindControl("delete");
if (imgbtn.CommandName == "Delete")
{
imgbtn.Attributes["onclick"] = "if(!confirm('Do you want to delete " + item + "?')){ return false;};";
}
}
}
Santosh SasupalliPosted Aug 2, 2016, 1:47 AM
Midhun TpPosted Aug 2, 2016, 1:33 AM