在我的程序里现在用Session保存了一个公有变量(ArrayList),
当page变化的时候,不断地保存新的东西在这个arraylist里面,
或者改变里面的内容。现在问题出现了,当用户按ie上的后退
时,Session里面的东西根本就不会改变。现在我需要的是返回
到某一page的时候,能把在这一page当时存在的Session值拿出
来。请问有什么方法呢?最好有例子,谢谢了!!!

解决方案 »

  1.   

    ViewStateb吧。ViewState一般怎么用呢?
      

  2.   

    把“Session”替换成“ViewState”就行了
      

  3.   

    Private Sub BindGrid(ByVal ArrayList As String)
            MyDataGrid.Visible = False
            Dim Array As New Com(Application("DSN")) '自定义的一个类
            Dim dvShowData As DataView
            dvShowData = Array.ShowCom(ArrayList, Session.SessionID) '通过存储过程显示数据
            MyDataGrid.DataSource = dvShowData        If Array.ErrCount > 0 Then
                Msg.ForeColor = Color.Red
                Msg.Text = Array.ErrMsg
                Exit Sub
            End If        Dim nPageCount As Integer
            Dim nModNum As Integer        nModNum = dvShowData.Count Mod MyDataGrid.PageSize
            nPageCount = IIf(nModNum = 0, dvShowData.Count / MyDataGrid.PageSize,   (dvShowData.Count - nModNum) / MyDataGrid.PageSize + 1)
            If MyDataGrid.CurrentPageIndex <> 0 Then
                If MyDataGrid.CurrentPageIndex >= nPageCount Then
                    MyDataGrid.CurrentPageIndex = IIf(nPageCount > 0, nPageCount - 1, 0)
                End If
            End If
            MyDataGrid.Visible = True
            MyDataGrid.DataBind()
            lab_Row.Visible = True       '显示标签数据
            lab_Row.Text = "符合条件的记录&nbsp;<font color=""#FF0000"">" & dvShowData.Count.ToString & "</font>&nbsp;条"
            If MyDataGrid.AllowPaging = True Then
                lab_Page.Visible = True
                lab_CPage.Visible = True
                lab_Page.Text = "共&nbsp;<font color=""#FF0000"">" & CInt(nPageCount).ToString & "</font>&nbsp;页"
                lab_CPage.Text = "当前页第&nbsp;<font color=""#FF0000"">" & CInt(MyDataGrid.CurrentPageIndex + 1).ToString & "</font>&nbsp;页"
            Else
                lab_Page.Visible = False
                lab_CPage.Visible = False
            End If
            Dim sDataIsShow As String
            If MyDataGrid.Visible Then
                sDataIsShow = "1"
            Else
                sDataIsShow = "0"
            End If
        End Sub然后再写一个函数调用这个BindGrid,在这里你取Session的时候,无论你对Page做什么操作,Session都会随着你的改变而能随时取值。
      

  4.   

    http://218.27.204.17/aspnet/a_user.aspx