I have a C# (.NET - 3.5 Framework) gridview that does EVERYTHING I want, almost ...
I cannot for the life of me figure out how to set the focus to the Next row after a user updates/cancels an update on a row. It just goes back to the top of the gridview... very frustrating.
I can set the focus to the correct line when I edit the gridview (but it shows up at the very bottom of the page). I would like to know how to make it so that the line I am editing in my gridview shows as the first Line in the gridview.
Here is my code to set the focus when editing (qtyOct is an asp:TextBox in an editItemTemplate within the gridview (this works perfectly):
but the same code construct does not work when I try to set the focus after updating the gridview (see attached code) it does not set the focus to the row immediately after the row just updated, it just goes back to the top of the gridview:
In Summary: 2 Questions (which are practially identical):
How can I set the line I am editing to the top of the gridview?
How can I set the line I have just editied to the top of the gridview?
Any help would be greatly appreciated!! Gotta get this into production tonight and this is not crucial, but one could say neither is having dignity ;-)
Thanks one and all!
protected void gridProg_OnRowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
int NextRow = e.RowIndex; //Go to the next row after canceling the update
gridProg.EditIndex = -1;
//The following line "should" set the focus to the next line in the gridview -- Instead the gridview loads to the top of the page.