您也可以使用當前所選記錄(您想要在詳細信息頁面上顯示的那個記錄)的ID的QueryString參數來代替使用會話。將它傳遞迴GridView-Page並添加功能以在網格中找到它並相應地設置PageIndex。
事情是這樣的:
Dim dr As DataRow = MyDataTble.Rows.Find(Request.QueryString("ID"))
Dim selectedIndex As Int32 = Me.GridView1.Find(dr.MySortColumn)
Dim pageIndexofSelectedRow As Int32 = CInt(Math.Floor(selectedIndex/Me.GridView1.PageSize))
If pageIndexofSelectedRow < 0 Then
Me.GridView1.PageIndex = 0
Me.GridView1.SelectedIndex = -1
Else
Me.GridView1.PageIndex = pageIndexofSelectedRow
Me.GridView1.SelectedIndex = selectedIndex Mod Me.GridView1.PageSize
End If
設置** **的PageIndex網格的,你可以選擇通過會話或查詢字符串傳遞 – V4Vendetta 2011-03-14 08:45:46