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. Advertisements

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:
    2,304
  2. Charlie@CBFC
    Replies:
    1
    Views:
    6,706
    =?Utf-8?B?UGhpbGxpcCBXaWxsaWFtcw==?=
    Oct 7, 2005
  3. Jeff Rodriguez
    Replies:
    23
    Views:
    1,519
    David Schwartz
    Dec 9, 2003
  4. debartsa
    Replies:
    1
    Views:
    528
    John Saunders
    Apr 9, 2004
  5. caldera

    Placeholder child of child control event problem.

    caldera, May 27, 2004, in forum: ASP .Net Building Controls
    Replies:
    1
    Views:
    359
  6. Replies:
    0
    Views:
    388
  7. Bart Plessers \(artabel\)

    find parrent URL - string question

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