i am geo.please any one help me to slove this
i have one panel , table, and a button. i want to add 2 new textboxs dynamically when i clicks on the button. if i click it again another 2 textbox should come. but if i entered any thing on previous textboxs it will not deleted at the time of clicking the button.please help me. i am able to add the row each time the button clicks , that code is follows, there is only two columns in the table. it is in asp.net using C#
Expand|Select|Wrap|Line Numbers
- int b = 0;
- TextBox txtBox;
- protected void btnAdd_Click(object sender, EventArgs e)
- {
- b = b + 1;
- Session["val"] = b;
- int count=0;
- for (int i = 0; i < b; i++)
- {
- TableRow tr = new TableRow();
- //2 is to count the columns
- for (int j = 0; j < 2; j++)
- {
- TableCell tc = new TableCell();
- txtBox = new TextBox();
- if (j == 1)
- {
- txtBox.ID = "txt" + count.ToString();
- txtBox.Width = 315;
- }
- txtBox.EnableViewState = true;
- // Add the control to the TableCell
- tc.Controls.Add(txtBox);
- // Add the TableCell to the TableRow
- tr.Cells.Add(tc);
- }
- // Add the TableRow to the Table
- Table1.Rows.Add(tr);
- }
- }