Instead of continuing in circles, I went back to the basics and wrote exaclty what I wanted to happen and tried to accomplish it step by step.
I created a page with a repeater that contains:
First Image in the Photo Album
Photo Album Name
Photo Album Id
Photo Album Owner
Code:
<div class="maintext">
<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
<br/><asp:Image ID="Image1" ImageUrl="" runat="server" /><br />
<br/><%#Eval("Name")%>
<br/><%#Eval("Id")%>
<br/><%#Eval("UserName")%> <br />
</ItemTemplate></asp:Repeater>
<p>
<asp:Label ID="Label1" runat="server"></asp:Label> </p>
</div>
In the CB Page, I created the data source to get the Photo Album Name, ID, and Owner
Code:
Using myDatabaseContext As MyDataContext = New MyDataContext()
Dim allAlbums = From albums In myDatabaseContext.PhotoAlbums _
Select albums.Name, albums.Id, albums.UserName
Repeater1.DataSource = allAlbums
Repeater1.DataBind()
This provided me with everything but the first picture in the photo album. So I went back and added a for each loop to see if I could correctly generate the first picture in the albums correctly:
Code:
For Each album In allAlbums
Dim albumId = album.Id
Dim firstPic As String = (From pics In myDatabaseContext.Pictures _
Where albumId = pics.PhotoAlbumId _
Select pics.ImageUrl).FirstOrDefault()
Label1.Text += firstPic + "<br/>"
Next
This produced a label with the url for the first picture in each album, exactly what I wanted.
What I can't do and haven't been able to do is find a way to bind the url's produced in the for each loop to the images in the repeater. Every time that I try to access the control using Repeater.FindControl("Image1") I an error. I apologize for the confusion. I am new to this and too stubborn to give up.