473,473 Members | 2,109 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

My ViewState is huge! What can I do?

Hello,

I have an ASPX page on which I place a UserControl 15 times (they only need
to be static controls on the page). This UserControl is a set of two
listboxes with radiobuttons above the listbox (to select between viewing a
code or description in the listbox). There are also left and right arrows
that move the selected items between the listboxes.

In my Page_Load I assign each UserControl the appropriate DataTable and this
assignment only happens when it is not a PostBack. So I know (pretty sure)
that I am not reloading all that data each time.

Each listbox (on the left) is loaded with data from stored procedures. When
I click the right arrow to move a selection from the left to the right
listbox it causes a postback (as expected). The problem is that I only need
to do a postback for the UserControl where I made the change (if that makes
any sense). The entire page doesn't need to be reloaded.

When I click an arrow in a UserControl, the bottom of IE says, "Opening
http:/localhost/..." This occurs even before it gets to the Page_Load.

Is there a way I can have a postback only on the UserControl I am clicking
on? I have ViewState on and when I look at the ViewSource, the ViewState is
just huge! The problem is some of these listboxes, in the UserControls, have
a large amount of data and I don't think it makes much sense to repopulate
them on each postback, yet I am forced to have this huge ViewState that is
really slowing things down.

Any help is greatly appreciated.
Sep 19 '06 #1
3 3474
Gummy,

1) You should be able to turn on ViewState for individual controls (and on
or off for the Page).
2) If the data that's loaded for each control doesn't change, you should
consider storing it in Cache so that you do not need to keep making round
trips to the database just to get the same data back again.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Gummy" wrote:
Hello,

I have an ASPX page on which I place a UserControl 15 times (they only need
to be static controls on the page). This UserControl is a set of two
listboxes with radiobuttons above the listbox (to select between viewing a
code or description in the listbox). There are also left and right arrows
that move the selected items between the listboxes.

In my Page_Load I assign each UserControl the appropriate DataTable and this
assignment only happens when it is not a PostBack. So I know (pretty sure)
that I am not reloading all that data each time.

Each listbox (on the left) is loaded with data from stored procedures. When
I click the right arrow to move a selection from the left to the right
listbox it causes a postback (as expected). The problem is that I only need
to do a postback for the UserControl where I made the change (if that makes
any sense). The entire page doesn't need to be reloaded.

When I click an arrow in a UserControl, the bottom of IE says, "Opening
http:/localhost/..." This occurs even before it gets to the Page_Load.

Is there a way I can have a postback only on the UserControl I am clicking
on? I have ViewState on and when I look at the ViewSource, the ViewState is
just huge! The problem is some of these listboxes, in the UserControls, have
a large amount of data and I don't think it makes much sense to repopulate
them on each postback, yet I am forced to have this huge ViewState that is
really slowing things down.

Any help is greatly appreciated.
Sep 20 '06 #2
Peter,

I really appreciate the information.

If I understand this correctly, on Postback the control for which I shut off
ViewState will not repopulate, is that correct?

If I use Cache, what part of the application takes the hit with all that
data?
When using Cache, do I use it the same way as ViewState (maybe just a search
and replace in my code) and .NET will take care of the rest?
Do I need to turn on/off Cache for just the controls whose data is changing?

Thank you.

"Peter Bromberg [C# MVP]" <pb*******@yahoo.nospammin.comwrote in message
news:2A**********************************@microsof t.com...
Gummy,

1) You should be able to turn on ViewState for individual controls (and on
or off for the Page).
2) If the data that's loaded for each control doesn't change, you should
consider storing it in Cache so that you do not need to keep making round
trips to the database just to get the same data back again.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Gummy" wrote:
>Hello,

I have an ASPX page on which I place a UserControl 15 times (they only
need
to be static controls on the page). This UserControl is a set of two
listboxes with radiobuttons above the listbox (to select between viewing
a
code or description in the listbox). There are also left and right arrows
that move the selected items between the listboxes.

In my Page_Load I assign each UserControl the appropriate DataTable and
this
assignment only happens when it is not a PostBack. So I know (pretty
sure)
that I am not reloading all that data each time.

Each listbox (on the left) is loaded with data from stored procedures.
When
I click the right arrow to move a selection from the left to the right
listbox it causes a postback (as expected). The problem is that I only
need
to do a postback for the UserControl where I made the change (if that
makes
any sense). The entire page doesn't need to be reloaded.

When I click an arrow in a UserControl, the bottom of IE says, "Opening
http:/localhost/..." This occurs even before it gets to the Page_Load.

Is there a way I can have a postback only on the UserControl I am
clicking
on? I have ViewState on and when I look at the ViewSource, the ViewState
is
just huge! The problem is some of these listboxes, in the UserControls,
have
a large amount of data and I don't think it makes much sense to
repopulate
them on each postback, yet I am forced to have this huge ViewState that
is
really slowing things down.

Any help is greatly appreciated.

Sep 20 '06 #3
Gummy wrote:
Hello,

I have an ASPX page on which I place a UserControl 15 times (they only need
to be static controls on the page). This UserControl is a set of two
listboxes with radiobuttons above the listbox (to select between viewing a
code or description in the listbox). There are also left and right arrows
that move the selected items between the listboxes.

In my Page_Load I assign each UserControl the appropriate DataTable and this
assignment only happens when it is not a PostBack. So I know (pretty sure)
that I am not reloading all that data each time.

Each listbox (on the left) is loaded with data from stored procedures. When
I click the right arrow to move a selection from the left to the right
listbox it causes a postback (as expected). The problem is that I only need
to do a postback for the UserControl where I made the change (if that makes
any sense). The entire page doesn't need to be reloaded.

When I click an arrow in a UserControl, the bottom of IE says, "Opening
http:/localhost/..." This occurs even before it gets to the Page_Load.

Is there a way I can have a postback only on the UserControl I am clicking
on? I have ViewState on and when I look at the ViewSource, the ViewState is
just huge! The problem is some of these listboxes, in the UserControls, have
a large amount of data and I don't think it makes much sense to repopulate
them on each postback, yet I am forced to have this huge ViewState that is
really slowing things down.

Any help is greatly appreciated.
Hi Gummy,

To put things simply: No.

Unless you're using frames (which just about everyone hates these days,
so I'll assume you're not), whenever you cause a postback, the entire
page has to be regenerated. This is because, as far as your browser is
concerned, it is navigating from one page to another. It has to be
supplied with all of the information it needs to render this "new"
page. That includes all of the data in all of the controls on the page.

Now, if you use viewstate, all of the information needed to repopulate
the controls is stored there, and is used to reconstruct the data
within those controls. If you disable viewstate for the controls, then
they will not know what they should contain (unless you reload them
from the database). It this simple: new page needs all of the data from
the old page. You either put in in the viewstate or you reload it from
the database. Either way will have performance hits.

Could you convert your user controls so that, if javascript is
available, they do most of their work client side, and so you only post
back when the whole page needs it? (Or possibly, if every movement
needs to be known about server side, use AJAX rather than causing a
postback)

Damien

Sep 20 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Lisa | last post by:
I have a web app that gets a recordset from the database and fills a grid. You can drilldown from this table to a detail table. Because the tables sometimes get huge, and because I have to go...
6
by: clsmith66 | last post by:
Is it possible to store the same information about a control that would be saved in the ViewState in a Session state? I have a page with three treeview controls and if I enable the view state for...
3
by: Lars Grøtteland | last post by:
Hello! My ViewState is huge. I have a couple two comboboxes, three edit boxes with one button each, and a dataGrid. I'm showing 200 items in the grid, and when the page loads, the viewState is...
7
by: Mantorok | last post by:
It's not unusual (to be lo....cough) for me to have VIEWSTATE ranging from 1 full page to several pages..... This seems in-efficient - any ideas how to reduce the thing? Thanks Kev
1
by: John | last post by:
I'm having problems controlling viewstate size in ASP.NET 2.0. I have a repeater, which contains a gridview, which contains another gridview. All this is databound to produce a 100page report...
3
by: emde | last post by:
In looking for a way to trim down viewstate, I came across the following articles to store viewstate in session: http://aspalliance.com/72 ...
2
by: Carly | last post by:
Hi, I am now not sure I understand what ViewState does. Having EnableViewState=true or false on a WEB form and/or different server controls does not seem to make any difference. I am just...
2
by: msch.prv | last post by:
Thanks for bearing with me. I am confronted with huge hidden viewstates fields in some pages and looking for ways to make these pages leaner. My problem hinges on how to efficiently handle...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.