ViewState Probelm in GridView
-
Hi ... I have bind one gridview with 2 different Method. Total 250 records are there. In first Method I fetch all 250 record in dataset and bind in Gridview with EnablePaging = True. Mean while i am saving this dataset in view state.Here grid view show only 10 records per page. So now when i see page source it display size of view state around 28 kb. In second method I fetch page wise record from DB. Means for 1st page i am fetching 10 record. and storing this dataset(with only 10 records) in view state for sorting. Now when i see page source it display the same size in view state. Is there any other technic to reduce view state?? and why happen like this in first method it fetch 250 records and i am storing it in view state while in second method i fetch only 10 records and storing in view state still view state size remain same.
-
Hi ... I have bind one gridview with 2 different Method. Total 250 records are there. In first Method I fetch all 250 record in dataset and bind in Gridview with EnablePaging = True. Mean while i am saving this dataset in view state.Here grid view show only 10 records per page. So now when i see page source it display size of view state around 28 kb. In second method I fetch page wise record from DB. Means for 1st page i am fetching 10 record. and storing this dataset(with only 10 records) in view state for sorting. Now when i see page source it display the same size in view state. Is there any other technic to reduce view state?? and why happen like this in first method it fetch 250 records and i am storing it in view state while in second method i fetch only 10 records and storing in view state still view state size remain same.
Hard to say without seeing the code. What happens if you disable viewstate in the gridview, how much does it drop by then ? That will tell you how much of the viewstate is your data in the gridview
Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
-
Hard to say without seeing the code. What happens if you disable viewstate in the gridview, how much does it drop by then ? That will tell you how much of the viewstate is your data in the gridview
Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
Hi christian, i have already disable view state for some of the column in grid view. After binding gridview i am reading one by one row and each and every row i am go thorugh cells one by one and disable this cells enableviewState property to false. in this way if i am doing than it is reduce viewstate from 32kb to 27 kb. but problem is that first method fetch 250 records and i am storing this records in viewstate for later paging & sorting & in second method i am fetch first 10 records and storing this record in view state for later sorting only. when i click second number in paging than i am fetching record from 11 to 20 and storing this one to view state. just my problem is to when i see view source of aspx page at that time in both the case it showing me viewstate size as 27 kb only.why it is not reduced...???? In first case i have store 250 rows while in second one i have stored 10 rows in view state.. Regards, Hemant Patel.
-
Hi christian, i have already disable view state for some of the column in grid view. After binding gridview i am reading one by one row and each and every row i am go thorugh cells one by one and disable this cells enableviewState property to false. in this way if i am doing than it is reduce viewstate from 32kb to 27 kb. but problem is that first method fetch 250 records and i am storing this records in viewstate for later paging & sorting & in second method i am fetch first 10 records and storing this record in view state for later sorting only. when i click second number in paging than i am fetching record from 11 to 20 and storing this one to view state. just my problem is to when i see view source of aspx page at that time in both the case it showing me viewstate size as 27 kb only.why it is not reduced...???? In first case i have store 250 rows while in second one i have stored 10 rows in view state.. Regards, Hemant Patel.
Asking me the same question again is not helpful. Did you disable viewstate for the entire grid ? If you did, then any viewstate you're seeing, is from other things on your page.
Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.