Retain datagrid scroll position after postback



Retain datagrid scroll position after postback To retain the scroll position of a datagrid / datalist after a postback is suprisingly simple, you simply add the below line of text to your code before you bind your results to the datagrid / datalist:
Page.SmartNavigation = true
An example of this is:
Dim MyConnection As SQLConnection
MyConnection = New SQLConnection(ConfigurationSettings.AppSettings("ConnectionString"))
 
Dim sql As String
sql="SELECT * FROM table"
 
Dim resultsDataSet as New DataSet()
Dim myDataAdapter as SqlDataAdapter = New SqlDataAdapter(sql, myConnection)

myDataAdapter.Fill(resultsDataSet)
 
Page.SmartNavigation = true
 
DataGrid1.DataSource = resultsDataSet
DataGrid1.DataBind()


Send a link to this page via email Send a link to this page via email