Delete records from Gridview


In the last post, I have implemented the cods how you can add the records to gridview using ViewState, DataTable and DataRow. Now, I am trying to delete the records one by one which I added at last.

At first, make "true" delete button of the gridview and write the code in the "RowDeleting" event
(this code 100% work)

protected void gdView_RowDeleting(object sender, GridViewDeleteEventArgs e)

        {

            if (ViewState["GrdData"] != null)

            {

                dt = ViewState["GrdData"] as DataTable;

                dt.Rows.RemoveAt(e.RowIndex);

                gdView.DataSource = dt;

                gdView.DataBind();

                ViewState["GrdData"] = dt;

            }

        }
If you have doubts, watch my video, to make sure the cods here is the link 
http://youtu.be/xt_vz3Lp5Mc



Enjoy this....!
Happy coding.....!

No comments:

Post a Comment