rcl58
asked on
Gridview RowEditing Can't FindControl
When entering Edit mode on my GridView I place the focus on a field with the FindControl method. All is well, but if I move to page #2 my code crashes, (ArgumentOutOfRangeExcepti on).
What am I doing wrong??
What am I doing wrong??
Private Sub gv_Gifts_RowEditing(sender As Object, e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles gv_Gifts.RowEditing
If gv_Gifts.EditIndex = e.NewEditIndex Then
e.Cancel = True
Exit Sub
End If
gv_Gifts.EditIndex = e.NewEditIndex
LoadOffers()
gv_Gifts.Rows(e.NewEditIndex).FindControl("giftTitle").Focus()
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Oops, the accepted solution is not working , same problem.
After going to page 2 and entering edit on the first row
e.NewEditIndex = 10
.PageSize = 10
.PageIndex = 1
Suggestion "correctIndex = e.NewEditIndex + (GridView1.PageSize * GridView1.PageIndex)" result in a value of 20.
Also the binding code change suggestion didn't help:
gv_Gifts.EditIndex = e.NewEditIndex
gv_Gifts.DatBind()
I'm still lost and may have to repost because I already accepted the solution.
After going to page 2 and entering edit on the first row
e.NewEditIndex = 10
.PageSize = 10
.PageIndex = 1
Suggestion "correctIndex = e.NewEditIndex + (GridView1.PageSize * GridView1.PageIndex)" result in a value of 20.
Also the binding code change suggestion didn't help:
gv_Gifts.EditIndex = e.NewEditIndex
gv_Gifts.DatBind()
I'm still lost and may have to repost because I already accepted the solution.
is the gridview binding in markup? I f no, please post which event(s) are binding the gridview dynamically.
Can you post the exception details?
Also if you can post the contents of gv_Gifts.Rows before the exception is thrown. I am interested in the count property whether Rows(0) is the actual first row or is the 11 row.
NOte: 1) IF you can include before/after values of my suggested code changes will be great.
2) No need to ask a new question, just request the moderator to reopen the question.
Can you post the exception details?
Also if you can post the contents of gv_Gifts.Rows before the exception is thrown. I am interested in the count property whether Rows(0) is the actual first row or is the 11 row.
NOte: 1) IF you can include before/after values of my suggested code changes will be great.
2) No need to ask a new question, just request the moderator to reopen the question.
ASKER
Note: This problem is continuted here:
https://www.experts-exchange.com/questions/28021945/Gridview-RowEditing-Can't-FindControl-V2.html
https://www.experts-exchange.com/questions/28021945/Gridview-RowEditing-Can't-FindControl-V2.html
gv_Gifts.EditIndex = e.NewEditIndex
gv_Gifts.DataBind()