<pre> protected void LinkButton1_Click(object sender, EventArgs e) { CreateDynamicControls(true); } private void CreateDynamicControls(bool incrementRowCount = false) { int rowCount = 0; //initialize a session. rowCount = Convert.ToInt32(ViewState["clicks"]); if (incrementRowCount) rowCount++; ViewState["clicks"] = rowCount; //Create the textboxes and labels each time the button is clicked. for (int i = 0; i < rowCount; i++) { TextBox TxtBoxU = new TextBox(); //TextBox TxtBoxE = new TextBox(); Label lblU = new Label(); //Label lblE = new Label(); TxtBoxU.ID = "TextBoxU" + i.ToString(); //TxtBoxE.ID = "TextBoxE" + i.ToString(); TxtBoxU.Width=900; lblU.ID = "LabelU" + i.ToString(); //lblE.ID = "LabelE" + i.ToString(); lblU.Text = (i + 1).ToString() + " : "; //lblE.Text = "E-Mail : "; //Add the labels and textboxes to the Panel. PlaceHolder1.Controls.Add(lblU); PlaceHolder1.Controls.Add(TxtBoxU); PlaceHolder1.Controls.Add(new LiteralControl("<br/>")); PlaceHolder1.Controls.Add(new LiteralControl("<br/>")); } } Kindly help
</<pre><pre> protected void LinkButton1_Click(object sender, EventArgs e) { CreateDynamicControls(true); } private void CreateDynamicControls(bool incrementRowCount = false) { int rowCount = 0; //initialize a session. rowCount = Convert.ToInt32(ViewState["clicks"]); if (incrementRowCount) rowCount++; ViewState["clicks"] = rowCount; //Create the textboxes and labels each time the button is clicked. for (int i = 0; i < rowCount; i++) { TextBox TxtBoxU = new TextBox(); //TextBox TxtBoxE = new TextBox(); Label lblU = new Label(); //Label lblE = new Label(); TxtBoxU.ID = "TextBoxU" + i.ToString(); //TxtBoxE.ID = "TextBoxE" + i.ToString(); TxtBoxU.Width=900; lblU.ID = "LabelU" + i.ToString(); //lblE.ID = "LabelE" + i.ToString(); lblU.Text = (i + 1).ToString() + " : "; //lblE.Text = "E-Mail : "; //Add the labels and textboxes to the Panel. PlaceHolder1.Controls.Add(lblU); PlaceHolder1.Controls.Add(TxtBoxU); PlaceHolder1.Controls.Add(new LiteralControl("<br/>")); PlaceHolder1.Controls.Add(new LiteralControl("<br/>")); }}
CreateDynamicControls
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)