• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 796
  • Last Modified:

how to add a table in a panel control at runtime

I am generating multiple tables at runtime and want to add it in a panel control. The html of the table I get is like this
<table runat="server" id="subtable 331" class="gridview_table">
        <tr class="gridview_altrow">
            <th rowspan="" colspan="">
                LA Areas</th>
            <th id="subtable_yearcode_0" laid="PGS" class="yearcode" term="subtable">
                PGS</th>
            <th>
                &nbsp</th>
            <th rowspan="" colspan="">
                Request Totals</th>
        </tr>
        <tr>
            <th id="subtable_area_0" laid="33-1" class="area" term="subtable">
                Banff & Buchan</th>
            <td>
                <input type="text" value="0" id="subtable_PGS_0" 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="subtable_subjectrequesttotals_0" maxlength="5" thefuntion="sum(row)"
                    readonly="true" class="noenter" /></td>
        </tr>
</table>
how can I  add and display it in the panel.
Thanks

0
mmalik15
Asked:
mmalik15
1 Solution
 
badalpatelCommented:
you can take reference of my below sample code
Panel pnlMain = new Panel();

        Table tbl = new Table();
        tbl.ID = "";
        TableHeaderRow thr = new TableHeaderRow();
        TableHeaderCell thc = new TableHeaderCell();
        thc.Text = "LA Areas";
        thr.Controls.Add(thc);
        thc = new TableHeaderCell();
        thc.Text = "PGS";
        thc.ColumnSpan=2;
        thr.Controls.Add(thc);
        tbl.Controls.Add(thr);
        TableRow tr =  new TableRow();
        TableCell td = new TableCell();
        td.Text = "td 1";
        tr.Controls.Add(td);
        td = new TableCell();
        td.Text = "td 2";
        td.ColumnSpan=2;
        tr.Controls.Add(td);
        tbl.Controls.Add(tr);

        pnlMain.Controls.Add(tbl)

Open in new window

0
 
mmalik15Author Commented:
Thanks for the reply.
I know how can I add a standard .net table in panel but i want to add a html tables created at runtimes.
Any other ideas?
0
 
aymoon80Commented:
you can use IE control and create your html dynamically in tmp file then load it into IE control
0
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

 
aymoon80Commented:
Sorry I thought it is a windows applications
0
 
aymoon80Commented:
you can put a variable in your html script then use Response.Write(yourVariable)

yourVariable is a string variable that holds your dynamically generated source code.

0
 
aymoon80Commented:
I notice that you add controls that run at server... this is not suitable in my approach

but please let me understand what is the case you have that guide you to do that?

Regards,
Ayman
0
 
CodeCruiserCommented:
>panel control

Is that ASP.NET 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.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now