Large page size (viewstate)

Last post 03-08-2008 5:11 AM by nati28. 11 replies.

Sort Posts:

  • Large page size (viewstate)

    03-05-2008, 3:55 PM
    • Loading...
    • nati28
    • Joined on 03-05-2008, 3:49 PM
    • Posts 8

    Hi,

    Itried it and it works grate Smile.

    I have onle one small problems:

    One of my tables contains 1500 rows and 50 columns, in aresults the grid has large viewstate (more than 1M...).

    When disabaling the viewstate it stop to function and raise javascript errors on paging, update ext.

     

    Does someone have any idea how to solve it ?

     

    Filed under:
  • Re: Large page size (viewstate)

    03-05-2008, 6:11 PM
    • Loading...
    • jsharratt
    • Joined on 08-10-2004, 2:14 PM
    • West Midlands, UK
    • Posts 97

    Can we have a little more information such as what kind of grid you are using and you are binding your data to it.

     

    Cheers,
    Jon Sharratt

  • Re: Large page size (viewstate)

    03-05-2008, 11:45 PM
    • Loading...
    • nati28
    • Joined on 03-05-2008, 3:49 PM
    • Posts 8

    I'm using the default grid that the template generated.

    I copied it to new folder and gave the folder the table name.

    The only changed I did in the ListDetails.aspx page is to decrease the number of then columns:

    <asp:DynamicGridView ID="GridView1" runat="server" DataSourceID="GridDataSource"

    AutoGenerateSelectButton="True" AutoGenerateEditButton="True" AutoGenerateDeleteButton="True"

    AllowPaging="True" AllowSorting="True" EnableQueryStringSelection="True" OnDataBound="OnGridViewDataBound"

    OnRowEditing="OnGridViewRowEditing" OnSelectedIndexChanging="OnGridViewSelectedIndexChanging"

    CssClass="gridview" AlternatingRowStyle-CssClass="even"

    AutoGenerateColumns="False" >

    <PagerStyle CssClass="Footer"/>

    <Columns>

    <asp:BoundField DataField="ID" HeaderText="#" SortExpression="ID" />

    <asp:BoundField DataField="FoodCode" HeaderText="FoodCode"

    SortExpression="FoodCode" />

    <asp:BoundField DataField="Description" HeaderText="Description"

    SortExpression="Description" />

    <asp:BoundField DataField="KeyWords" HeaderText="KeyWords"

    SortExpression="KeyWords" />

    <asp:BoundField DataField="FoodCatID" HeaderText="Cat"

    SortExpression="FoodCatID" />

    <asp:BoundField DataField="Short_desc" HeaderText="Short_desc"

    SortExpression="Short_desc" />

     

    </Columns>

    <PagerTemplate>

    <uc1:GridViewPager runat="server" />

    </PagerTemplate>

    <EmptyDataTemplate>

    There are currently no items in this table.

    </EmptyDataTemplate>

    <AlternatingRowStyle CssClass="even"></AlternatingRowStyle>

    </asp:DynamicGridView>

    <asp:LinqDataSource ID="GridDataSource" runat="server">

    <WhereParameters>

    <asp:DynamicControlParameter ControlID="FilterRepeater" />

    </WhereParameters>

    </asp:LinqDataSource>

     

    Filed under:
  • Re: Large page size (viewstate)

    03-06-2008, 3:08 PM
    • Loading...
    • marcind
    • Joined on 09-06-2007, 5:11 AM
    • Redmond, WA
    • Posts 305
    • AspNetTeam

    Hi nati28,

    the ASP.NET 3.5 Extensions preview is an early preview version of the Dynamic Data feature and might not have all of its behavior optimized. In addition, Dynamic Data controls do not currently function with viewstate turned off in edit scenarios. We are working on addressing this issue.

    On a side note, you are using BoundFields in your columns collection. To take advantage of the field template feature of Dynamic Data you should be using DynamicFields instead. 

    Marcin Dobosz
    SDE, ASP.NET Team, Microsoft
    Get the Dynamic Data Futures 7/16 update.
  • Re: Large page size (viewstate)

    03-06-2008, 4:17 PM
    • Loading...
    • nati28
    • Joined on 03-05-2008, 3:49 PM
    • Posts 8
    Thanks for the reply.
     
    The viewstate issue is really a big problem ( more than 1.5M...)
    Why the grid need viewstate for all the rows & columns (in the DB there are more than 40 column but the grid display only few columns - if the viewstate will represent only the visible column this issue could be solved).
     
    It is really cool that we can develop so fast, but 1500 rows with 50 columns in one DB table should be handle with no problems...Sad
     
    I changed my code to DynamicFields (nothing better...)
     
  • Re: Large page size (viewstate)

    03-06-2008, 5:21 PM
    • Loading...
    • davidebb
    • Joined on 06-11-2002, 12:31 PM
    • Redmond, WA
    • Posts 923
    • AspNetTeam

    Do you see the view state changing size as you change the number of displayed columns, or does it make no difference?  e.g. if you try 1, 2, 5, 10, 50 columns, how does it affect the size?

    Also, are you displaying all the rows at once, or are you using paging?  e.g. If you only display 10 rows at a time, you should get less much view state than if you display them all.

    Note that all this is probably not specific to Dynamic Data, and I suspect you'd see similar behavior with a regular GridView & LinqDataSource.

    David

  • Re: Large page size (viewstate)

    03-07-2008, 1:14 AM
    • Loading...
    • nati28
    • Joined on 03-05-2008, 3:49 PM
    • Posts 8
    Of coerce I'm using paging...
    I never displayed all the columns (only the columns that exists in the code I posted).
     
    I tried to display only 1,2,3 columns and the viewstate is still the same (about 1.2 M , total HTML page size 1.5 M).
     
    I tried another scenario:
    1. Table with about 5 columns and 10,000 rows.
    2. using the default templates (with paging...)
    3. the page size is 6M !
     
    It should be critical bug (i don't know if it's belong to LINQ / Dianamic data,  or do I miss some configuration ?
     
    Thanks,
     
  • Re: Large page size (viewstate)

    03-07-2008, 3:58 PM
    • Loading...
    • marcind
    • Joined on 09-06-2007, 5:11 AM
    • Redmond, WA
    • Posts 305
    • AspNetTeam

    Nati,

    could you write a page that uses a regular GridVIew to display your table and compare how much view state you are seeing without Dynamic Data being involved? Then we would be better able to isolate your problem.

    Marcin Dobosz
    SDE, ASP.NET Team, Microsoft
    Get the Dynamic Data Futures 7/16 update.
  • Re: Large page size (viewstate)

    03-07-2008, 4:47 PM
    • Loading...
    • nati28
    • Joined on 03-05-2008, 3:49 PM
    • Posts 8
    Yes I did it... When I use <asp:LinqDataSource> and <asp:GridView> with EnableViewState =true the page size is ~ 80 k (the viesate is represent only then displayed rows & columns. In the DynamicData the viewstate represent all the rows & columns of the grid (not only the displayed ).In the both scenarios I used paging with the same page size...I think it's bug in the <asp:DynamicGridView> that the viewstate represent all the rows & columns of the grid and not only the displayed rows & columns.

    On this case it can works fine only with about 10,000 cels, when the rows * columns = more than 100,000 cells the page size is really huge. (Of coerce I'm using paging…)

     

    Did someone tried it (<asp:DynamicGridView>)  on large tables ( more than 10,000 rows) ?

     

  • Re: Large page size (viewstate)

    03-07-2008, 5:14 PM
    • Loading...
    • davidebb
    • Joined on 06-11-2002, 12:31 PM
    • Redmond, WA
    • Posts 923
    • AspNetTeam

    Strange, I'm not seeing this.  I see the ViewState get larger as I add more columns.  Does your page also contain some filters (i.e. drop downs)?  Those also contribute to the view state, and for foreign keys into tables with lots of rows they can make a big difference.  To do a valid comparison between the DynamicGridView and the regular GridView, you would need to reduce the default page to only have the DynamicGridView and LinqDataSource, and not any of the other things (filters, detailsview, etc...).

    David

  • Re: Large page size (viewstate)

    03-08-2008, 3:19 AM
    • Loading...
    • nati28
    • Joined on 03-05-2008, 3:49 PM
    • Posts 8
    Thanks David,You are right, the component that enlarged the viewstate is the DynamicDetailsView (when setting <asp:LinqDataSource EnableViewState=false > the page size is fine - and the select action on the grid doesn't work...)When I use only the <asp:DynamicGridView> the page size is fine…I'll try to find out why…Does anyone have an idea?Thanks,

     

  • Re: Large page size (viewstate)

    03-08-2008, 5:11 AM
    Answer
    • Loading...
    • nati28
    • Joined on 03-05-2008, 3:49 PM
    • Posts 8

    I found the problem:

    <asp:LinqDataSource StoreOriginalValuesInViewState=false

    Solve it...

    Thanks for everyone that helps me with this issue

     

     

     

Page 1 of 1 (12 items)