I am retreiving data from one page to another page on which i used to gridview to hold data using session
Now i am trying to delete row using deleting event
row is not getting deleted.
here is my c# code
protected void Page_Load(object sender, EventArgs e)
{
DataTable dt;
dt = (DataTable)Session["buyitems"];
GridView1.DataSource = dt;
GridView1.DataBind();
}
Row delete event
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
int index = Convert.ToInt32(e.RowIndex);
DataTable dt = (DataTable)ViewState["buyitems"];
dt.Rows[index].Delete();
ViewState["buyitems"] = dt;
GridView1.DataSource = dt;
GridView1.DataBind();
}
please guide