Retain datagrid scroll position after postback
Thursday 05 October 2006
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()
|
(0)
|
|
|