Datagrid vanishing and taking all my nested controls with it.

G

Guest

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

intrader

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!
 
G

Guest

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.
 

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,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top