Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > ViewState problem

Reply
Thread Tools

ViewState problem

 
 
Al Cadalzo
Guest
Posts: n/a
 
      03-03-2004

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


 
Reply With Quote
 
 
 
 
Marshal Antony
Guest
Posts: n/a
 
      03-04-2004
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
>
>



 
Reply With Quote
 
 
 
 
Al Cadalzo
Guest
Posts: n/a
 
      03-04-2004
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
> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problems with ViewState: "function 'ViewState.get_Item' evaluated and returned null" Steph ASP .Net 2 05-11-2011 02:35 PM
Errors: Failed to load viewstate. & Validation of viewstate MAC failed. sck10 ASP .Net 6 09-01-2006 05:59 PM
Loading usercontrols, viewstate problem, slighly different from all others "viewstate uc problems" please help... ujjc001 ASP .Net 0 07-27-2005 01:52 PM
Viewstate errors... how do I get viewstate working? mark ASP .Net Building Controls 0 02-20-2004 02:17 PM
Corrupted ViewState (Yes, another issue concerning viewstate) Ben Rush ASP .Net 2 12-05-2003 04:17 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57