Updating Disconnected DataSets with GridView

  • Thread starter Thread starter ist
  • Start date Start date
I

ist

Hi,
I am trying to create a Session-Wide, Disconnected, Updatable
DataTable (or DataSet) object and use it through an ASP.NET GridView.

The scenario is this:

1. When the page is first loaded, connect to DB, get data, fill
DataTable.
2. Bind DataTable to GridView. Set DataTable as a Session object.
3. User continues navigating page, but after first load, no more DB
connection is made, grid is filled from DataTable Session object.
4. Sometime, user sets GridView to edit mode and makes some changes.
Then he clicks Update button on GridView.

This is where I fail. I somehow imagine that there must be a way to
reflect user's change on Gridview to DataTable Session object (NOT to
actual DB)

So when user continues navigating page, he will see updated data
(since DataTable is Session-wide) however the actual DB is not
updated.

I've tried triggering GridView1.UpdateRow(e.RowIndex, false) on
GridView1_RowUpdating event but it gives me stack overflow (huh?)
error.

Thanks...
 
I've tried triggering GridView1.UpdateRow(e.RowIndex, false) on
GridView1_RowUpdating event but it gives me stack overflow (huh?)
error.

It is supposed to overflow because of recursive callback (UpdateRow
itself raises RowUpdating event, from where it is getting called
again).

In any case GridView's automatic row update is intended for
DataSourceControl (i.e. the one set by by DataSourceID instead of
DataSource). Your best bet is probably to manually update the table
stored in Session state in RowUpdating or RowCommand event.
 
Back
Top