Click here to Skip to main content
15,868,004 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a Webform in ASP.Net, In this I used DropDownList,TextBox I am Entering some data into this and Using Add Button, Every Added records display in gridView(Not Connected to DataBase), Suppose if their is some mistake in any column while Adding records I want to delete that particular rows only. So could any body will help me to sort out of this problem, what kind of code i have to used, can anybody provide me the code. Thanks in Advance.......

I have used Some code shown below But Sometimes it delete two rows (2nd last and last rows) and some times only one rows...



DataTable dt = (DataTable)Session["additems"];
       if (dt.Rows.Count > 0)
       {
           dt.Rows.RemoveAt(e.RowIndex);
       }
       Session["additems"] = dt;
       bindGrid();
Posted
Updated 21-Mar-12 19:47pm
v2

1 solution

C#
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
 {
     dt = (DataTable)ViewState["dt"];
     dt.Rows[e.RowIndex].Delete();
     GridView1.DataSource = dt;
     GridView1.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