Telerik is a leading vendor of ASP.NET AJAX, ASP.NET MVC, Silverlight, WinForms and WPF controls and components, as well as .NET Reporting, .NET ORM , .NET CMS, Code Analysis, Mocking, Team Productivity and Automated Testing Tools. Building on its expertise in interface development and Microsoft technologies, Telerik helps customers build applications with unparalleled richness, responsiveness and interactivity. Telerik products help thousands of companies to be more productive and deliver reliable applications under budget and on time.
Version Q1 2012 released 04/11/2012
select

Grid / ViewState Optimization

Example Configuration
RadGrid's ViewState size is 3316 bytes


Toms SpezialitätenLuisenstr. 48Münster 44087GermanyTOMSPToms SpezialitätenLuisenstr. 48Münster 44087GermanyMichael Suyama102497/5/1996 12:00:00 AM8/16/1996 12:00:00 AM7/10/1996 12:00:00 AMSpeedy Express14Tofu18.6090167.400011.61
Toms SpezialitätenLuisenstr. 48Münster 44087GermanyTOMSPToms SpezialitätenLuisenstr. 48Münster 44087GermanyMichael Suyama102497/5/1996 12:00:00 AM8/16/1996 12:00:00 AM7/10/1996 12:00:00 AMSpeedy Express51Manjimup Dried Apples42.404001696.000011.61
Victuailles en stock2, rue du CommerceLyon 69004FranceVICTEVictuailles en stock2, rue du CommerceLyon 69004FranceJanet Leverling102517/8/1996 12:00:00 AM8/5/1996 12:00:00 AM7/15/1996 12:00:00 AMSpeedy Express22Gustaf's Knäckebröd16.8060.0595.760041.34
Victuailles en stock2, rue du CommerceLyon 69004FranceVICTEVictuailles en stock2, rue du CommerceLyon 69004FranceJanet Leverling102517/8/1996 12:00:00 AM8/5/1996 12:00:00 AM7/15/1996 12:00:00 AMSpeedy Express57Ravioli Angelo15.60150.05222.300041.34
Victuailles en stock2, rue du CommerceLyon 69004FranceVICTEVictuailles en stock2, rue du CommerceLyon 69004FranceJanet Leverling102517/8/1996 12:00:00 AM8/5/1996 12:00:00 AM7/15/1996 12:00:00 AMSpeedy Express65Louisiana Fiery Hot Pepper Sauce16.80200336.000041.34
Ernst HandelKirchgasse 6Graz 8010AustriaERNSHErnst HandelKirchgasse 6Graz 8010AustriaNancy Davolio102587/17/1996 12:00:00 AM8/14/1996 12:00:00 AM7/23/1996 12:00:00 AMSpeedy Express2Chang15.20500.2608.0000140.51
Ernst HandelKirchgasse 6Graz 8010AustriaERNSHErnst HandelKirchgasse 6Graz 8010AustriaNancy Davolio102587/17/1996 12:00:00 AM8/14/1996 12:00:00 AM7/23/1996 12:00:00 AMSpeedy Express5Chef Anton's Gumbo Mix17.00650.2884.0000140.51
Ernst HandelKirchgasse 6Graz 8010AustriaERNSHErnst HandelKirchgasse 6Graz 8010AustriaNancy Davolio102587/17/1996 12:00:00 AM8/14/1996 12:00:00 AM7/23/1996 12:00:00 AMSpeedy Express32Mascarpone Fabioli25.6060.2122.8800140.51
Ottilies KäseladenMehrheimerstr. 369Köln 50739GermanyOTTIKOttilies KäseladenMehrheimerstr. 369Köln 50739GermanyMargaret Peacock102607/19/1996 12:00:00 AM8/16/1996 12:00:00 AM7/29/1996 12:00:00 AMSpeedy Express41Jack's New England Clam Chowder7.70160.2592.400055.09
Ottilies KäseladenMehrheimerstr. 369Köln 50739GermanyOTTIKOttilies KäseladenMehrheimerstr. 369Köln 50739GermanyMargaret Peacock102607/19/1996 12:00:00 AM8/16/1996 12:00:00 AM7/29/1996 12:00:00 AMSpeedy Express57Ravioli Angelo15.60500780.000055.09
Ottilies KäseladenMehrheimerstr. 369Köln 50739GermanyOTTIKOttilies KäseladenMehrheimerstr. 369Köln 50739GermanyMargaret Peacock102607/19/1996 12:00:00 AM8/16/1996 12:00:00 AM7/29/1996 12:00:00 AMSpeedy Express62Tarte au sucre39.40150.25443.250055.09
Ottilies KäseladenMehrheimerstr. 369Köln 50739GermanyOTTIKOttilies KäseladenMehrheimerstr. 369Köln 50739GermanyMargaret Peacock102607/19/1996 12:00:00 AM8/16/1996 12:00:00 AM7/29/1996 12:00:00 AMSpeedy Express70Outback Lager12.00210.25189.000055.09
Blondel père et fils24, place KléberStrasbourg 67000FranceBLONPBlondesddsl père et fils24, place KléberStrasbourg 67000FranceAndrew Fuller102657/25/1996 12:00:00 AM8/22/1996 12:00:00 AM8/12/1996 12:00:00 AMSpeedy Express17Alice Mutton31.20300936.000055.28
Blondel père et fils24, place KléberStrasbourg 67000FranceBLONPBlondesddsl père et fils24, place KléberStrasbourg 67000FranceAndrew Fuller102657/25/1996 12:00:00 AM8/22/1996 12:00:00 AM8/12/1996 12:00:00 AMSpeedy Express70Outback Lager12.00200240.000055.28
FrankenversandBerliner Platz 43München 80805GermanyFRANKFrankenversandBerliner Platz 43München 80805GermanyMargaret Peacock102677/29/1996 12:00:00 AM8/26/1996 12:00:00 AM8/6/1996 12:00:00 AMSpeedy Express40Boston Crab Meat14.70500735.0000208.58
FrankenversandBerliner Platz 43München 80805GermanyFRANKFrankenversandBerliner Platz 43München 80805GermanyMargaret Peacock102677/29/1996 12:00:00 AM8/26/1996 12:00:00 AM8/6/1996 12:00:00 AMSpeedy Express59Raclette Courdavault44.00700.152618.0000208.58
FrankenversandBerliner Platz 43München 80805GermanyFRANKFrankenversandBerliner Platz 43München 80805GermanyMargaret Peacock102677/29/1996 12:00:00 AM8/26/1996 12:00:00 AM8/6/1996 12:00:00 AMSpeedy Express76Lakkalikööri14.40150.15183.6000208.58
White Clover Markets1029 - 12th Ave. S.SeattleWA98124USAWHITCWhite Clover Markets305 - 14th Ave. S. Suite 3BSeattleWA98128USASteven Buchanan102697/31/1996 12:00:00 AM8/14/1996 12:00:00 AM8/9/1996 12:00:00 AMSpeedy Express33Geitost2.00600.05114.00004.56
White Clover Markets1029 - 12th Ave. S.SeattleWA98124USAWHITCWhite Clover Markets305 - 14th Ave. S. Suite 3BSeattleWA98128USASteven Buchanan102697/31/1996 12:00:00 AM8/14/1996 12:00:00 AM8/9/1996 12:00:00 AMSpeedy Express72Mozzarella di Giovanni27.80200.05528.20004.56
Wartian HerkkuTorikatu 38Oulu 90110FinlandWARTHWartian HerkkuTorikatu 38Oulu 90110FinlandNancy Davolio102708/1/1996 12:00:00 AM8/29/1996 12:00:00 AM8/2/1996 12:00:00 AMSpeedy Express36Inlagd Sill15.20300456.0000136.54
Wartian HerkkuTorikatu 38Oulu 90110FinlandWARTHWartian HerkkuTorikatu 38Oulu 90110FinlandNancy Davolio102708/1/1996 12:00:00 AM8/29/1996 12:00:00 AM8/2/1996 12:00:00 AMSpeedy Express43Ipoh Coffee36.80250920.0000136.54
Vins et alcools Chevalier59 rue de l'AbbayeReims 51100FranceVINETVins et alcools Chevalier59 rue de l'AbbayeReims 51100FranceMichael Suyama102748/6/1996 12:00:00 AM9/3/1996 12:00:00 AM8/16/1996 12:00:00 AMSpeedy Express71Flotemysost17.20200344.00006.01
Vins et alcools Chevalier59 rue de l'AbbayeReims 51100FranceVINETVins et alcools Chevalier59 rue de l'AbbayeReims 51100FranceMichael Suyama102748/6/1996 12:00:00 AM9/3/1996 12:00:00 AM8/16/1996 12:00:00 AMSpeedy Express72Mozzarella di Giovanni27.8070194.60006.01
Magazzini Alimentari RiunitiVia Ludovico il Moro 22Bergamo 24100ItalyMAGAAMagazzini Alimentari RiunitiVia Ludovico il Moro 22Bergamo 24100ItalyNancy Davolio102758/7/1996 12:00:00 AM9/4/1996 12:00:00 AM8/9/1996 12:00:00 AMSpeedy Express24Guaraná Fantástica3.60120.0541.040026.93
Magazzini Alimentari RiunitiVia Ludovico il Moro 22Bergamo 24100ItalyMAGAAMagazzini Alimentari RiunitiVia Ludovico il Moro 22Bergamo 24100ItalyNancy Davolio102758/7/1996 12:00:00 AM9/4/1996 12:00:00 AM8/9/1996 12:00:00 AMSpeedy Express59Raclette Courdavault44.0060.05250.800026.93
Berglunds snabbköpBerguvsvägen 8Luleå S-958 22SwedenBERGSBerglunds snabbköpBerguvsvägen 8Luleå S-958 22SwedenAndrew Fuller102808/14/1996 12:00:00 AM9/11/1996 12:00:00 AM9/12/1996 12:00:00 AMSpeedy Express24Guaraná Fantástica3.6012043.20008.98
Berglunds snabbköpBerguvsvägen 8Luleå S-958 22SwedenBERGSBerglunds snabbköpBerguvsvägen 8Luleå S-958 22SwedenAndrew Fuller102808/14/1996 12:00:00 AM9/11/1996 12:00:00 AM9/12/1996 12:00:00 AMSpeedy Express55Pâté chinois19.20200384.00008.98
Berglunds snabbköpBerguvsvägen 8Luleå S-958 22SwedenBERGSBerglunds snabbköpBerguvsvägen 8Luleå S-958 22SwedenAndrew Fuller102808/14/1996 12:00:00 AM9/11/1996 12:00:00 AM9/12/1996 12:00:00 AMSpeedy Express75Rhönbräu Klosterbier6.20300186.00008.98
Romero y tomilloGran Vía, 1Madrid 28001SpainROMEYRomero y tomilloGran Vía, 1Madrid 28001SpainMargaret Peacock102818/14/1996 12:00:00 AM8/28/1996 12:00:00 AM8/21/1996 12:00:00 AMSpeedy Express19Teatime Chocolate Biscuits7.30107.30002.94
Romero y tomilloGran Vía, 1Madrid 28001SpainROMEYRomero y tomilloGran Vía, 1Madrid 28001SpainMargaret Peacock102818/14/1996 12:00:00 AM8/28/1996 12:00:00 AM8/21/1996 12:00:00 AMSpeedy Express24Guaraná Fantástica3.606021.60002.94
Romero y tomilloGran Vía, 1Madrid 28001SpainROMEYRomero y tomilloGran Vía, 1Madrid 28001SpainMargaret Peacock102818/14/1996 12:00:00 AM8/28/1996 12:00:00 AM8/21/1996 12:00:00 AMSpeedy Express35Steeleye Stout14.404057.60002.94
Romero y tomilloGran Vía, 1Madrid 28001SpainROMEYRomero y tomilloGran Vía, 1Madrid 28001SpainMargaret Peacock102828/15/1996 12:00:00 AM9/12/1996 12:00:00 AM8/21/1996 12:00:00 AMSpeedy Express30Nord-Ost Matjeshering20.7060124.200012.69
Romero y tomilloGran Vía, 1Madrid 28001SpainROMEYRomero y tomilloGran Vía, 1Madrid 28001SpainMargaret Peacock102828/15/1996 12:00:00 AM9/12/1996 12:00:00 AM8/21/1996 12:00:00 AMSpeedy Express57Ravioli Angelo15.602031.200012.69
Lehmanns MarktstandMagazinweg 7Frankfurt a.M. 60528GermanyLEHMSLehmanns MarktstandMagazinweg 7Frankfurt a.M. 60528GermanyMargaret Peacock102848/19/1996 12:00:00 AM9/16/1996 12:00:00 AM8/27/1996 12:00:00 AMSpeedy Express27Schoggi Schokolade35.10150.25394.880076.56
Lehmanns MarktstandMagazinweg 7Frankfurt a.M. 60528GermanyLEHMSLehmanns MarktstandMagazinweg 7Frankfurt a.M. 60528GermanyMargaret Peacock102848/19/1996 12:00:00 AM9/16/1996 12:00:00 AM8/27/1996 12:00:00 AMSpeedy Express44Gula Malacca15.50210325.500076.56
Lehmanns MarktstandMagazinweg 7Frankfurt a.M. 60528GermanyLEHMSLehmanns MarktstandMagazinweg 7Frankfurt a.M. 60528GermanyMargaret Peacock102848/19/1996 12:00:00 AM9/16/1996 12:00:00 AM8/27/1996 12:00:00 AMSpeedy Express60Camembert Pierrot27.20200.25408.000076.56
Lehmanns MarktstandMagazinweg 7Frankfurt a.M. 60528GermanyLEHMSLehmanns MarktstandMagazinweg 7Frankfurt a.M. 60528GermanyMargaret Peacock102848/19/1996 12:00:00 AM9/16/1996 12:00:00 AM8/27/1996 12:00:00 AMSpeedy Express67Laughing Lumberjack Lager11.2050.2542.000076.56
Reggiani CaseificiStrada Provinciale 124Reggio Emilia 42100ItalyREGGCReggiani CaseificiStrada Provinciale 124Reggio Emilia 42100ItalyMargaret Peacock102888/23/1996 12:00:00 AM9/20/1996 12:00:00 AM9/3/1996 12:00:00 AMSpeedy Express54Tourtière5.90100.153.10007.45
Reggiani CaseificiStrada Provinciale 124Reggio Emilia 42100ItalyREGGCReggiani CaseificiStrada Provinciale 124Reggio Emilia 42100ItalyMargaret Peacock102888/23/1996 12:00:00 AM9/20/1996 12:00:00 AM9/3/1996 12:00:00 AMSpeedy Express68Scottish Longbreads10.0030.127.00007.45
Comércio MineiroAv. dos Lusíadas, 23Sao PauloSP05432-043BrazilCOMMIComércio MineiroAv. dos Lusíadas, 23Sao PauloSP05432-043BrazilLaura Callahan102908/27/1996 12:00:00 AM9/24/1996 12:00:00 AM9/3/1996 12:00:00 AMSpeedy Express5Chef Anton's Gumbo Mix17.00200340.000079.70
Comércio MineiroAv. dos Lusíadas, 23Sao PauloSP05432-043BrazilCOMMIComércio MineiroAv. dos Lusíadas, 23Sao PauloSP05432-043BrazilLaura Callahan102908/27/1996 12:00:00 AM9/24/1996 12:00:00 AM9/3/1996 12:00:00 AMSpeedy Express29Thüringer Rostbratwurst99.001501485.000079.70
Comércio MineiroAv. dos Lusíadas, 23Sao PauloSP05432-043BrazilCOMMIComércio MineiroAv. dos Lusíadas, 23Sao PauloSP05432-043BrazilLaura Callahan102908/27/1996 12:00:00 AM9/24/1996 12:00:00 AM9/3/1996 12:00:00 AMSpeedy Express49Maxilaku16.00150240.000079.70
Comércio MineiroAv. dos Lusíadas, 23Sao PauloSP05432-043BrazilCOMMIComércio MineiroAv. dos Lusíadas, 23Sao PauloSP05432-043BrazilLaura Callahan102908/27/1996 12:00:00 AM9/24/1996 12:00:00 AM9/3/1996 12:00:00 AMSpeedy Express77Original Frankfurter grüne Soße10.40100104.000079.70
LILA-SupermercadoCarrera 52 con Ave. Bolívar #65-98 Llano LargoBarquisimetoLara3508VenezuelaLILASLILA-SupermercadoCarrera 52 con Ave. Bolívar #65-98 Llano LargoBarquisimetoLara3508VenezuelaMichael Suyama102969/3/1996 12:00:00 AM10/1/1996 12:00:00 AM9/11/1996 12:00:00 AMSpeedy Express11Queso Cabrales16.80120201.60000.12
LILA-SupermercadoCarrera 52 con Ave. Bolívar #65-98 Llano LargoBarquisimetoLara3508VenezuelaLILASLILA-SupermercadoCarrera 52 con Ave. Bolívar #65-98 Llano LargoBarquisimetoLara3508VenezuelaMichael Suyama102969/3/1996 12:00:00 AM10/1/1996 12:00:00 AM9/11/1996 12:00:00 AMSpeedy Express16Pavlova13.90300417.00000.12
LILA-SupermercadoCarrera 52 con Ave. Bolívar #65-98 Llano LargoBarquisimetoLara3508VenezuelaLILASLILA-SupermercadoCarrera 52 con Ave. Bolívar #65-98 Llano LargoBarquisimetoLara3508VenezuelaMichael Suyama102969/3/1996 12:00:00 AM10/1/1996 12:00:00 AM9/11/1996 12:00:00 AMSpeedy Express69Gudbrandsdalsost28.80150432.00000.12
Hungry Owl All-Night Grocers8 Johnstown RoadCorkCo. Cork IrelandHUNGOHungry Owl All-Night Grocers8 Johnstown RoadCorkCo. Cork IrelandJanet Leverling103099/19/1996 12:00:00 AM10/17/1996 12:00:00 AM10/23/1996 12:00:00 AMSpeedy Express4Chef Anton's Cajun Seasoning17.60200352.000047.30
Hungry Owl All-Night Grocers8 Johnstown RoadCorkCo. Cork IrelandHUNGOHungry Owl All-Night Grocers8 Johnstown RoadCorkCo. Cork IrelandJanet Leverling103099/19/1996 12:00:00 AM10/17/1996 12:00:00 AM10/23/1996 12:00:00 AMSpeedy Express6Grandma's Boysenberry Spread20.00300600.000047.30
Hungry Owl All-Night Grocers8 Johnstown RoadCorkCo. Cork IrelandHUNGOHungry Owl All-Night Grocers8 Johnstown RoadCorkCo. Cork IrelandJanet Leverling103099/19/1996 12:00:00 AM10/17/1996 12:00:00 AM10/23/1996 12:00:00 AMSpeedy Express42Singaporean Hokkien Fried Mee11.202022.400047.30
Hungry Owl All-Night Grocers8 Johnstown RoadCorkCo. Cork IrelandHUNGOHungry Owl All-Night Grocers8 Johnstown RoadCorkCo. Cork IrelandJanet Leverling103099/19/1996 12:00:00 AM10/17/1996 12:00:00 AM10/23/1996 12:00:00 AMSpeedy Express43Ipoh Coffee36.80200736.000047.30
Page size:
select
 600 items in 12 pages



  • This example demonstrates Telerik RadGrid's view state optimization and performance mechanism. Disabling RadGrid's view state by setting the EnableViewState property to false will save the most important data to the page control state and will force a grid rebind on every postback.

    Typically RadGrid stores in ViewState only items/controls collection, not data source data. Sometimes though the page viewstate can grow too big and might significantly increase the page download time. You can control this behavior by setting the EnableViewState property to false if you do not wish the data for the controls in the grid to to be persisted in the view state. This means that the control will need to be rebound on every request: either by firing the NeedDataSource event or by going through an ASP.NET 2.x/3.x data source control. When having EnableViewState set to false, RadGrid will use the page control state to store only the absolutely necessary bits of data that preserve the current paging, sorting or selected state.

    Please take into account that some operations in Telerik RadGrid like data extraction through the ExtractValuesFromItem method, grouping, hierarchical views expand/collapse, custom edit forms (WebUserControl and FormTemplate) or filtering require that view state is enabled. Those features will not work if EnableViewState is set to false.

    Note that the grid state stored in the page viewstate is 16 times smaller when its EnableViewState property is set to false and we have 26 columns and 10 to 50 records in the control displayed at once (with scrolling enabled).
    How to store the grid viewstate in the Session or compress it using RadCompression you can find out from this and this article.

Source Code

C# VB.NET
Show code in new window Demo isolation steps
  • <%@ Page Language="c#" Inherits="Telerik.GridExamplesCSharp.Programming.ViewState.DefaultCS"
        CodeFile="DefaultCS.aspx.cs" %>

    <%@ Register TagPrefix="telerik" Namespace="Telerik.QuickStart" %>
    <%@ Register TagPrefix="telerik" TagName="Header" Src="~/Common/Header.ascx" %>
    <%@ Register TagPrefix="telerik" TagName="HeadTag" Src="~/Common/HeadTag.ascx" %>
    <%@ Register TagPrefix="telerik" TagName="Footer" Src="~/Common/Footer.ascx" %>
    <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/tr/xhtml11/DTD/xhtml11.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <telerik:HeadTag runat="server" ID="Headtag2"></telerik:HeadTag>
    </head>
    <body class="BODY">
        <form runat="server" id="mainForm" method="post">
        <telerik:Header runat="server" ID="Header1" NavigationLanguage="CS"></telerik:Header>
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server" />
        <!-- content start -->
        <telerik:ConfiguratorPanel runat="server" Expanded="true" ID="ConfigurationPanel1">
            <asp:Label ID="Label1" runat="server" Style="font-weight: bold; color: green">Label</asp:Label>
            <br />
            <br />
    <asp:CheckBox ID="CheckBox1" AutoPostBack="True" runat="server" Text="RadGrid's ViewState on/off"
    OnCheckedChanged="CheckBox1_CheckedChanged" />

        </telerik:ConfiguratorPanel>
        <br />
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="RadGrid1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
        <telerik:RadGrid ID="RadGrid1" DataSourceID="SqlDataSource1" runat="server" AllowPaging="True"
            AllowSorting="True" PageSize="50" Width="95%" ShowStatusBar="true">
            <HeaderStyle Width="150px" />
            <ClientSettings>
                <Scrolling AllowScroll="true" UseStaticHeaders="true" />
            </ClientSettings>
            <PagerStyle Mode="NextPrevAndNumeric" />
        </telerik:RadGrid>
        <asp:SqlDataSource ID="SqlDataSource1" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
            ProviderName="System.Data.SqlClient" SelectCommand="SELECT TOP 600 * FROM Invoices"
            runat="server"></asp:SqlDataSource>
        <br />
        <br />
        <!-- content end -->
        <telerik:Footer runat="server" ID="Footer1"></telerik:Footer>
        </form>
    </body>
    </html>

Get more than expected!

Take your time to truly experience the power of RadControls for ASP.NET AJAX with a free 60-day trial backed up by Telerik’s unlimited dedicated support.

Download your RadControls for ASP.NET AJAX trial and jumpstart your development with the available Getting Started resources.

If you have any questions, do not hesitate to contact us at sales@telerik.com.

Copyright 2002-2012 © Telerik. All right reserved
Telerik Inc, 201 Jones Rd, Waltham, MA 02451