how to add control runtime(dynamically)
i am trying to add control(textbox ,button "Remove") 3times in runtime with the help of add button. and adding someting text in text box but when i am clicking button "Remove" then all added control goes to erase.
how to achiev solution for this problem ?
Button btn = new Button();
Table tblName = new Table();
PlaceHolder PlaceHolder1 = new PlaceHolder();
btn.Click += new EventHandler(btn_Click);
TableRow tr = new TableRow();
tr.Cells.Add(new TableCell());
tr.Cells.Add(new TableCell());
tr.Cells[0].Text ="jhjh";
tr.Cells[1].Controls.Add(btn);
btn.Text = "Remove";
// btn.ID = "Remove_0";
tblName.Rows.Add开发者_如何学运维(tr);
PlaceHolder1.Controls.Add(tblName);
Controls added dynamically, must be re-created each time (and prefererably on the Page_Init before the ViewState is parsed)
精彩评论