Link to home
Start Free TrialLog in
Avatar of pauledwardian
pauledwardian

asked on

C# Placeholder Generate 4 textboxes in a row

How can I add a placeholder inside a table?

<asp:PlaceHolder ID="Table1" runat="server"></asp:PlaceHolder>

Open in new window

Avatar of YZlat
YZlat
Flag of United States of America image

try

TextBox tb;
Panel pnl;

for(int i=1; i<=4; i++)
{
      tb=new TextBox();
      tb.id="TextBox" + i;
      pnl=Page.FindControl("Table1");
      pnl.Controls.Add(tb);
}
as I understood you have a panel on your page with id Table1 and you want to add controls inside that panel?
TextBox tb;
        Panel pnl;

        for (int i = 1; i <= 4; i++)
        {
            tb = new TextBox();
            tb.ID = "TextBox" + i;
            pnl = (Panel) this.FindControl("Table1");
            pnl.Controls.Add(tb);
        } 

Open in new window

Avatar of pauledwardian
pauledwardian

ASKER

ASKER CERTIFIED SOLUTION
Avatar of Obadiah Christopher
Obadiah Christopher
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Your code looks greate, however it does not add a new row after clicking on the "Add Rows" button again.
It only adds the row once!
did you try my code?
Thanks!