Binding Array of DataRows to Repeater

G

George Durzi

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?
 
C

Craig Deelsnyder

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?

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...
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,045
Latest member
DRCM

Latest Threads

Top