How do you nest master-detail data controls?

F

Fuzzie Dice

I am trying to get something to work as so:

Section Title
Item 1
Item 2
Item 3
More...

Section Title
Item 1
Item 2
Item 3
More...

Section Title
Item 1
Item 2
Item 3
More...

When I created the AccessDataSource and set up the Select query, it did return rows. But when I view the web page, all I am getting is this:

Section Title
More...

Section Title
More...

Section Title
More...

Here is my code. Note that in my original source code that I tested, the SelectCommand statements are all on one line. Also the NavigationURL properties do NOT have a _ at the end but are all on one line. I did this here in this example so that it is hopefully easier to read.

<asp:AccessDataSource
ID="AccessDataSource1"
runat="server"
DataFile="~/App_Data/myaccessdb.mdb"
SelectCommand="SELECT TOP 3 sections.sectionname, sections.sectionid FROM items INNER JOIN sections ON items.sectionid = sections.sectionid
WHERE items.advert=false AND items.publish=true"
/>
<asp:DataList
ID="AccessDataSource2"
runat="server"
DataSourceID="AccessDataSource1"
DataKeyField="sectionid">
<ItemTemplate>
<asp:Label
ID="lblSNames"
runat="server"
Text='<%# Eval("sectionname") %>'
/>

<br />

<asp:AccessDataSource
ID="AccessDataSource3"
runat="server"
DataFile="~/App_Data/myaccessdb.mdb"
SelectCommand="SELECT TOP 3 [itemid], [title] FROM [items]
WHERE ([sectionid] = ?) ORDER BY [viewcount] DESC, [title]">
<SelectParameters>
<asp:ControlParameter
ControlID="AccessDataSource2"
Name="sectionid"
PropertyName="SelectedValue"
Type="Int32"
/>
</SelectParameters>
</asp:AccessDataSource>

<asp:Repeater
ID="repLinks"
runat="server"
DataSourceID="AccessDataSource3">
<ItemTemplate>
<asp:HyperLink
ID="lnkItemLink"
runat="server"
NavigateUrl='<%#"~/itempage.aspx?id=" & _
Eval("itemid").ToString %>' Text='<%#Eval("title").ToString%>'
/>
</ItemTemplate>
</asp:Repeater>

<asp:HyperLink
ID="lnkMoreLink"
runat="server"
NavigateUrl='<%#"~/browsesections.aspx?section=" & _
Eval("sectionid").tostring %>'
Text="More..."
/>

<br /><br />

</ItemTemplate>

</asp:DataList>

It looks logically like it should work. But while I do get the section names, I don't seem to get the individual links listed.

Can anyone give me a hint as to where I'm going wrong here?
 

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,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top