By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,918 Members | 1,662 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,918 IT Pros & Developers. It's quick & easy.

Datagrid vanishing and taking all my nested controls with it.

P: n/a
I've got a datagrid with some nested controls, created at design-time. The
controls themselves have no databound values.

After a few other operations on the page (selecting a few parameters, etc),
a button is clicked and the databind occurs. This part works fine. It
retreives the 4-10 rows it needs and using the itemdatabound formats
everything nicely.

What I intend to do then, is after the user has gone through the nested
controls and entered the values they want for each line item, they click a
button to bulk-submit them. This is where it all goes wrong. On the
postback, the datagrid.items.count is 0, there's no controls collection
anymore and the whole grid vanishes. Obviously, I can't get the values
anymore.

The debugger and the designer both report that viewstate is on for the
datagrid, for the panel containng the datagrid, and for the page. Is there
any conceivable reason the contents of the datagrid would suddenly disappear?

If I rebind, then of course I get the whole thing back but all my controls
get reset and I no longer have the user-submitted values. By all accounts,
all I should have to do after the user hits submit is iterate through the
datagriditems and call the appropriate findcontrol...but if the items keeps
resetting to empty, there's nothing there for me...

Any ideas? Thanks much if you've got 'em...
Nov 19 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On Fri, 24 Jun 2005 10:43:12 -0700, nulldevice wrote:
I've got a datagrid with some nested controls, created at design-time. The
controls themselves have no databound values.

After a few other operations on the page (selecting a few parameters, etc),
a button is clicked and the databind occurs. This part works fine. It
retreives the 4-10 rows it needs and using the itemdatabound formats
everything nicely.

What I intend to do then, is after the user has gone through the nested
controls and entered the values they want for each line item, they click a
button to bulk-submit them. This is where it all goes wrong. On the
postback, the datagrid.items.count is 0, there's no controls collection
anymore and the whole grid vanishes. Obviously, I can't get the values
anymore.

The debugger and the designer both report that viewstate is on for the
datagrid, for the panel containng the datagrid, and for the page. Is there
any conceivable reason the contents of the datagrid would suddenly disappear?

If I rebind, then of course I get the whole thing back but all my controls
get reset and I no longer have the user-submitted values. By all accounts,
all I should have to do after the user hits submit is iterate through the
datagriditems and call the appropriate findcontrol...but if the items keeps
resetting to empty, there's nothing there for me...

Any ideas? Thanks much if you've got 'em...

I think that on postback the data from for the datagrid is empty and
therefore your datagrid will be empty. Examine what happens before the
rebind. That path must have data!

Nov 19 '05 #2

P: n/a
Well, I got it to work this morning, and the solution is entirely baffling to
me.

On this page were some other controls that were being populated dynamically.
a specific type of literal control we developed. on page Init, there's a
function that walks the controls tree and does a typeof on any control it
finds, and when it hits one, it does the mojo it needs to associate those
controls with the data they're supposed to be associated with.

Whenever the "typeof" hit the datagrid in the init, it'd drop all its
viewstate information. When this happened, grid.datasource became nothing
and the grid would disappear. When I removed the control-tree walk, he
grids stopped disappearing. This was also happening for asp tables. I have
not tried datalists or repeaters yet.

So I put in a workaround, but it's very perplexing that a typeof() would
cause my grids to freak out.

"intrader" wrote:
I think that on postback the data from for the datagrid is empty and
therefore your datagrid will be empty. Examine what happens before the
rebind. That path must have data!

Nov 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.