Datagrid invisible

  • Thread starter Thread starter DJ Dev
  • Start date Start date
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.
 
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
 
Back
Top