views:

1091

answers:

3

I have a page designed with many HTML Tables which are hidden or displayed based on what needs to be shown at the time. There are various ASP.NET standard web controls within these tables, usually check boxes, radio button lists, text entry boxes, labels, etc. and all work just fine.

I am trying to put a DataGrid within one of the rows (under a tag) and get the error message:

Parser Error Message: System.Web.UI.HtmlControls.HtmlTableCellCollection must have items of type 'System.Web.UI.HtmlControls.HtmlTableCell'. 'MIIRS:DATAGRID' is of type 'MIIRS.WebControls.DataGrid'.

(MIIRS DataGrid inherits the DataGrid class and adds minor functionality to it, if you're wondering)

I know I can redesign the page to put the DataGrid outside of a table, but if I can find a way to avoid this that's what I want to do.

So my question is: is there any way to make the HtmlTable accept a DataGrid, GridView or similar object nested in it? And would changing to an asp table tag make it acceptable? Or any other creative solutions to minimize having to split up tables, or cannibalize my system the way I have it? :)

+1  A: 

I have found one possible answer to the question. Using tags and CSS one can hide and display areas of HTML, so while I couldn't get the Datagrid IN the table, I could put it outside of a table and simply display or hide it. When this is placed "in the middle" of a table it requires splitting the table up into two parts (before and after).

This is the best way I've found so far to keep things looking the same on the page. I am still wondering why certain controls aren't able to be put into an HtmlTable row though.

n2009
A: 

You might want to take a look at this walkthrough...

http://www.codeproject.com/KB/webforms/EditNestedDataGrid.aspx

Mikey
that certainly looks like one solution, but too much complexity for what i need to do! Instead of hiding and showing the tables I just hide and show individual <div>s using CSS and it works better, and that way I can have items outside of the HtmlTable structure that show or disappear along with it.
n2009
+2  A: 

Nested tables AND datagrids? oh man you probably don't need that much complexity and I'm sure you could find a simplier way to accomplish your UI goal.

either that or.. run away, run fast and hard! RUN UNTIL YOUR HANDS SHAKE

BPAndrew
+1 for comedy, and the sane advise to avoid nested datagrids.
Jon Tackabury
no, the tables aren't nested. The datagrid was supposed to be in one of the rows (to be part of the page layout). I was able to put it outside of the table structure however, and just show or hide it (I think I put it within a div)
n2009
I think you'll have a better shot going that way - dynamic controls in .NET are nothing but trouble especially when you start posting back. render everything out and use js/cs to manipulate it. if you want to get leaner than that, use AJAX to load the parts you dont want to show right away
BPAndrew