I didnt realize that in .NET 2.0 you could do this with
MaintainScrollPositionOnPostback="true" in the page declaration.
However, this is not supported in 1.x ( dont know if you are using this )
but if you are one approach that I have used ( and there may be more ).
1.) Add a column to your datagrid
2.) In the ItemDataBount Event ( which fired for each row bound to the
grid ) add the an HTML acnchor tag with the number associated with the row
being added.
If e.Item.ItemType <> ListItemType.Footer And e.Item.ItemType <>
ListItemType.Header Then
Dim anchor As New LiteralControl
anchor.Text = "<a name=""" + e.Item.ItemIndex.ToString + """>"
e.Item.Cells(e.Item.Cells.Count - 'YourColumnNumber' ).Controls.Add(anchor)
End If
3.) On Postback when you edit a row, you should intercept the Update event
and call this
bookmarkIndex = e.Item.ItemIndex '// bookmark is a class level integer
InsertScriptBlock
// Sub Further down
Private Sub InsertScriptBlock()
Dim jScript As New System.Text.StringBuilder
jScript.Append("<script language=""JavaScript"">")
jScript.Append("location.href=""#")
jScript.Append(bookmarkIndex.ToString())
jScript.Append(""";")
jScript.Append("</script>")
RegisterClientScriptBlock("Bookmark", jScript.ToString())
End Sub