Creating a TABLE in the code behind.

Category : ASP.Net, C#

This worked well for me.  I created the TABLE in markup [MAKE SURE ITS AN ASP:TABLE with the runat server tag].

Then you can manipulate it from code-behind like so:

   TableRow tr = new TableRow();
   TableCell tc = new TableCell();
   Label label2 = new Label();
   label2.Text = "LAJLKFJDSLJFLKDF";
   tc.Controls.Add(label2);
   tr.Cells.Add(tc);
   MyTable.Rows.Add(tr);

Hope this helps!

Post a comment

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word