View Single Post
  #9 (permalink)  
Old October 22nd, 2003, 01:41 PM
katsarosj katsarosj is offline
Friend of Wrox
 
Join Date: Jun 2003
Location: , , .
Posts: 540
Thanks: 0
Thanked 4 Times in 4 Posts
Default

It is really up to you and what you are more comfortable with. I think the speed difference will be negligible. If you are using a code-behind file, then it gets compiled anyway which will speed it up.

The advantage to doing it the first way is that you can access the table/rows/columns methods and properties programmatically. Otherwise, I would just add the code as HTML(the portions where your are writing the table as strings) to the .aspx page (not the code behind) because it is less for the server to process.

Remember also that one of the great things about .net is the ability to "act" more like a windows form than classic asp.

So, if you want to create them programmatically, I would use the way that I presented to you. Hope this helps.

J

Quote:
quote:Originally posted by stu9820
 Is it faster to build a table like this:
**********************
Dim tblTable as Table
Dim tblRow as TableRow
Dim tblCell as TableCell

tblTable = New Table
tblRow = New TableRow
tblCell = New TableCell

tblCell.Text = "This text would appear in the first column."
tblRow.Cells.Add(tblCell)

tblCell = New TableCell
tblCell.Text = "This text would appear in the second column."
tblRow.Cells.Add(tblCell)

tblTable.Rows.Add(tblRow)

frmFormName.Controls.Add(tblTable)
**************************


as opposed to this:
*****************
Dim strResultsHolder As String
strResultsHolder = "<table width=80% border=0 cellpadding=2 cellspacing=0>"
strResultsHolder &= "<tr><th colspan=3>" & myNews & "</th></tr>"

Dim r1 As DataRow
For Each r1 In objDataSet.Tables("dtNews").Rows
strResultsHolder &= "<tr><td width=140>" & r1("the_news") & "</td> <td>" & r1("short_sum") & "</td>"
If r1("news_link") = "No Link" Then
        strResultsHolder &= "<td width=90>No Link</td></tr>"
Else
        strResultsHolder &= "<td width=90><a href=" & r1("news_link") & " target=_blank>Get the story</a></td></tr>"
End If
Next

strResultsHolder &= "</table>"
display.InnerHtml = strResultsHolder