DataList parrent control with a Repeater child control

Discussion in 'ASP .Net Datagrid Control' started by SL, Jun 24, 2004.

  1. SL

    SL Guest

    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
     
    SL, Jun 24, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Nevyn Twyll
    Replies:
    8
    Views:
    1,963
  2. Jeff Rodriguez
    Replies:
    23
    Views:
    1,200
    David Schwartz
    Dec 9, 2003
  3. debartsa
    Replies:
    1
    Views:
    374
    John Saunders
    Apr 9, 2004
  4. Bart Plessers \(artabel\)

    find parrent URL - string question

    Bart Plessers \(artabel\), Sep 3, 2003, in forum: ASP General
    Replies:
    0
    Views:
    125
    Bart Plessers \(artabel\)
    Sep 3, 2003
  5. Kga Agk
    Replies:
    1
    Views:
    155
    Kga Agk
    Jun 16, 2009
Loading...

Share This Page