Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. nested repeater

nested repeater

Scheduled Pinned Locked Moved ASP.NET
questioncsharpasp-net
17 Posts 4 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Dhyanga

    Sure. Thanks for the reply. Well these are the codes.

    <asp:Repeater runat="server" id="Repeater1">
    <HeaderTemplate>items<br /><br /></HeaderTemplate>
    <ItemTemplate>
    <b><%# DataBinder.Eval(Container.DataItem, "catagoryname") %></t>
    <br><%# DataBinder.Eval(Container.DataItem, "catagorydescription") %>

        <asp:Repeater ID="Repeater3" runat="server">
        
                 <ItemTemplate>
                 <br>Items: <%# DataBinder.Eval(Container.DataItem,"ItemName")%></t></t></t><%# DataBinder.Eval(Container.DataItem, "Amount") %>
                 <br><%# DataBinder.Eval(Container.DataItem, "ItemDescription") %></br>
                  </ItemTemplate>
                 </asp:Repeater>
                 
    
    </ItemTemplate>
          <separatortemplate>
             <br />
             <br />
             <br />
           </separatortemplate>
        </asp:Repeater>
    

    I have these in my ascx page.

    suchita

    M Offline
    M Offline
    Martin Jarvis
    wrote on last edited by
    #4

    You won't be able to access the Repeater3 control from the ascx directly as a new one is created for each databound item. If you handle the OnItemDataBound event on Repeater1 you'll be able to access the Repeater3 control using: e.Item.FindControl("Repeater3")


    Freestyle Interactive Ltd  Martin on .Net  Follow Me on Twitter

    N D 2 Replies Last reply
    0
    • D Dhyanga

      Sure. Thanks for the reply. Well these are the codes.

      <asp:Repeater runat="server" id="Repeater1">
      <HeaderTemplate>items<br /><br /></HeaderTemplate>
      <ItemTemplate>
      <b><%# DataBinder.Eval(Container.DataItem, "catagoryname") %></t>
      <br><%# DataBinder.Eval(Container.DataItem, "catagorydescription") %>

          <asp:Repeater ID="Repeater3" runat="server">
          
                   <ItemTemplate>
                   <br>Items: <%# DataBinder.Eval(Container.DataItem,"ItemName")%></t></t></t><%# DataBinder.Eval(Container.DataItem, "Amount") %>
                   <br><%# DataBinder.Eval(Container.DataItem, "ItemDescription") %></br>
                    </ItemTemplate>
                   </asp:Repeater>
                   
      
      </ItemTemplate>
            <separatortemplate>
               <br />
               <br />
               <br />
             </separatortemplate>
          </asp:Repeater>
      

      I have these in my ascx page.

      suchita

      N Offline
      N Offline
      Not Active
      wrote on last edited by
      #5

      You have not bound the nested Repeater so of course it will not display anything.

      <asp:Repeater ID="Repeater3" runat="server" DataSource='<%# ((SiteMapNode)Container.DataItem).ChildNodes %>'>


      I know the language. I've read a book. - _Madmatt

      D 1 Reply Last reply
      0
      • M Martin Jarvis

        You won't be able to access the Repeater3 control from the ascx directly as a new one is created for each databound item. If you handle the OnItemDataBound event on Repeater1 you'll be able to access the Repeater3 control using: e.Item.FindControl("Repeater3")


        Freestyle Interactive Ltd  Martin on .Net  Follow Me on Twitter

        N Offline
        N Offline
        Not Active
        wrote on last edited by
        #6

        Martin Jarvis wrote:

        You won't be able to access the Repeater3 control from the ascx directly

        Why not? See below.


        I know the language. I've read a book. - _Madmatt

        1 Reply Last reply
        0
        • M Martin Jarvis

          You won't be able to access the Repeater3 control from the ascx directly as a new one is created for each databound item. If you handle the OnItemDataBound event on Repeater1 you'll be able to access the Repeater3 control using: e.Item.FindControl("Repeater3")


          Freestyle Interactive Ltd  Martin on .Net  Follow Me on Twitter

          D Offline
          D Offline
          Dhyanga
          wrote on last edited by
          #7

          Thank you for the reply but still it didnt recognize Repeater3.. :(

          suchita

          1 Reply Last reply
          0
          • N Not Active

            You have not bound the nested Repeater so of course it will not display anything.

            <asp:Repeater ID="Repeater3" runat="server" DataSource='<%# ((SiteMapNode)Container.DataItem).ChildNodes %>'>


            I know the language. I've read a book. - _Madmatt

            D Offline
            D Offline
            Dhyanga
            wrote on last edited by
            #8

            Thank you for the reply but adding that line still couldn't recognize the Repeater3 .. :(

            suchita

            N 1 Reply Last reply
            0
            • D Dhyanga

              Thank you for the reply but adding that line still couldn't recognize the Repeater3 .. :(

              suchita

              N Offline
              N Offline
              Not Active
              wrote on last edited by
              #9

              SayamiSuchi wrote:

              couldn't recognize the Repeater3

              Please clarify what you mean by this. The example was for a nested Sitemap, you will of course need to adjust it to your usage.


              I know the language. I've read a book. - _Madmatt

              D 1 Reply Last reply
              0
              • N Not Active

                SayamiSuchi wrote:

                couldn't recognize the Repeater3

                Please clarify what you mean by this. The example was for a nested Sitemap, you will of course need to adjust it to your usage.


                I know the language. I've read a book. - _Madmatt

                D Offline
                D Offline
                Dhyanga
                wrote on last edited by
                #10

                I am taking datasource from the dataset which i passed it to the repeater1.I also tried like this:

                <asp:Repeater runat="server" id="Repeater1">
                <HeaderTemplate>items<br /><br /></HeaderTemplate>
                <ItemTemplate>
                <b><%# DataBinder.Eval(Container.DataItem, "catagoryname") %></t>
                <br><%# DataBinder.Eval(Container.DataItem, "catagorydescription") %>

                    <asp:Repeater ID="Repeater3" runat="server" DataSourceID="DataSourceMember">
                    
                             <ItemTemplate>
                             <br>Items: <%# DataBinder.Eval(Container.DataItem,"ItemName")%></t></t></t><%# DataBinder.Eval(Container.DataItem, "Amount") %>
                             <br><%# DataBinder.Eval(Container.DataItem, "ItemDescription") %></br>
                              </ItemTemplate>
                             </asp:Repeater>
                             <asp:SqlDataSource ID="DataSourceMember" runat="server" ConnectionString="server=myComp;uid=sa;pwd=sa;database=ItemCat" SelectCommand="SELECT \* FROM items where catID = '<%# DataBinder.Eval(Container.DataItem,"ID") %>'"  \\>
                
                </ItemTemplate>
                      <separatortemplate>
                         <br />
                         <br />
                         <br />
                       </separatortemplate>
                    </asp:Repeater>
                

                erros is : Parser Error Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately. Parser Error Message: The server tag is not well formed. Source Error: Line 193: </ItemTemplate> Line 194: </asp:Repeater> Line 195: <asp:SqlDataSource ID="DataSourceMember" runat="server" ConnectionString="server=myComp;uid=sa;pwd=sa;database=ItemCat" SelectCommand="SELECT * FROM items [ACN] Where catID = '<%# DataBinder.Eval(Container.DataItem,"ID") %>'" \> Line 196:

                suchita

                modified on Monday, July 26, 2010 2:10 PM

                N 1 Reply Last reply
                0
                • D Dhyanga

                  I am taking datasource from the dataset which i passed it to the repeater1.I also tried like this:

                  <asp:Repeater runat="server" id="Repeater1">
                  <HeaderTemplate>items<br /><br /></HeaderTemplate>
                  <ItemTemplate>
                  <b><%# DataBinder.Eval(Container.DataItem, "catagoryname") %></t>
                  <br><%# DataBinder.Eval(Container.DataItem, "catagorydescription") %>

                      <asp:Repeater ID="Repeater3" runat="server" DataSourceID="DataSourceMember">
                      
                               <ItemTemplate>
                               <br>Items: <%# DataBinder.Eval(Container.DataItem,"ItemName")%></t></t></t><%# DataBinder.Eval(Container.DataItem, "Amount") %>
                               <br><%# DataBinder.Eval(Container.DataItem, "ItemDescription") %></br>
                                </ItemTemplate>
                               </asp:Repeater>
                               <asp:SqlDataSource ID="DataSourceMember" runat="server" ConnectionString="server=myComp;uid=sa;pwd=sa;database=ItemCat" SelectCommand="SELECT \* FROM items where catID = '<%# DataBinder.Eval(Container.DataItem,"ID") %>'"  \\>
                  
                  </ItemTemplate>
                        <separatortemplate>
                           <br />
                           <br />
                           <br />
                         </separatortemplate>
                      </asp:Repeater>
                  

                  erros is : Parser Error Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately. Parser Error Message: The server tag is not well formed. Source Error: Line 193: </ItemTemplate> Line 194: </asp:Repeater> Line 195: <asp:SqlDataSource ID="DataSourceMember" runat="server" ConnectionString="server=myComp;uid=sa;pwd=sa;database=ItemCat" SelectCommand="SELECT * FROM items [ACN] Where catID = '<%# DataBinder.Eval(Container.DataItem,"ID") %>'" \> Line 196:

                  suchita

                  modified on Monday, July 26, 2010 2:10 PM

                  N Offline
                  N Offline
                  Not Active
                  wrote on last edited by
                  #11

                  Now we finally get to the issue, "Parser Error Message: The server tag is not well formed". You could have saved a few steps and gave this information at the beginning. This is not the best way to accomplish this. You understand you are going to create a new SqlDatasource for each item in the parent list? Handle the ItemDataBound event of the parent repeater and assign the datasource, perferably from a cached source.


                  I know the language. I've read a book. - _Madmatt

                  D 1 Reply Last reply
                  0
                  • N Not Active

                    Now we finally get to the issue, "Parser Error Message: The server tag is not well formed". You could have saved a few steps and gave this information at the beginning. This is not the best way to accomplish this. You understand you are going to create a new SqlDatasource for each item in the parent list? Handle the ItemDataBound event of the parent repeater and assign the datasource, perferably from a cached source.


                    I know the language. I've read a book. - _Madmatt

                    D Offline
                    D Offline
                    Dhyanga
                    wrote on last edited by
                    #12

                    itemDataBound event is like this right:

                        void Repeater1\_ItemDataBound(object sender, RepeaterItemEventArgs e)
                        {
                            RepeaterItem item = e.Item;
                            if ((item.ItemType == ListItemType.Item) ||
                                (item.ItemType == ListItemType.AlternatingItem))
                            {
                    
                                Repeater3 = e.Item.FindControl("Repeater3");
                                DataRowView drv = (DataRowView)item.DataItem;
                                Repeater3.DataSource = drv.CreateChildView("category\_item");
                                Repeater3.DataBind();
                            }
                        }
                    

                    but if i do like this, it give error as below: Repeater3 doesn't exits.. while ascx.cs code is

                    <asp:Repeater runat="server" id="Repeater1">
                    <HeaderTemplate>items<br /><br /></HeaderTemplate>
                    <ItemTemplate>
                    <b><%# DataBinder.Eval(Container.DataItem, "catagoryname") %></t>
                    <br><%# DataBinder.Eval(Container.DataItem, "catagorydescription") %>

                        <asp:Repeater ID="Repeater3" runat="server">
                        
                                 <ItemTemplate>
                                 <br>Items: <%# DataBinder.Eval(Container.DataItem,"ItemName")%></t></t></t><%# DataBinder.Eval(Container.DataItem, "Amount") %>
                                 <br><%# DataBinder.Eval(Container.DataItem, "ItemDescription") %></br>
                                  </ItemTemplate>
                                 </asp:Repeater>
                                 
                    
                    </ItemTemplate>
                          <separatortemplate>
                             <br />
                             <br />
                             <br />
                           </separatortemplate>
                        </asp:Repeater>
                    

                    suchita

                    N 1 Reply Last reply
                    0
                    • D Dhyanga

                      itemDataBound event is like this right:

                          void Repeater1\_ItemDataBound(object sender, RepeaterItemEventArgs e)
                          {
                              RepeaterItem item = e.Item;
                              if ((item.ItemType == ListItemType.Item) ||
                                  (item.ItemType == ListItemType.AlternatingItem))
                              {
                      
                                  Repeater3 = e.Item.FindControl("Repeater3");
                                  DataRowView drv = (DataRowView)item.DataItem;
                                  Repeater3.DataSource = drv.CreateChildView("category\_item");
                                  Repeater3.DataBind();
                              }
                          }
                      

                      but if i do like this, it give error as below: Repeater3 doesn't exits.. while ascx.cs code is

                      <asp:Repeater runat="server" id="Repeater1">
                      <HeaderTemplate>items<br /><br /></HeaderTemplate>
                      <ItemTemplate>
                      <b><%# DataBinder.Eval(Container.DataItem, "catagoryname") %></t>
                      <br><%# DataBinder.Eval(Container.DataItem, "catagorydescription") %>

                          <asp:Repeater ID="Repeater3" runat="server">
                          
                                   <ItemTemplate>
                                   <br>Items: <%# DataBinder.Eval(Container.DataItem,"ItemName")%></t></t></t><%# DataBinder.Eval(Container.DataItem, "Amount") %>
                                   <br><%# DataBinder.Eval(Container.DataItem, "ItemDescription") %></br>
                                    </ItemTemplate>
                                   </asp:Repeater>
                                   
                      
                      </ItemTemplate>
                            <separatortemplate>
                               <br />
                               <br />
                               <br />
                             </separatortemplate>
                          </asp:Repeater>
                      

                      suchita

                      N Offline
                      N Offline
                      Not Active
                      wrote on last edited by
                      #13

                      Repeater3 = e.Item.FindControl("Repeater3");

                      Of course it doesn't exist, what type is Repeater3? All you have is a name. You also understand FindControl needs to be cast to something useful?


                      I know the language. I've read a book. - _Madmatt

                      D 1 Reply Last reply
                      0
                      • N Not Active

                        Repeater3 = e.Item.FindControl("Repeater3");

                        Of course it doesn't exist, what type is Repeater3? All you have is a name. You also understand FindControl needs to be cast to something useful?


                        I know the language. I've read a book. - _Madmatt

                        D Offline
                        D Offline
                        Dhyanga
                        wrote on last edited by
                        #14

                        yes. i did like this:

                        Repeater3 =(Repeater) e.Item.FindControl("Repeater3");

                        now i have another error shown. The relation is not parented to the table to which this DataView points. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.ArgumentException: The relation is not parented to the table to which this DataView points. Source Error: Line 120: Repeater2 = (Repeater)e.Item.FindControl("Repeater2"); Line 121: DataRowView drv = (DataRowView)item.DataItem; Line 122: Repeater2.DataSource = drv.CreateChildView("CategoryToItem"); Line 123: Repeater2.DataBind(); Line 124: }

                        suchita

                        modified on Monday, July 26, 2010 4:38 PM

                        N 1 Reply Last reply
                        0
                        • D Dhyanga

                          yes. i did like this:

                          Repeater3 =(Repeater) e.Item.FindControl("Repeater3");

                          now i have another error shown. The relation is not parented to the table to which this DataView points. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.ArgumentException: The relation is not parented to the table to which this DataView points. Source Error: Line 120: Repeater2 = (Repeater)e.Item.FindControl("Repeater2"); Line 121: DataRowView drv = (DataRowView)item.DataItem; Line 122: Repeater2.DataSource = drv.CreateChildView("CategoryToItem"); Line 123: Repeater2.DataBind(); Line 124: }

                          suchita

                          modified on Monday, July 26, 2010 4:38 PM

                          N Offline
                          N Offline
                          Not Active
                          wrote on last edited by
                          #15

                          RTFM


                          I know the language. I've read a book. - _Madmatt

                          D A 2 Replies Last reply
                          0
                          • N Not Active

                            RTFM


                            I know the language. I've read a book. - _Madmatt

                            D Offline
                            D Offline
                            Dhyanga
                            wrote on last edited by
                            #16

                            Sorry, I couldn't get that. Can you explain that please ? I even included below code:

                            SqlCommand objCmd = new SqlCommand(query, cnx);
                            SqlDataAdapter objDA = new SqlDataAdapter(objCmd);
                            DataSet ds = new DataSet();
                            objDA.Fill(ds);
                            Repeater1.DataSource = ds;
                            Repeater1.DataBind();

                                    DataColumn c1 = ds.Tables\["category"\].Columns\["ID"\];
                                    DataColumn c2 = ds.Tables\["Items"\].Columns\["CatID"\];
                                    dRel = new DataRelation("CategoryToItem", c1, c2);
                                    ds.Relations.Add(dRel);
                            

                            suchita

                            1 Reply Last reply
                            0
                            • N Not Active

                              RTFM


                              I know the language. I've read a book. - _Madmatt

                              A Offline
                              A Offline
                              Adam R Harris
                              wrote on last edited by
                              #17

                              ROFL A+ man A+ ... :-D

                              If at first you don't succeed ... post it on The Code Project and Pray.

                              1 Reply Last reply
                              0
                              Reply
                              • Reply as topic
                              Log in to reply
                              • Oldest to Newest
                              • Newest to Oldest
                              • Most Votes


                              • Login

                              • Don't have an account? Register

                              • Login or register to search.
                              • First post
                                Last post
                              0
                              • Categories
                              • Recent
                              • Tags
                              • Popular
                              • World
                              • Users
                              • Groups