PageIndexChanged not firing in DataGrid if EnableViewState is false
-
Hi, I want EnableViewState = false in order to optimize the end output page but when i turn it off, my pageing functionality no longer works mainly the PageIndexChanged event no longer fires, how do you handle this with enable view state as false? I have tried every thing possible to make it work but it is not working. I refered few forums in which people were facing similar problems but no one was able to provide some concrete solution for the same. Please refer the below links where people have faced similar problems but the solution provided is not reliable: http://www.west-wind.com/WebLog/posts/211.aspx http://www.velocityreviews.com/forums/t67338-pageindexchanged-not-firing-in-datagrid.html I've tried explicit event hookup but still it did'nt work. I know if we call the data generation method before the page change method it will work but in this case the data generation mehtod will be called twice first before the page change method and second in the page change method, this will result in huge performance degradation and i want to avoid it. Let me know if it is a genuine bug in ASP .NET or there is some way out to this problem. An early reply will be really helpfull. thanks!
-
Hi, I want EnableViewState = false in order to optimize the end output page but when i turn it off, my pageing functionality no longer works mainly the PageIndexChanged event no longer fires, how do you handle this with enable view state as false? I have tried every thing possible to make it work but it is not working. I refered few forums in which people were facing similar problems but no one was able to provide some concrete solution for the same. Please refer the below links where people have faced similar problems but the solution provided is not reliable: http://www.west-wind.com/WebLog/posts/211.aspx http://www.velocityreviews.com/forums/t67338-pageindexchanged-not-firing-in-datagrid.html I've tried explicit event hookup but still it did'nt work. I know if we call the data generation method before the page change method it will work but in this case the data generation mehtod will be called twice first before the page change method and second in the page change method, this will result in huge performance degradation and i want to avoid it. Let me know if it is a genuine bug in ASP .NET or there is some way out to this problem. An early reply will be really helpfull. thanks!
Well of course it won't work if EnableViewState = False - how can it? if you want to minimise the size of viewstate on a page where it is needed, then you must disable it (set to false) at the individual control level, not page level (obviously only for those controls that don't need to post back their state...) Fred
-
Well of course it won't work if EnableViewState = False - how can it? if you want to minimise the size of viewstate on a page where it is needed, then you must disable it (set to false) at the individual control level, not page level (obviously only for those controls that don't need to post back their state...) Fred
Thanks for your reply, but it is practically not possible for me to keep enableviewstate true since there are huge reports. Hence for my case i have to keep it false. Is there any other way out and is it a bug in ASP.NET Thanks!
-
Thanks for your reply, but it is practically not possible for me to keep enableviewstate true since there are huge reports. Hence for my case i have to keep it false. Is there any other way out and is it a bug in ASP.NET Thanks!
No, it'a not a bug - it's by reading the viewstate that asp.net can perform the paging; if you turn it off, it has no way of knowing what page you are on. If you really want to turn it off (though if you are displaying that much "huge" information on the page I'd suggest you look again at this: perhaps links to the individual reports would be better?) you will have to "fake" your own paging instead of relying on the datagrid's inbuilt functionality. Only read and display the first 10 (?) records; find out how many there actually are and dynamically write links to each set of 10... each link will cause the page to reload pulling only the required records (bit more coding there for you to work out!), and you will also have to re-calculate and re-write your page links again each time....
-
Hi, I want EnableViewState = false in order to optimize the end output page but when i turn it off, my pageing functionality no longer works mainly the PageIndexChanged event no longer fires, how do you handle this with enable view state as false? I have tried every thing possible to make it work but it is not working. I refered few forums in which people were facing similar problems but no one was able to provide some concrete solution for the same. Please refer the below links where people have faced similar problems but the solution provided is not reliable: http://www.west-wind.com/WebLog/posts/211.aspx http://www.velocityreviews.com/forums/t67338-pageindexchanged-not-firing-in-datagrid.html I've tried explicit event hookup but still it did'nt work. I know if we call the data generation method before the page change method it will work but in this case the data generation mehtod will be called twice first before the page change method and second in the page change method, this will result in huge performance degradation and i want to avoid it. Let me know if it is a genuine bug in ASP .NET or there is some way out to this problem. An early reply will be really helpfull. thanks!
-
I am using ASP.NET 2.0 Regards, Anees
-
No, it'a not a bug - it's by reading the viewstate that asp.net can perform the paging; if you turn it off, it has no way of knowing what page you are on. If you really want to turn it off (though if you are displaying that much "huge" information on the page I'd suggest you look again at this: perhaps links to the individual reports would be better?) you will have to "fake" your own paging instead of relying on the datagrid's inbuilt functionality. Only read and display the first 10 (?) records; find out how many there actually are and dynamically write links to each set of 10... each link will cause the page to reload pulling only the required records (bit more coding there for you to work out!), and you will also have to re-calculate and re-write your page links again each time....
Thanks Fred. I will work on it. Regards, Anees
-
I am using ASP.NET 2.0 Regards, Anees
Then it really may be a bug (bad design), such a thing could be in ControlState. Why are you using DataGrid anyway, when there is GridView?
[My Blog]
"Visual studio desperately needs some performance improvements. It is sometimes almost as slow as eclipse." - Rüdiger Klaehn
"Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe -
Hi, I want EnableViewState = false in order to optimize the end output page but when i turn it off, my pageing functionality no longer works mainly the PageIndexChanged event no longer fires, how do you handle this with enable view state as false? I have tried every thing possible to make it work but it is not working. I refered few forums in which people were facing similar problems but no one was able to provide some concrete solution for the same. Please refer the below links where people have faced similar problems but the solution provided is not reliable: http://www.west-wind.com/WebLog/posts/211.aspx http://www.velocityreviews.com/forums/t67338-pageindexchanged-not-firing-in-datagrid.html I've tried explicit event hookup but still it did'nt work. I know if we call the data generation method before the page change method it will work but in this case the data generation mehtod will be called twice first before the page change method and second in the page change method, this will result in huge performance degradation and i want to avoid it. Let me know if it is a genuine bug in ASP .NET or there is some way out to this problem. An early reply will be really helpfull. thanks!
Please try disabling the viewstate for innercontrols rather than for DataGrid as a whole.