Click here to Skip to main content
15,891,757 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to delete a record from gridview when particular row has been checked using checkbox in that gridview?
Posted

You can simply use GridView RowCommand and CommandArgument for the same.
Try out like this,
<asp:templatefield xmlns:asp="#unknown">
              <headertemplate>
                Delete
              </headertemplate>
              <itemtemplate>
                  <asp:imagebutton commandname="DeleteCommand" commandargument="<%# Eval(" id=" )%>" imageurl="/test.pmg">
                        ID="lnk" runat="server" />
              </asp:imagebutton></itemtemplate>
          </asp:templatefield>


and in codebehind
Protected Void Grid_RowCommand(object sender, GridViewEventArgs e)
{
 if(e.CommandName=="DeleteCommand") 
    {
 CheckBox cb= (CheckBox)e.Row.findControl("chkbox");
if(cb.Checked)      
     {
      DeletedRecord(e.CommandArgument);
     }
    }
}


Please check for the syntax.
 
Share this answer
 
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900