Hi ,
Try this
int countTimes = 0;
protected void Button2_Click(object sender, EventArgs e)
{
if (ViewState["countTimes"] == null)
{
countTimes = 1;
}
else
{
countTimes = Convert.ToInt32(ViewState["countTimes"]);
}
for (int i = 0; i < countTimes; i++)
{
TableRow row = new TableRow();
TableCell cell = new TableCell();
TextBox txt = new TextBox();
txt.ID = "txt"+i;
TextBox txt1 = new TextBox();
txt1.ID = "txt" + i;
TextBox txt2 = new TextBox();
txt2.ID = "txt" + i;
TextBox txt3= new TextBox();
txt3.ID = "txt" + i;
TextBox txt4 = new TextBox();
txt4.ID = "txt" + i;
TextBox txt5 = new TextBox();
txt5.ID = "txt" + i;
TextBox txt6 = new TextBox();
txt6.ID = "txt" + i;
cell.Controls.Add(txt);
cell.Controls.Add(txt1);
cell.Controls.Add(txt2);
cell.Controls.Add(txt3);
cell.Controls.Add(txt4);
cell.Controls.Add(txt5);
cell.Controls.Add(txt6);
row.Controls.Add(cell);
Table1.Controls.Add(row);
}
countTimes = countTimes + 1;
ViewState.Add("countTimes", countTimes);
}
<div>
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
<br />
<asp:Table ID="Table1" runat="server">
</asp:Table>
</div>
Best Regards
M.Mitwalli