Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>@Geoff</p> <p>That sort of Eval statement was actually added in 2.0, but if performance is important Eval should be avoided since it uses Reflection.</p> <p>The repeater is a pretty good way of doing it, although it might be faster to generate the table in code:</p> <p>ASPX Page:</p> <pre><code>&lt;table class="report" id="bookTable" runat="server"&gt; &lt;tr&gt; &lt;th&gt;Published&lt;/th&gt; &lt;th&gt;Title&lt;/th&gt; &lt;th&gt;Author&lt;/th&gt; &lt;th&gt;Price&lt;/th&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre> <p>Code Behind:</p> <pre><code>Protected Sub Page_Load( ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Not Page.IsPostback Then BuildTable() End If End Sub Private Sub BuildTable() Dim db As New BookstoreDataContext Dim bookCollection = from b in db.Books _ Order By b.Published _ Select b Dim row As HtmlTableRow Dim cell As HtmlTableCell For Each book As Books In bookCollection row = New HtmlTableRow() cell = New HtmlTableCell With { .InnerText = b.Published.ToShortDateString } row.Controls.Add(cell) cell = New HtmlTableCell With { .InnerText = TryNbsp(HttpContext.Current.Server.HtmlEncode(b.Title)) } row.Controls.Add(cell) cell = New HtmlTableCell With { .InnerText = TryNbsp(HttpContext.Current.Server.HtmlEncode(b.Author)) row.Controls.Add(cell) cell = New HtmlTableCell With { .InnerText = Format(b.Price, "c") } row.Controls.Add(cell) bookTable.Controls.Add(row) Next </code></pre> <p>I guess it depends on how important speed is to you. For simplicity's sake I think I would go with the Repeater.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload