how to add a dynamic table in a panel at runtime in c#

I am creating html formatted tables at runtime with uniques ID's using the following code

PopDefinition table = new PopDefinition();
                StringBuilder html = new StringBuilder();
                html.Append(string.Format("<table runat=" + "server" + " id={0}subtable{1}{0} class={0}gridview_table{0}>", _dq, " " + Convert.ToString(_laid[i]) + Convert.ToString(j + 1)));
                _headerlist.Clear();
                html.Append(createheader(table.headers, "subtable"));
                DataRow[] dr = _mainset.Tables[0].Select();
                html.Append(createbody(table.columns, dr, "subtable"));
                html.Append(createfooter(table.footers, "subtable"));
                html.Append("</table>");

and get html as attached in the code part. how can I store these tables in some sort of a control like panel control and make the ones visible which i need.
Thanks,



<table runat=server id="subtable 82" class="gridview_table"><tr class="gridview_altrow"><th rowspan="" colspan="">LA Areas</th><th id="Th56" laid="PGS" class="yearcode" term="subtable">PGS</th><th>&nbsp</th><th rowspan="" colspan="">Request Totals</th></tr><tr><th id="Th57" laid="8-1" class="area" term="subtable">Bute</th><td><input type="text" value ="0" id="Text120" maxlength = "5"  onblur="checkvalue(this.id); dosum(this.id, new Array('subjectrequesttotals','fPGS_0'));"  /></td><th>&nbsp</th><td><input type="text" value="0" id="Text121" maxlength="5" thefuntion="sum(row)" readonly = "true" class = "noenter"/></td></tr><tr class="gridview_altrow"><th id="Th58" laid="8-2" class="area" term="subtable">Cowal</th><td><input type="text" value ="0" id="Text122" maxlength = "5"  onblur="checkvalue(this.id); dosum(this.id, new Array('subjectrequesttotals','fPGS_0'));"  /></td><th>&nbsp</th><td><input type="text" value="0" id="Text123" maxlength="5" thefuntion="sum(row)" readonly = "true" class = "noenter"/></td></tr><tr><th id="Th59" laid="8-3" class="area" term="subtable">Helensburgh & Lomond</th><td><input type="text" value ="0" id="Text124" maxlength = "5"  onblur="checkvalue(this.id); dosum(this.id, new Array('subjectrequesttotals','fPGS_0'));"  /></td><th>&nbsp</th><td><input type="text" value="0" id="Text125" maxlength="5" thefuntion="sum(row)" readonly = "true" class = "noenter"/></td></tr><tr class="gridview_altrow"><th id="Th60" laid="8-4" class="area" term="subtable">Islay and Jura</th><td><input type="text" value ="0" id="Text126" maxlength = "5"  onblur="checkvalue(this.id); dosum(this.id, new Array('subjectrequesttotals','fPGS_0'));"  /></td><th>&nbsp</th><td><input type="text" value="0" id="Text127" maxlength="5" thefuntion="sum(row)" readonly = "true" class = "noenter"/></td></tr><tr><th id="Th61" laid="8-5" class="area" term="subtable">Kintyre North</th><td><input type="text" value ="0" id="Text128" maxlength = "5"  onblur="checkvalue(this.id); dosum(this.id, new Array('subjectrequesttotals','fPGS_0'));"  /></td><th>&nbsp</th><td><input type="text" value="0" id="Text129" maxlength="5" thefuntion="sum(row)" readonly = "true" class = "noenter"/></td></tr><tr class="gridview_altrow"><th id="Th62" laid="8-6" class="area" term="subtable">Kintyre South</th><td><input type="text" value ="0" id="Text130" maxlength = "5"  onblur="checkvalue(this.id); dosum(this.id, new Array('subjectrequesttotals','fPGS_0'));"  /></td><th>&nbsp</th><td><input type="text" value="0" id="Text131" maxlength="5" thefuntion="sum(row)" readonly = "true" class = "noenter"/></td></tr><tr><th id="Th63" laid="8-7" class="area" term="subtable">Lorn, Coll & Colonsay</th><td><input type="text" value ="0" id="Text132" maxlength = "5"  onblur="checkvalue(this.id); dosum(this.id, new Array('subjectrequesttotals','fPGS_0'));"  /></td><th>&nbsp</th><td><input type="text" value="0" id="Text133" maxlength="5" thefuntion="sum(row)" readonly = "true" class = "noenter"/></td></tr><tr class="gridview_altrow"><th id="Th64" laid="8-8" class="area" term="subtable">Mid-Argyll</th><td><input type="text" value ="0" id="Text134" maxlength = "5"  onblur="checkvalue(this.id); dosum(this.id, new Array('subjectrequesttotals','fPGS_0'));"  /></td><th>&nbsp</th><td><input type="text" value="0" id="Text135" maxlength="5" thefuntion="sum(row)" readonly = "true" class = "noenter"/></td></tr><tr><th id="Th65" laid="8-9" class="area" term="subtable">Mull and Iona</th><td><input type="text" value ="0" id="Text136" maxlength = "5"  onblur="checkvalue(this.id); dosum(this.id, new Array('subjectrequesttotals','fPGS_0'));"  /></td><th>&nbsp</th><td><input type="text" value="0" id="Text137" maxlength="5" thefuntion="sum(row)" readonly = "true" class = "noenter"/></td></tr><tr class="gridview_altrow"><th id="Th66" laid="8-10" class="area" term="subtable">Tiree</th><td><input type="text" value ="0" id="Text138" maxlength = "5"  onblur="checkvalue(this.id); dosum(this.id, new Array('subjectrequesttotals','fPGS_0'));"  /></td><th>&nbsp</th><td><input type="text" value="0" id="Text139" maxlength="5" thefuntion="sum(row)" readonly = "true" class = "noenter"/></td></tr><tr><th id="Th67" laid="8" class="area" term="subtable">Unspecified, TBA</th><td><input type="text" value ="0" id="Text140" maxlength = "5"  onblur="checkvalue(this.id); dosum(this.id, new Array('subjectrequesttotals','fPGS_0'));"  /></td><th>&nbsp</th><td><input type="text" value="0" id="Text141" maxlength="5" thefuntion="sum(row)" readonly = "true" class = "noenter"/></td></tr><tr class="gridview_altrow"><th rowspan="" colspan="">Total</th><td><input type="text" value="0" id="Text142" maxlength="5" thefuntion="sum(PGS)" readonly = "true" class = "noenter"/></td><th>&nbsp</th><td><input type="text" value="0" id="Text143" maxlength="5" thefuntion="sum(subjectrequesttotals)" readonly = "true" class = "noenter"/></td></tr></table>

Open in new window

mmalik15Asked:
Who is Participating?
 
carlnorrbomConnect With a Mentor Commented:
Hi,

You should be able to do something simple like:

After your code above, add:

LiteralControl lit = new LiteralControl();
lit.Text = html.ToString();
Page.Controls.Add(lit);


And you can also toggle visibility like:

lit.Visible = false  / true;

/Carl.

0
 
CodeCruiserCommented:
>how to add a dynamic table in a panel
To a Winforms panel?
0
 
mmalik15Author Commented:
....
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.