Imar:
My code is given below. Itâs pretty much the same as in the book with the exception that Iâve changed some names: Reviews = Songs, Genre = Bands and PlanetWroxEntities becomes TRTDevelopmentSongsAndBandsEntities. I know what Iâm asking extends what is presented in the book but as I looked at my web site I felt it really needed to have functionality equivalent to that seen in the âAll.aspxâ and âMy Favorite Reviewsâ pages. However, after several days and a lot of "Googling" I have simply not been able to implement that functionality. I donât even know if Iâm on the right tract.
For the present I have implemented a solution on my web site that I hate. Iâve inserted a second bulleted list underneath that of in the âAllSongsByBand.aspxâ form using the âDataDisplayMode = âHyperLinkâ and âDataTextField =âClipLinkââ (a filed I've inserted into the "Songs" table that provides a url link to a clip of the song). This works to an extent but does not link the âViewDetailâ Form, looks awful, and is not acceptable.
The âViewDetails.aspxâ and âViewDetails.aspx.csâ look pretty much the same as in the book with the exception that Iâve changed names (âSongsâ and âBandsâ again) and added a couple of additional fields to display. If you need to look at the code I can send it.
I appreciate your rapid response. Any guidance or pointers or even an opinion as to whether or not Iâm on the right tract would be greatly appreciated.
I'm greatly indebted to you as this is my first real attempt a creating a web site. My site does work perfectly anologus to that you have created in the book and with the knowledge you provided have been able to make some adaptations. I still have a lot nore to learn, however, about how Asp.Net works :-)
Thanks
Code:
<%@ Page Title="All Songs By A Band" Language="C#" MasterPageFile="~/MasterPages/Frontend.master"
AutoEventWireup="true" CodeFile="AllSongsByBand.aspx.cs" Inherits="Songs_AllSongsByBand" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="cpMainContent" runat="Server">
<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
<h3>
<asp:Literal ID="Literal1" runat="server" Text='<%# Eval("Band1")
%>'></asp:Literal>
</h3>
<asp:BulletedList ID="SongList" runat="server"
DataSource='<%# Eval ("Songs") %>' DataTextField="Title"
DisplayMode="Text">
</asp:BulletedList>
</Itemtemplate>
</asp:Repeater>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="cpClientScript" runat="Server">
</asp:Content>
And the âCode Behindâ
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Songs_AllSongsByBand : BasePage
{
protected void Page_Load(object sender, EventArgs e)
{
using (TRTDevelopmentSongsAndBandsEntities MyEntities = new
TRTDevelopmentSongsAndBandsEntities())
{
var AllBands = from Band in MyEntities.Bands.Include("Songs")
orderby Band.Band1
select new { Band.Band1, Band.Songs};
Repeater1.DataSource = AllBands.ToList();
Repeater1.DataBind();
}
}
}