SortCommand, PageIndexChanged, ItemCommand events of datagrid

Posted on 2005-05-01
Last Modified: 2009-12-16
Is it necessary to set the EnableViewState of datagrid as true to implement ItemCommand, SortCommand and PageIndexChanged event of datagrid. If not then how can i get these events working even after setting the EnableViewState property of datagrid as false. Actually in my grid, if i set EnableViewState as true then events are working fine but not otherwise. Could anybody give any suggestions regarding this???

Thanks & Regards
Question by:sachitjain
    LVL 18

    Expert Comment

    ViewState holds current state of Web Controls. If you set it to false ViewState will have no information regarding the DataGrid displayed. ex. the datagrid would not be able to maintain current-page-index by itself and that may be reason why the PageIndexChanged event handler did not fire.

    So, if you are taking help of inbuilt paging, sorting or you want some datagrid inforamtin in PostBack you'll need EnableViewState=True for Datagrid..

    You can read some more about this here:

    LVL 33

    Accepted Solution

    Put the DataGrid on a diet if you are concerned about the viewstate!
    LVL 12

    Author Comment

    Thanks raterus

    The reference given by u is great.


    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Suggested Solutions

    Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
    IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…
    This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now