Click here to Skip to main content
15,867,594 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Posted
Comments
joe_j 13-Feb-13 3:35am    
Try setting the EnableViewState = True
And not sure if you would require the gd_PageIndexChanging event

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