Controlling the ViewState of children controls

M

Manuj Aggarwal

I have a custom Grid control which inherits from ASP.NET DataGrid control.
In this custom control I also have some other server controls e.g. a drop
down list to manage paging for the grid.
I want to disable viewstate on main Grid but I do want to maintain ViewState
for child controls like pager drop-down which I need to manage the data
rendered in the grid.
Is this possible? If yes, any sample code will be much appreciated.

TIA

Thanks
Manuj
 
V

Victor Garcia Aprea [MVP]

Hi Manuj,

Are you simply inheriting from DataGrid and adding childs or are you
creating a brand new composite control with a DataGrid and other controls as
childs? In the second case it should be a matter of just setting the grid's
EnableViewState property to false and keep the others to true. Now if you're
dealing with the first case, you will need to override the LoadViewState and
SaveViewState methods of your DataGrid-derived type to load/save only the
state you're interested in (for the dropdowns in your case).

--
Victor Garcia Aprea
Microsoft MVP | ASP.NET
Looking for insights on ASP.NET? Read my blog:
http://obies.com/vga/blog.aspx
To contact me remove 'NOSPAM'. Please post all questions to the newsgroup
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top