Thursday, December 16, 2010

.NET - GridView EnableViewState


Introduction:

When a grid view is being bound with data on every postback, common practice is to set Enable View State property of the Grid view to false

Description:

If a grid view has some code written in Row Command and Row Deleting event it will not be executed as these events are not fired when view state is disabled. The best thing to do is  if you don’t have anything defined in row command or row deleting event go on and disable the  view state.


Rounded Rectangle: <asp:GridView ID="GridView1" runat="server" EnableViewState="False">
</asp:GridView>