Akhter HUssain

Akhter HUssain

  • 713
  • 1.3k
  • 103.2k

How to delete row from gridvew ,as using session?

Aug 22 2019 12:47 PM
I am trying to delete row from gridview using session,not from database,i have two page on  first page i have datalist and second page have gridview ,i am passing data from datalist to anpother page gridview,
Now i want to delete row from gridview ,for storing data in gridview i am using session,i have used row deleting event but row is not getting deleted...please help me out...
 
  1. protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)  
  2.    {  
  3.        int index = Convert.ToInt32(e.RowIndex);  
  4.        DataTable dt = (DataTable)Session["buyitems"];  
  5.        dt.Rows[index].Delete();  
  6.        Session["buyitems"] = dt;  
  7.        GridView1.DataSource = dt;  
  8.        GridView1.DataBind();  
  9.    }  
On Page load 
 
  1. protected void Page_Load(object sender, EventArgs e)  
  2.  {  
  3.      DataTable dt;  
  4.      dt = (DataTable)Session["buyitems"];  
  5.      GridView1.DataSource = dt;  
  6.      GridView1.DataBind();  
  7.   
  8.  }  
 

Answers (2)