Click here to Skip to main content
15,896,453 members
Please Sign up or sign in to vote.
1.86/5 (4 votes)
See more:
how to use update gridview data without using database in c#
Posted
Updated 6-Apr-18 16:03pm
v2

1 solution

First make a Data Table for your data. Then assign it to your Gridview . When ever you perform operation on Gridview assign gridview data to datatable and you can use it again.

DataTable dt = new DataTable();
        DataRow dr;
        dt.Columns.Add(new System.Data.DataColumn("BookName", typeof(String)));
        dt.Columns.Add(new System.Data.DataColumn("BookQty", typeof(String)));
        dt.Columns.Add(new System.Data.DataColumn("BookImg", typeof(String)));
    foreach (GridViewRow row in gvShoppingCart.Rows)
        {
            Image Bookimg = (Image)row.FindControl("BookImg");
            Label Booknames = (Label)row.FindControl("lblBookName");
            TextBox Bookqty = (TextBox)row.FindControl("TXTQty");
            Label TotalPrice = (Label)row.FindControl("LBLTotal");
            dr = dt.NewRow();
            dr[0] = Booknames.Text;
            dr[1] = Bookqty.Text;
            dr[2] = Bookimg.ImageUrl.ToString();
            dt.Rows.Add(dr);
        }

        Session["QtyTable"] = dt;
 
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