tags:

views:

65

answers:

2

In my project I am using a session table. I am binding this session table to the gridview, in gridview row updating event. I keep the records of session table to a datatable and I use the code below code for updating:

dttable.rows(e.rowindex)("name")="arun"
dttable.Acceptchanges()

My problem is when using PageIndexChanging, I can edit in the 1st page of GridView without any problem, but in second page it is editing the one corresponding to e.RowIndex in the first page, so no change occurs other than the first page in the gridview.

Please help.

A: 

Your problem is to update your datasource with the index that came from the current page.

dttable.rows(e.rowindex)("name")="arun"

Change the line above with this one :

dttable.Select("YourTableID = " + yourGridView.DataKeys(e.rowindex).Value)(0)("name")="arun"

As a summary, just get the DataKey from grid view and select the related row from your datasource with this key and update it.

Canavar
A: 

You need to accound for which page you are on and not just the row unmber. it's an array so you have to give it the index that corresponds to the entire array.

dttable.rows(e.rowindex + (mygridcontrol.currentpageindex * mygridcontrol.pagesize))("name")="arun"
dttable.Acceptchanges()
Middletone