1
Answer

Dynamic Table

tripti fulzele

tripti fulzele

16y
2.6k
1

I have a dropdown,textbox and button on button click i m writing below code

System.Web.UI.WebControls.Table TBL = new System.Web.UI.WebControls.Table();

TBL.ID = "PP";

TBL.Width = Unit.Percentage(230);

TBL.BorderWidth = Unit.Pixel(1);

Button btnAddEntity= new Button();

btnAddEntity.Text = "Add Entity";

TableRow TBLROW = new TableRow();

TBL.Rows.Add(TBLROW);

TableCell TBLCELL = new TableCell();

TBLROW.Cells.Add(TBLCELL);

TBLCELL.Width = Unit.Percentage(5);

TBLCELL.Text = ddlCategory.SelectedItem.Text;

TBLCELL = new TableCell();

TBLROW.Cells.Add(TBLCELL);

TBLCELL.Width = Unit.Percentage(7);

TBLCELL.Text = txtWeight.Text;

TBLCELL = new TableCell();

TBLROW.Cells.Add(TBLCELL);

TBLCELL.Width = Unit.Percentage(20);

TBLCELL.Controls.Add(btnAddEntity);

PH.Controls.Add(TBL);

first time on button there is no problem but if i select another text from dropdown and writing another text in textbox and click on button then previous row get overwrited with new one.

wat i want is whenever i m clicking on button that row get added to next row and so on...

 

Answers (1)