Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ViewState is HUGE

Reply
Thread Tools

ViewState is HUGE

 
 
Lars Grøtteland
Guest
Posts: n/a
 
      08-16-2005
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
61 pages pasted into Word. - That's over 3/4 of the aspx page.

Any help how to size down this ViewState would be appreciated.

- Lars


 
Reply With Quote
 
 
 
 
Alex D.
Guest
Posts: n/a
 
      08-16-2005
just disable ViewState for the whole DataGrid and bind it every time the
page is loaded. if you need to post back some fields from your datagrid then
just disable the viewstate for the other fields, in order to do that you may
need to use template fields for the ones you one to disable postback.


"Lars Grøtteland" <lars@nospam> wrote in message
news:%...
> 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 61 pages pasted into Word. - That's over 3/4 of the aspx page.
>
> Any help how to size down this ViewState would be appreciated.
>
> - Lars
>



 
Reply With Quote
 
Eliyahu Goldin
Guest
Posts: n/a
 
      08-16-2005
Lars,

If you re-populate the datagrid on every postback, you can disable it's
ViewState. It will save a lot.

Eliyahu

"Lars Grøtteland" <lars@nospam> wrote in message
news:%...
> 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
> 61 pages pasted into Word. - That's over 3/4 of the aspx page.
>
> Any help how to size down this ViewState would be appreciated.
>
> - Lars
>
>



 
Reply With Quote
 
Marcel van den Hof
Guest
Posts: n/a
 
      08-16-2005
Hi Lars,

If you would like to use datagrid functionality like paging and
sorting then I would not recommend to disable the viewstate on the
datagrid itself.

My recommended approach would be:
1: Rebind to the grid on every postback.
2: Disable the viewstate for each row of type ListItemType.Item.

So for example in the DataGrid1_ItemCreated event you could add the
following line of code:

if (e.Item.ItemType == ListItemType.Item)
e.Item.EnableViewState = false;

That little line of magic there will shorten the viewstate
considerably. But you will need to rebind on every postback.

Let me know if this works out for you.

Regards,

Marcel van den Hof
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Memory error due to the huge/huge input file size tejsupra@gmail.com Python 3 11-20-2008 06:21 PM
My ViewState is huge! What can I do? Gummy ASP .Net 3 09-20-2006 06:56 AM
Huge viewstate on v2.0 John ASP .Net 1 12-03-2005 09:15 AM
HUGE Viewstate Mantorok ASP .Net 7 12-02-2005 10:51 AM
How to a avoid a *huge* viewstate? mortb ASP .Net Building Controls 2 05-01-2005 05:38 PM



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57