0

I am having one gridview on my web application....
It all working fine but not getting the result i want...


I have also used Edit and Delete Link as shoun in image 1....
When i click Edit button, then it can be edited... but when i click update the data gets updated easly... and also actual database gets updated....


I want the gridview should only get updated and not actual database.....
please help....

Attachments image1.jpg 6.84 KB
3
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by dnanetwork
0

Hi,

1. On page load, Fill a DataTable with records retrieved from Database.
2. Store the DataTable in Session. Also bind the DataTable to the GridView.
3. In the Edit/Update events, Get the DatatTable from Session, Update/Edit the appropriate record in the DataTable, Store it in Session again, Re-bind the DataTable to GridView.

You can finally update the DataTable with database. After saving, clear the session variable which is used for storing it.

It is not advisable to store a large DataTable in Session.

0

I am not getting ...
if you have any example please attach here....

0

I have done upto this whats next...
please help...

SqlConnection conn = new SqlConnection("Data Source=XXX-578AC20261\\SQLEXPRESS;Initial Catalog=TT;Integrated Security=True");
        SqlCommand cmd = new SqlCommand("SELECT * FROM Cust", conn);
        cmd.CommandType = CommandType.Text;
        SqlDataAdapter da = new SqlDataAdapter();
        da.SelectCommand = cmd;
        DataTable dt = new DataTable();
        da.Fill(dt);
        
Session["MyDataTable"] = dt;
        
        // To retrieve it from session
        dt = (DataTable)Session["MyDataTable"];

Edited by vishalrane: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.