Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 41591
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T15:12:19+00:00 2026-05-10T15:12:19+00:00

This is what I’ve got. It works. But, is there a simpler or better

  • 0

This is what I’ve got. It works. But, is there a simpler or better way?

ASPX Page…

<asp:Repeater ID='RepeaterBooks' runat='server'>     <HeaderTemplate>         <table class='report'>             <tr>                 <th>Published</th>                 <th>Title</th>                 <th>Author</th>                 <th>Price</th>             </tr>     </HeaderTemplate>     <ItemTemplate>             <tr>                 <td><asp:Literal ID='LiteralPublished' runat='server' /></td>                 <td><asp:Literal ID='LiteralTitle' runat='server' /></td>                 <td><asp:Literal ID='LiteralAuthor' runat='server' /></td>                 <td><asp:Literal ID='LiteralPrice' runat='server' /></td>             </tr>     </ItemTemplate>     <FooterTemplate>         </table>     </FooterTemplate> </asp:Repeater> 

ASPX.VB Code Behind…

Protected Sub Page_Load( ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load     Dim db As New BookstoreDataContext     RepeaterBooks.DataSource = From b In db.Books _                                Order By b.Published _                                Select b     RepeaterBooks.DataBind() End Sub  Sub RepeaterBooks_ItemDataBound( ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles RepeaterBooks.ItemDataBound     If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then         Dim b As Book = DirectCast(e.Item.DataItem, Book)         DirectCast(e.Item.FindControl('LiteralPublished'), Literal).Text = '<nobr>' + b.Published.ToShortDateString + '</nobr>'         DirectCast(e.Item.FindControl('LiteralTitle'), Literal).Text = '<nobr>' + TryNbsp(HttpContext.Current.Server.HtmlEncode(b.Title)) + '</nobr>'         DirectCast(e.Item.FindControl('LiteralAuthor'), Literal).Text = '<nobr>' + TryNbsp(HttpContext.Current.Server.HtmlEncode(b.Author)) + '</nobr>'         DirectCast(e.Item.FindControl('LiteralPrice'), Literal).Text = '<nobr>' + Format(b.Price, 'c') + '</nobr>'     End If End Sub  Function TryNbsp(ByVal s As String) As String     If s = '' Then         Return '&nbsp;'     Else         Return s     End If End Function 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T15:12:19+00:00Added an answer on May 10, 2026 at 3:12 pm

    @Geoff

    That sort of Eval statement was actually added in 2.0, but if performance is important Eval should be avoided since it uses Reflection.

    The repeater is a pretty good way of doing it, although it might be faster to generate the table in code:

    ASPX Page:

    <table class='report' id='bookTable' runat='server'>         <tr>             <th>Published</th>             <th>Title</th>             <th>Author</th>             <th>Price</th>         </tr>  </table> 

    Code Behind:

    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 

    I guess it depends on how important speed is to you. For simplicity’s sake I think I would go with the Repeater.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a bit of a long shot, but if anyone can figure it
This is kinda oddball, but I was poking around with the GNU assembler today
This might seem like a stupid question I admit. But I'm in a small
This is a difficult and open-ended question I know, but I thought I'd throw
This past summer I was developing a basic ASP.NET/SQL Server CRUD app, and unit
This is starting to vex me. I recently decided to clear out my FTP,
This is my first post here and I wanted to get some input from
This error just started popping up all over our site. Permission denied to call
This most be the second most simple rollover effect, still I don't find any
This is a self-explanatory question: Why does this thing bubble into my try catch's

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.