protected void Button1_Click(object sender, EventArgs e) { if (txtQuantity.Text != "") { if (Page.IsPostBack) { for (int i = 0; i <= Convert.ToInt16(txtQuantity.Text) / 3; i++) { Label la = new Label(); la.Text = ddlProductName.SelectedItem.Value + (i + 1).ToString(); la.ID = "abc1" + i; PlaceHolder1.Controls.Add(la); //la = FindControl(String.Format(i)) as Label; TextBox txtbox = new TextBox(); // txtbox.Text = "Textbox - " + i.ToString(); PlaceHolder1.Controls.Add(new LiteralControl("<input id='txt' name='Textbox" + i + "'type='text' />")); PlaceHolder1.Controls.Add(new LiteralControl("<br />")); } for (int j = (Convert.ToInt16(txtQuantity.Text) / 3) + 1; j <= Convert.ToInt16(txtQuantity.Text) * 2 / 3; j++) { Label la1 = new Label(); la1.Text = ddlProductName.SelectedItem.Value + (j + 1).ToString(); la1.ID = "abc2" + j; PlaceHolder2.Controls.Add(la1); //la = FindControl(String.Format(i)) as Label; TextBox txtbox1 = new TextBox(); // txtbox.Text = "Textbox - " + i.ToString(); PlaceHolder2.Controls.Add(new LiteralControl("<input id='txt' name='Textbox" + j + "'type='text' />")); PlaceHolder2.Controls.Add(new LiteralControl("<br />")); } for (int k = (Convert.ToInt16(txtQuantity.Text) * 2 / 3) + 1; k < Convert.ToInt16(txtQuantity.Text); k++) { Label la2 = new Label(); la2.Text = ddlProductName.SelectedItem.Value + (k + 1).ToString(); la2.ID = "abc3" + k; PlaceHolder3.Controls.Add(la2); //la = FindControl(String.Format(i)) as Label; TextBox txtbox1 = new TextBox(); // txtbox.Text = "Textbox - " + i.ToString(); PlaceHolder3.Controls.Add(new LiteralControl("<input id='txt' name='Textbox" + k + "'type='text' />")); PlaceHolder3.Controls.Add(new LiteralControl("<br />")); } } } }
if (Page.IsPostBack)
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)