Hello folks,

I need to create a html table dynamically, so I used HtmlTable and HtmlTableCell ... but I need to put inside a HtmlTableCell another HtmlTable object, so the structure will be:

HtmlTable
|
---HtmlTableRow
|
---HtmlTableCell
|
---HtmlTable

I hope someone could help me

Thanks

Omar

If your container table is fixed & you know in which cell you want to put the dynamic conents then i hope literal is best ease to maintain.

<HtmlTable>
<HtmlTableRow>
<HtmlTableCell>
<HtmlTable>
<HtmlTableRow>
<HtmlTableCell>
<HtmlTableCell>
<HtmlTableRow>
<HtmlTable>
<HtmlTableCell>
<HtmlTableRow>
<HtmlTable>

if its not what you want so try to explain your self again

Well... i forgot to say I want to do it, in the codebehind... not in the aspx file...

Well... i forgot to say I want to do it, in the codebehind... not in the aspx file...

What? from the server side?

What? from the server side?

Yes... server side... I've been doing in a simpler maner with

For Each obj As bNoticiasBE In oListaNoticiasBE

            tdvcNotTitular = New System.Web.UI.HtmlControls.HtmlTableCell
            trvcNotTitular = New System.Web.UI.HtmlControls.HtmlTableRow
            tddtNotFecha = New System.Web.UI.HtmlControls.HtmlTableCell
            trdtNotFecha = New System.Web.UI.HtmlControls.HtmlTableRow
            tdvcNotSumilla = New System.Web.UI.HtmlControls.HtmlTableCell
            trvcNotSumilla = New System.Web.UI.HtmlControls.HtmlTableRow

            'avcNotTitular()
            tdvcNotTitular.InnerHtml = "<div align=""justify"" class=""pequeno1""><a href=""wfNoticiasDetalle.aspx?tipo=" + ViewState.Item("pagina.tipo").ToString + "&id=" + obj.inNotCodigo.ToString + """><strong>" + obj.vcNotTitular.ToString + "</strong></a></div>"
            'tdvcNotTitular.InnerText = obj.vcNotTitular
            trvcNotTitular.Cells.Add(tdvcNotTitular)
            tblListaNoticias.Rows.Add(trvcNotTitular)

            tddtNotFecha.InnerHtml = "<strong><font color=""#666666"">" + obj.dtNotFechaNoticia.ToShortDateString + "</font></strong>"
            'tddtNotFecha.InnerText = obj.dtNotFechaNoticia.ToShortDateString
            trdtNotFecha.Cells.Add(tddtNotFecha)
            tblListaNoticias.Rows.Add(trdtNotFecha)

            tdvcNotSumilla.InnerHtml = "<div align=""justify"">" + obj.vcNotSumilla.ToString + "</div>"
            'tdvcNotSumilla.InnerText = obj.vcNotSumilla
            trvcNotSumilla.Cells.Add(tdvcNotSumilla)
            tblListaNoticias.Rows.Add(trvcNotSumilla)

        Next

But I don't know how insert a table, If it can be done...

Next time try to explain your self properly from the begining...;

I will post it in C# code but its not a problem to convert it to VB.

Lets say that you have a HtmlTable ready with everything inside (all the rows and cells that you want, in my code its name is "tbl2".
And the cell that we want to add the table to call "tbl1Cell"
So here is the code:

HtmlTable tbl2 = new HtmlTable();

        HtmlTableCell tbl1Cell = new HtmlTableCell();

        tbl1Cell.Controls.Add(tbl2);

Now convert it to VB

Next time try to explain your self properly from the begining...;

I will post it in C# code but its not a problem to convert it to VB.

Lets say that you have a HtmlTable ready with everything inside (all the rows and cells that you want, in my code its name is "tbl2".
And the cell that we want to add the table to call "tbl1Cell"
So here is the code:

HtmlTable tbl2 = new HtmlTable();

        HtmlTableCell tbl1Cell = new HtmlTableCell();

        tbl1Cell.Controls.Add(tbl2);

Now convert it to VB

Thanks, and I'll try to be more accurate on my explaining.

So, as far I can see, the trick is to construct the object before I add it, I don't know how could I miss it...

Thanks again!...

This question has already been answered. Start a new discussion instead.