Note that there are some explanatory texts on larger screens.

plurals
  1. POAdd rows to a table dynamically
    primarykey
    data
    text
    <p>At the moment I am trying to create a table whose content is supposed to be created by a subclass (result of querying a RESTful web service). I have been working for quite some time on that now and I just cannot seem to get it to work. I have tried so many different solutions. </p> <ul> <li>creating the table in the subclass and add it to Page.Controls. That gets me "The Controls collection cannot be modified because the control contains code blocks (i.e. &lt;% ... %>)." which does not make sense at all.</li> <li>I have tried to create an empty table on the page and passed its handle to the subclass which was responsible for adding rows. Noting happened.</li> <li>I have tried to return a TableRowCollection and assigned it to the previously created (empty) table. Nothing happened.</li> <li><p>Now I just want to add one row and one cell to the table (baby steps towards what I need). Not even that works. Please find the code for that attached:</p> <pre><code>TableRow row = new TableRow(); table.Rows.Add(row); TableCell cell = new TableCell(); row.Cells.Add(cell); cell.Controls.Add(new TextBox()); </code></pre></li> </ul> <p>The table is simple and empty:</p> <pre><code>&lt;asp:Table ID="table" runat="server" /&gt; </code></pre> <p>The source code that is displayed by my browser looks like that:</p> <pre><code>&lt;table id="table"&gt; &lt;/table&gt; </code></pre> <p>I have been looking at countless examples on the web and all look like this. I guess it is only a tiny problem somewhere but I have not been able to figure it out. Now I am willing to offer life-long gratitude to everybody who can provide the hint for solving this mess.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload