ricojohari
ricojohari

Reputation: 183

Add control into table from code-behind

I'm trying to dynamically add asp.net controls into HTML table, not the ASP.NET table. Well, let's just say that controls that i want to add is a textbox. How can i achieve that?

Upvotes: 1

Views: 3825

Answers (1)

Rahul Gokani
Rahul Gokani

Reputation: 1708

Do one thing, use <asp:Panel> or <asp:PlaceHolder> in side any td in which you want to put your dynamic control. and then using their ID you can put your control in side that table. e.g

Asp File:-

<table>
<tr>
<td><asp:PlaceHolder ID="placeHolder1" runat="server"/><td>
</tr>
</table>

Code Behind:-

TextBox t1 = new TextBox();
t1.ID="txt1";
placeHolder1.Controls.Add(t1);

Try this and let me know if this works or not.

Upvotes: 1

Related Questions