ViewState Question

  • Thread starter Thread starter Samuel Shulman
  • Start date Start date
S

Samuel Shulman

I assign the ViewState with some values that disappear when the page is
loaded again what can I do to preserve the values?

Thank you,
Samuel
 
Is it the same page? ViewState goes out of scope when you switch the
pages your on.

Can you provide some code? This would help.

Sean
 
It is the same page and below is the code

The user clickes the Column header and the data disappears

Thanks
Protected Sub dg_Sorting(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.GridViewSortEventArgs) Handles dg.Sorting

Dim sSort As String

Dim sDirection As String

sSort = ViewState("Sort")

sDirection = ViewState("Direction")

If sSort = e.SortExpression Then

If sDirection = "asc" Then

sDirection = "desc"

Else

sDirection = "asc"

End If

Else

sDirection = "asc"

End If

ViewState("Sort") = sSort

ViewState("Direction") = sDirection

PopulateList(e.SortExpression & " " & sDirection)

End Sub
 
Back
Top