ViewState Question

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
 
S

Sean Chambers

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
 
S

Samuel Shulman

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,265
Latest member
TodLarocca

Latest Threads

Top