DataList parrent control with a Repeater child control

S

SL

I've been trying to bind a Repeater 'child control' to a DataList control and seem to have lost the plot.

Tec spec:
Connection to SQL server
2 DataAdaplters
1 DataSet
1 DataSet relation between the two tables


Section of the Test.aspx page:

<form id="Form1" method="post" runat="server">
<asp:datalist id=DataList1 runat="server" BorderColor="#999999" BorderStyle="None" BackColor="White" CellPadding="3" GridLines="Vertical" BorderWidth="1px" DataSource="<%# dsClientProjects1 %>" DataKeyField="Name" DataMember="tblClients" RepeatDirection="Horizontal" RepeatColumns="3">
<SelectedItemStyle Font-Bold="True" ForeColor="White" BackColor="#008A8C"></SelectedItemStyle>
<AlternatingItemStyle BackColor="Gainsboro"></AlternatingItemStyle>
<ItemStyle ForeColor="Black" BackColor="#EEEEEE"></ItemStyle>
<ItemTemplate>
<asp:Label id=Label1 runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.Name", "{0}") %>'>
</asp:Label><BR>

<asp:Repeater id=childRepeater runat="server" DataMember="tblProject" DataSource="<%# dsClientsProjects1 %>">
<ItemTemplate>
<li>
<%# DataBinder.Eval(Container.DataItem, "[\"Name\"]")%>
<br>
</li>
</ItemTemplate>
</asp:Repeater>

</ItemTemplate>
<FooterStyle ForeColor="Black" BackColor="#CCCCCC"></FooterStyle>
<HeaderStyle Font-Bold="True" ForeColor="White" BackColor="#000084"></HeaderStyle>
<AlternatingItemTemplate>
<asp:Label id=Label2 runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.Name", "{0}") %>'>
</asp:Label>
</AlternatingItemTemplate>
</asp:datalist>
</form>


Page_Load() of .ASPX.CS file:

DataRelation relClientsProject = dsClientProjects1.Relations.Add("ClientsProject",
dsClientProjects1.Tables["tblClients"].Columns["Client_ID"],
dsClientProjects1.Tables["tblProject"].Columns["Clients_FK"]);

daClients.Fill(dsClientProjects1, "tblClients");
daProject.Fill(dsClientProjects1, "tblProject");

Page.DataBind();

//Close the connection.
sqlConnection1.Close();


To test the dataset relationship I've writen the following foreach loop, which is ineffect what I need to do when linking the Parrent Control (DataList) to the Child Control (Repeater):

foreach (DataRow rowClients in dsClientProjects1.Tables["tblClients"].Rows)
{
Response.Write(rowClients["Name"] + ": <br>");
foreach (DataRow rowCOrder in rowClients.GetChildRows("ClientsProject"))
{
Response.Write("* " + rowCOrder["Name"].ToString() + "<br>");
}
}


So finaly here are my questions to you kind people:

1. Is it possible to do what I want in designer/html mode?
2. Is Yes to Q.1 please can you point me in the right direction or let me know how?
3. If No to Q.1 please can you let me know how best to do it in code?

Many Thanks,
Siôn
 

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

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top