Everything is located inside an UpdatePanel with updatemode='always'. The GridView and ObjectDataSource support and use paging. Paging works without any problems. The problem is editing. When I click edit on the first page, everything works as expected. When I click edit on the n-th item on the second or other page (greater than one), the GridView switches to the first page and selected the n-th item for editing.
(More concerete example: I switch to the second page, I select the item number 2 on that page to be edited, the GridView switches to the first page and selects the item number 2 (on the first page) to be edited).
this is my code behind
Private Sub gd_RowEditing(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles gd.RowEditing
gd.EditIndex = e.NewEditIndex
BindGrid()
End Sub
Private Sub gd_PageIndexChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewPageEventArgs) Handles gd.PageIndexChanging
gd.PageIndex = e.NewPageIndex
gd.EditIndex = -1
BindGrid()
End Sub
Private Sub gd_RowUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles gd.RowUpdating
Dim i As Integer
Try
i = e.RowIndex
Dim data As DataKey
data = gd.DataKeys(e.RowIndex)
gd.EditIndex = -1
BindGrid()
Catch ex As Exception
msg(Me, ex.Message)
End Try
End Sub
Private Sub gd_RowCancelingEdit(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCancelEditEventArgs) Handles gd.RowCancelingEdit
gd.EditIndex = -1
BindGrid()
End Sub