ViewState problem

Discussion in 'ASP .Net Datagrid Control' started by Al Cadalzo, Mar 3, 2004.

  1. Al Cadalzo

    Al Cadalzo Guest

    I am having a performance problem with a datagrid control that has a large
    viewstate due to several columns containing very long href's in the
    hyperlinks. I need the enableviewstate = true to enable paging
    (AllowPaging=true,PageSize=50). If I don't enableViewState on the DataGrid
    then my PageIndex_Changed handler doesn't get executed. I retrieve fresh
    data each time I postback, so I don't actually need the datagrid's items in
    the viewState, all I need is the page number. Is there a way that I can
    use ViewState just to enable the PageIndex_Changed handler to work, without
    passing the dataGrid's dataitems in ViewState? Maybe someone has written
    their own code to enabling paging so that the DataGrid's viewstate can be
    turned off?

    Thanks,
    Al
     
    Al Cadalzo, Mar 3, 2004
    #1
    1. Advertising

  2. Hi,
    You can disable viewstate for each item in your datagrid.If you disable
    viewstate in DataGridItems only,paging and
    post back will work.You can do so by disabling view state of datagrid items
    in the PreRender event handler.
    private void Page_PreRender(object sender,EventArgs e){
    foreach(DataGridItem dg in DataGrid1.Items){

    dg.EnableViewState=false;

    }

    }
    Hope this helps.
    Regards,
    Marshal Antony
    ..NET Developer
    http://www.dotnetmarshal.com



    "Al Cadalzo" <> wrote in message
    news:...
    >
    > I am having a performance problem with a datagrid control that has a large
    > viewstate due to several columns containing very long href's in the
    > hyperlinks. I need the enableviewstate = true to enable paging
    > (AllowPaging=true,PageSize=50). If I don't enableViewState on the

    DataGrid
    > then my PageIndex_Changed handler doesn't get executed. I retrieve fresh
    > data each time I postback, so I don't actually need the datagrid's items

    in
    > the viewState, all I need is the page number. Is there a way that I can
    > use ViewState just to enable the PageIndex_Changed handler to work,

    without
    > passing the dataGrid's dataitems in ViewState? Maybe someone has written
    > their own code to enabling paging so that the DataGrid's viewstate can be
    > turned off?
    >
    > Thanks,
    > Al
    >
    >
     
    Marshal Antony, Mar 4, 2004
    #2
    1. Advertising

  3. Al Cadalzo

    Al Cadalzo Guest

    Marshal,

    I had no idea you could turn it off on individual datagrid items. At first
    the paging didn't work, so I added an IF ItemType == ListItemType.Item
    dg.EnableViewState=false;

    and then the paging worked again. It improved the performance greatly.

    Many thanks,
    Al

    "Marshal Antony" <> wrote in message
    news:...
    > Hi,
    > You can disable viewstate for each item in your datagrid.If you disable
    > viewstate in DataGridItems only,paging and
    > post back will work.You can do so by disabling view state of datagrid

    items
    > in the PreRender event handler.
    > private void Page_PreRender(object sender,EventArgs e){
    > foreach(DataGridItem dg in DataGrid1.Items){
    >
    > dg.EnableViewState=false;
    >
    > }
    >
    > }
    > Hope this helps.
    > Regards,
    > Marshal Antony
    > .NET Developer
    > http://www.dotnetmarshal.com
    >
    >
    >
    > "Al Cadalzo" <> wrote in message
    > news:...
    > >
    > > I am having a performance problem with a datagrid control that has a

    large
    > > viewstate due to several columns containing very long href's in the
    > > hyperlinks. I need the enableviewstate = true to enable paging
    > > (AllowPaging=true,PageSize=50). If I don't enableViewState on the

    > DataGrid
    > > then my PageIndex_Changed handler doesn't get executed. I retrieve

    fresh
    > > data each time I postback, so I don't actually need the datagrid's items

    > in
    > > the viewState, all I need is the page number. Is there a way that I

    can
    > > use ViewState just to enable the PageIndex_Changed handler to work,

    > without
    > > passing the dataGrid's dataitems in ViewState? Maybe someone has

    written
    > > their own code to enabling paging so that the DataGrid's viewstate can

    be
    > > turned off?
    > >
    > > Thanks,
    > > Al
    > >
    > >

    >
    >
     
    Al Cadalzo, Mar 4, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ben Rush
    Replies:
    2
    Views:
    567
    Ben Rush
    Dec 5, 2003
  2. Steph
    Replies:
    2
    Views:
    1,695
    heislord5
    May 11, 2011
  3. ujjc001
    Replies:
    0
    Views:
    1,397
    ujjc001
    Jul 27, 2005
  4. sck10
    Replies:
    6
    Views:
    955
    sck10
    Sep 1, 2006
  5. mark

    Viewstate errors... how do I get viewstate working?

    mark, Feb 20, 2004, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    299
Loading...

Share This Page