Reputation: 4848
Just for testing, I made a page with nothing but the form and div tags and, in the codebehind, I created a table, added rows to it, then used the following code to add the table to the page:
Page.Controls.Add(dtStatuses);
What I'd like to do now, though, is add this table to a particular div. For instance, if I have a div tag with an ID of "testDiv", how can I add the above table (dtStatuses) to that div, with just code in the codebehind?
Upvotes: 0
Views: 2915
Reputation: 40970
Just set runat="server"
to the div
<div id="testDiv" runat="server"></div>
and add the control like this
testDiv.Controls.Add(dtStatuses);
Upvotes: 4