Click here to Skip to main content
15,904,351 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
--When shall i make the EnableViewState property of gridview to be true/ False ? Kindly help.
Posted

1 solution

If you want to maintain the state of your gridview in your page.

i.e. if you want to use that datatable with which you are binding your gridview somewhere else in your code.. than you can save the datatable in viewstate and can get it somewhere else.

in this way that current state of your gridview is persisted in viewstate for further use.

So having a gridview with enabled view state is gud idea to handle the persistance of data.

hope that will help.

Further about viewstate you can visit.

[^]

[^]

[^]
 
Share this answer
 
Comments
anurag19289 24-Oct-13 6:12am    
Hi Vick-So what i have understood

1)when we are editing ,updating or cancelling in gridview...obviously we are binding the grid again...

So in this case we cant make the enable view state propery to be false

doubt : what happens if we make it false ?

2)if a grid is binding normally. we are not editing/updating/cancelling. In this case it would be wise to make it false

I have read in the article you have provided. It suggests that where ever its not required we should disable it.

So if in the second case is it like if its enabled ...then the hidden field value in view source increases....leading to performance issue


kindly correct me if i am wrong
VICK 24-Oct-13 6:16am    
I think following article can lead you to the answers of your questions

http://msdn.microsoft.com/en-us/library/ms178472(v=vs.100).aspx

OR this one

http://msdn.microsoft.com/en-us/library/bb386448.aspx


anurag19289 24-Oct-13 6:35am    
Ok thanks for the help VICK...
i will do more analysis on this..
VICK 24-Oct-13 6:37am    
Welcome always... :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900