It must be said that at the time of writing this article most of the tables on this site are generated by building a string, pretty much the same way as you would have done it in classic ASP. But after creating controls for this site it suddenly dawned that there was a much better way to create tables in code
Here are three techniques to create tables in code.
"Oldtable" shows us how to create a table using a string, this is easily the most concise code, but is not clear at all. If you have used this technique is classic asp you will know how easy it is to forget closing tags. This technique also provides no formatting of the HTML and thus the generated page is a nightmare
"Table" show us how to create a table using HTMLControl objects. If you have ever created tables client side in JScript this will be familiar, as it is the same but for the declaration of the objects. All the attributes of the table are available through the object. This technique is much easier to read and takes away the generation of the tags, so missing out a closing tag is not a worry. You also benefit in that the HTML code produced is indented and easy to read.
"NewTable" show us how to create a table using webControl objects. This technique also gives you clarity in the code and the generated HTML. It also has typing on the attributes making it easier to set them correctly. You may notice when you run the examples that this is the only one where the row colors actually turned out as intended.