Click here to Skip to main content
15,949,686 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Friends,
I have bind one Gridview Using datatable that is stored in session...Now i added one button(for delete) in grid view using Tempalte Field...now i want to do delete Operation on current Row and aftervdeletion I want to bind gridview again...

Important Note Here am using Templare field for button...
Posted

http://www.dotnetfunda.com/articles/article29.aspx[^]

here you will get required info.
 
Share this answer
 
you can try this way

XML
<asp:TemplateField>
                   <ItemTemplate>
                       <asp:Button ID="btnDelete" runat="server" Text="Delete" CommandName="Delete"/>
                   </ItemTemplate>
               </asp:TemplateField>



protected void grvTest_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Delete")
{
GridViewRow row = (GridViewRow)((Button)e.CommandSource).NamingContainer;

DataTable dt = (DataTable)Session["CurrentTable"];

dt.Rows.Remove(dt.Rows[row.RowIndex]);
grvTest.DataSource = dt;
grvTest.DataBind();
}
}
 
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