views:

306

answers:

2

I am cleaning up my viewsource and want to use the EnableViewState. I am using a gridview that has the following.

<asp:GridView ID="GridView1" runat="server" AlternatingRowStyle-BackColor="#ECECEC"
            AllowSorting="true" AutoGenerateColumns="False" OnRowDataBound="gridvw_RowDataBound"
            ShowFooter="True" OnSorting="gridvw1_DataSort" Caption="New Shoes"
            CssClass="blueBord" HeaderStyle-ForeColor="White" OnPageIndexChanging="gridvw_PageIndexChanging"
            OnRowCreated="gridvw_RowCreated" AllowPaging="True" PageSize="50" EnableViewState="false">

What controls can EnableViewState = true/false affect on a GridView?

A: 

It will affect all controls in the GridView. As to which controls use ViewState to persist values that would be difficult to say without knowing what your GridView looks like.

Andrew Hare
hope that helps...
A: 

From MSDN:

The GridView control is re-created on postback based on the information that is stored in ViewState. If the GridView control includes a TemplateField or a CommandField with the CausesValidation property set to true, then the EnableViewState property must also be set to true to ensure that concurrent data operations, such as updates and deletes, apply to the appropriate row.

Paging and column sorting info will be stored in control state and won't be affected by the change.

foson