p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: Beginning ASP.NET 4 : in C# and VB (http://p2p.wrox.com/forumdisplay.php?f=560)
-   -   Ch14, Try out pg493 (http://p2p.wrox.com/showthread.php?t=82996)

TeaDrinkingGeek March 18th, 2011 07:45 AM

Ch14, Try out pg493
 
Hi Imar,

I've been experimenting with your code on pg 493, 494.

I wanted to add another Review field into the repeater.

I wrote this:

Code:

<asp:BulletedList ID="BulletedList1" runat="server" DataSource='<%# Eval("Reviews")%>' DataTextField="Summary" DisplayMode="Text">
                  </asp:BulletedList>

It displays the summary of reviews fine but in this format:

PUNK
--->Title
--->Title

--->Summary
--->Summary

How can I get it to display like:

PUNK
--->Title
--->Summary

--->Title
--->Summary

?

Regards
TDG

Imar March 18th, 2011 08:25 AM

This won't work as each bulleted list renders it's own set of items. What you could instead is use a nested Repeater and define controls for the title and the summary. Something like this should work:

Code:

<asp:Repeater ID="Repeater1" runat="server">
  <ItemTemplate>
    <h3><asp:Literal ID="Literal1" runat="server" Text='<%# Eval("Name") %>'></asp:Literal></h3>
    <asp:Repeater runat="server" DataSource='<%# Eval("Reviews")%>' >
      <ItemTemplate>
        <h4><asp:Literal ID="Literal1" runat="server" Text='<%# Eval("Title") %>' /><br /></h4>
        <p>
        <asp:Literal ID="Literal2" runat="server" Text='<%# Eval("Summary") %>' />
        </p>
      </ItemTemplate>
    </asp:Repeater>
  </ItemTemplate>
</asp:Repeater>

Cheers,

Imar

TeaDrinkingGeek March 18th, 2011 09:14 AM

Thanks Imar,

I thought you might have to have a nested query to get the info.

Imar March 18th, 2011 09:25 AM

You already have a nested set of data, where each genre holds a number of reviews. In this example, the outer Repeater displays the top level genres, while the inner Repeater displays the nested reviews.

Cheers.

Imar


All times are GMT -4. The time now is 09:56 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.