Binding Array of DataRows to Repeater

Discussion in 'ASP .Net' started by George Durzi, Jul 29, 2004.

  1. George Durzi

    George Durzi Guest

    Don't know why I'm having trouble with this:

    Dim arNewsletters As DataRow() = dsPubs.Tables(0).Select("CategoryName =
    'Newsletters'")
    If (arNewsletters.Length > 0) Then
    rptNewsletters.DataSource = arNewsletters
    rptNewsletters.DataBind()
    End If

    The code compiles, but if (for the sake of example) my Repeater looks like
    this

    <asp:Repeater ID="rptNewsletters" Runat="server">
    <ItemTemplate>
    <%#Container.DataItem%>
    </ItemTemplate>
    </asp:Repeater>

    all I see is:
    System.Data.DataRow System.Data.DataRow System.Data.DataRow



    (as many times as I have rows)

    I usually do all my coding in c#, this is the first vb.net project I've
    done. Maybe it's syntax?
     
    George Durzi, Jul 29, 2004
    #1
    1. Advertisements

  2. No, it's not syntax per se...Container.DataItem is a DataRow at that
    point (you bound an array of DataRows, so 1 item is a DataRow), and it's
    ToString method (like alot of classes) prints out it's typename. You
    have to ask for a column out of that current DataRow, either using a
    numerical index or by name.

    Note VB.NET uses () for indexes, not [], that syntax might trip you up...
     
    Craig Deelsnyder, Jul 30, 2004
    #2
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.