Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    May 2005
    Location
    The Lone Star State
    Posts
    47
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy Nested Repeaters

    Greetings!

    I don't know why I'm having such a hard time with this, but here is what I'm trying to do:

    The data set returns a table essentially like this:

    Sub Type | Name | Phone #

    so...multiple records with a data grid come out like this:

    Bollards | Company A | 555-5555
    Bollards | Company B | 555-5678
    Bollards | Company C | 555-9999
    Gabions | Company D | 555-9876
    Gabions | Company E | 555-1234

    I'm trying to implement nested Repeaters so that the output looks something like this:

    Bollards:
    Company A | 555-5555
    Company B | 555-5678
    Company C | 555-9999
    Gabions:
    Company D | 555-9876
    Company E | 555-1234

    For some reason, my nested repeater is not being recognized as such. When I try to bind data to it earlier in my code, I get an error saying the repeater is undifined, although it rests just below the <ItemTemplate> tag of the first repeater. I tried specifying the DataSource in the <asp:repeater> tag, but that gives me a parse error.

    I'm not sure if my structure is right either, but here is that section of code (note this doesn't work currently):

    Code:
    <asp:Repeater ID="Repeater1" runat="server">
    <HeaderTemplate>
    		<table border="1">
       </HeaderTemplate>
        <ItemTemplate>
    		<asp:Repeater ID="Repeater2" runat="server" DataSource='values'>
    		 <ItemTemplate>
    		<tr>
             <td width="20">&nbsp;</td>
    		 <td><%#DataBinder.Eval(Container.DataItem, "SubType")%></b></i></td> 
             <td width="120"><%#DataBinder.Eval(Container.DataItem, "Company Name")%></td>
             <td width="110"><%#DataBinder.Eval(Container.DataItem, "Contact")%></td>
             <td width="110"><%#DataBinder.Eval(Container.DataItem, "Phone")%></td>
    		 <td width="30"><%#DataBinder.Eval(Container.DataItem, "Extension")%></td>
             <td width="110"><%#DataBinder.Eval(Container.DataItem, "Fax")%></td>
    		 <td width="110"><%#DataBinder.Eval(Container.DataItem, "Mobil")%></td>
    		 <td width="120"><%#DataBinder.Eval(Container.DataItem, "Extra")%></td>
    		 <td width="120">&nbsp;</td><p>
    		 </table>
    		 </tr>
    		 </ItemTemplate> 
    </asp:Repeater>
    </itemtemplate>
    </asp:Repeater>
    Any advice is SINCERELY appreciated! I'm stumped.

  • #2
    Senior Coder
    Join Date
    Dec 2002
    Location
    Arlington, Texas USA
    Posts
    1,062
    Thanks
    4
    Thanked 8 Times in 8 Posts
    you need to bind the child repeater to the parent repeater. here is an article that describes how to do this http://support.microsoft.com/default...b;EN-US;326338

  • #3
    New Coder
    Join Date
    May 2005
    Location
    The Lone Star State
    Posts
    47
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks Miranda! I'm off to a good start....

    Here's what I've got so far, and it seems like none of the little variations I've been trying work. If anybody can point me in the right direction, I'd be much obliged. Here's the important piece of the code:

    Code:
     cmdMbrs = New OleDbCommand( _
                "SELECT * " & _
    		"FROM tblSubType " & _
    		"WHERE (((tblSubType.SubType)=" & strWhere & "))" & _
    		"ORDER BY tblSubType.SubType;", conClsf)
    		
      cmdMbrs2 = New OleDbCommand( _
         "SELECT * " & _
    	 "FROM tblSubContractors " & _
    	 "WHERE (((tblSubContractors.SubType)=" & strWhere & "))" & _
    	 "ORDER BY tblSubContractors.SubType;", conClsf)
    		
    		
      Dim DA as OleDbDataAdapter = New OleDbDataAdapter
      Dim DA2 as OleDbDataAdapter = New OleDbDataAdapter
      
      DA.SelectCommand = cmdMbrs
      
      Dim ds As DataSet = New DataSet
      Dim tblType as DataTable
      Dim tblContractors as DataTable 
       
    		ds.Tables.Add("tblType")
    		ds.Tables.Add("tblContractors")
    			
      rdrMbrs = cmdMbrs.ExecuteReader
      
      DA.Fill("tblType", rdrMbrs)
      
      DA2.SelectCommand = cmdMbrs2
      
      conClsf.close
    	
      conClsf.Open
      
      rdrMbrs2 = cmdMbrs2.ExecuteReader
    		
      DA2.Fill("tblContractors", rdrMbrs2)
    		
    		Dim parentCol As DataColumn
        	Dim childCol As DataColumn
       
        	parentCol = ds.Tables("tblSubType").Columns("SubType")
        	childCol = ds.Tables("tblSubContractors").Columns("SubType")
    
    		
            myRel = New System.Data.DataRelation("Subs", parentCol, childCol)
    		ds.Relations.Add(myRel)
    		
            Repeater1.DataSource = ds.Tables("tblSubType")
               Repeater1.DataBind()
    					
      cmdMbrs.Dispose
      cmdMbrs2.Dispose
      conClsf.Close
    Please help! Thanks much.

  • #4
    New to the CF scene
    Join Date
    Sep 2008
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Same Problem

    I am also facing same problem. did your problem got solved? if yes please let me know. waiting for your early reply.


    -gk

  • #5
    New to the CF scene
    Join Date
    Jul 2008
    Location
    Cyech republic, Prague
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi,
    I would use server side event ItemCreated of the Repeater and in this event handler I would specify the output for each record.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •