views:

36

answers:

2

Interesting happened to me... I have a grid with rows of data, but the page will fail have several postback. I check it with fiddler and find that view state expands 2-3 times after each post back.

The thing I did to trigger the post back is searching and sorting. I am not sure how it happens. Does anybody can give me a hint?

Thank you!

A: 

My opinion, first locate wich control is make the view state grow (maybe you have any drop down list box, that you forget to clear, and on each post back you add more items)

To do that, place on your controls one after the other the viewstate=false.

ones you locate the control that make the problem, just check if you forget to clear it, and you just add data to it.

Aristos
A: 

OK, I fixed this problem. I think the ViewState is just something like a Dictionary that keep a list of key value pair. In my case, my value is objects, which is a address or reference. So when I get a object from ViewState, and uncarefully assign new children to that object. all new children will be put to ViewState automatically. Unfortunately, in my code there is really uncareful cycle that get children from ViewState, create copies in memory and add them back! The code cannot distinguish duplicate children because they are at different address.... So finally the page get 2 times bigger at each post back and bang!!!!!!!

Thanks you guys all the same!