Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

Not having a good day with ViewState

  Asked By: Alyson    Date: Sep 21    Category: Sharepoint    Views: 2768

I am not having a good day with ViewState().

Here it is:

1) I have a web part with a sortable grid.
2) I manipulate the sort expressions and store them using ViewState.
3) This all seems to work fine while I am on the page with the web part.
4) I go to another page within the site.
5) I click the link with the web part and it comes up without the sort
expression saved in the ViewState, that is as if it is all new.

Here is my quesion:
Is the information in the ViewState saved after I go aoof the current page
and then back to that page?



5 Answers Found

Answer #1    Answered By: Sheena Ray     Answered On: Sep 21

ViewState will not persist between pages. It is only used for postbacks to one page.

What you are trying to do may be better accomplished with session state instead.

Answer #2    Answered By: Jaime Weaver     Answered On: Sep 21

The trouble with session state is that it is off in the standard sharepoint
config.web, and (as I understand it) using session is discouraged in
sharepoint due to the performance hit.

So other than using session, does anyone have a suggestion?

Answer #3    Answered By: Anibal Baird     Answered On: Sep 21

You could use a cookie...........

Answer #4    Answered By: Karla Morrison     Answered On: Sep 21

That too, but you know about cookies and users. Although I could tell them
that they get that feature if they allow the cookie.

Sharepoint caches too, and I could make it "Personal Storage." I got that
kind of working, but I am unsure of the consequences. It seems to me that
it might be a feature to give them the same settings when they are on a
different machine.

Answer #5    Answered By: Patricia Richardson     Answered On: Sep 21

ViewState is only saved  on Page postback in all ASP.NET applications.

State management in SharePoint is typically accomplished using web  Part

FWIW, constant application values could be stored in an
application.config file referred to by the web.config or in the
web.config itself and client side, cookies can certainly still be used.

Didn't find what you were looking for? Find more on Not having a good day with ViewState Or get search suggestion and latest updates.