Datagrid invisible

D

DJ Dev

Hi All,
I have 2 datagrids which are generated in runtime based on values
selected by user from a dropdown. I have a template column in the
datagrid with checkboxes. I want the user to select some value in
checkbox and based on that query the db to display some stuff. Now the
problem is that if I set the checkboxes to AutoPostback = True, the
datagrid disappears. I cant make them a part of the Page_Load event
since they r based on the value from the dropdownlist.
What can I do? Is there a ViewState property or something I can use?

Please help. :(

Thanks.
 
C

Corey O'Mara

Hello DJ,

The item is actually stored in Viewstate, but it doesn't show up on the page
since the control is built at runtime! I know it sounds like it won't work,
but you want to go ahead and instantiate those datagrids in the page_load
event even on a post back. If it's a postback, viewstate will take over from
there and you'll have your fully populated datagrids just like you would if
you had built the datagrids at design time. Make sure you don't initialize
your datagrids, just instantiate and add to the controls collection.
Initialization should only happen if it's not a postback. It's crazy, but it
works!

Corey O'Mara
MCSD.NET, MCT
 

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,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top