<asp:ImageButton ID="ImgBtnDelete" runat="server"
ImageUrl="~/Images/delete.jpg" Height="20px" Width="20px" onclick="ImgBtnDelete_Click"
ImageAlign="AbsMiddle" OnClientClick="javascript:return confirm('Are you sure you want to permanently delete this item? This action cannot be reversed.')" />
protected void ImgBtnDelete_Click(object sender, ImageClickEventArgs e)
{
ImageButton ibtn1 = sender as ImageButton;
int rowIndex = Convert.ToInt32(ibtn1.Attributes["RowIndex"]);
DataTable Dt = (DataTable) ViewState ["CurrentTable"] ;
DataRow DrCurrentRow = null;
int RowIndex = Convert.ToInt32(rowIndex);
if (Dt.Rows.Count > 1)
{
Dt.Rows.Remove(Dt.Rows[RowIndex]);
DrCurrentRow = Dt.NewRow();
ViewState["CurrentTable"] = Dt;
GridView1.DataSource = Dt;
GridView1.DataBind();
for (int i = 0; i < GridView1.Rows.Count - 1; i++)
{
GridView1.Rows[i].Cells[0].Text = Convert.ToString(i + 1);
}
}
}