Home » questions » how to add a table dynamically in asp.net ,create rows dynamically and display the text in the brows

how to add a table dynamically in asp.net ,create rows dynamically and display the text in the brows

2006-08-08 06:03:25, Category: Programming & Design

Answers

  1. ralphd42

    On 2006-08-08 06:17:01


    create a function to create a table void buildTable() { Table tb = new Table(); TableRow tr = new TableRow(); TableCell tc = new TableCell(); tc.Text = "Hello"; tr.Cells.Add(tc); tb.Rows.Add(tr); // you should have a placeholder on your page. Pc.Controls.Add(tb); } // also you must rebuild your table again in protected override void LoadViewState(object savedState) { base.LoadViewState (savedState); if(AddedTable) { buildTable(); } }
  2. Islamegy®

    On 2006-08-08 06:19:44


    Soo easy.. use Table Class. TableCell cell = new TableCell(); TableRow row = new TableRow(); row.Cells.Add(cell); Table t = new Table(); t.Rows.Add(row); you can also add controls to display text like Literal, Label.. Label lb1 = new Label(); lb1.Text = "Text Text Text"; cell.Controls.Add(lb1); Hope this is what you want.. Contact me if u need any help