title: Display data in Nested repeater control & how to pass value parentID from Parent Repeater to Child Repeater using asp.net
body: <p><img src="https://i.stack.imgur.com/yQ8SX.png" alt="Photo Album ">
  I have to display photo gallery as show in the image. I store information for photo gallery in 4 different tables. i need to show on main page CategoryName and Albums along with their respected Icon and link them to a AlbumCategoryPage.aspx.</p>
  
  <p>In order to achieve this i am using nested repeater control.</p>
  
  <p>Parent Repeater will show Category Image (as show in red color) and then show Top 4 albums in the same category and so in.</p>
  
  <p>So far  i have done it like this </p>
  
  <pre><code>            &lt;asp:Repeater ID="rptAlbumCategory" runat="server" OnItemDataBound="rptAlbumCategory_ItemBound"&gt;
                  &lt;ItemTemplate&gt;
                          &lt;!-- Repeated data --&gt;
                          &lt;div class="AlbumRowWrapper"&gt;
                              &lt;div id="dAlbumCategory" class="AlbumCategoryIcon"&gt;
                                  &lt;asp:Image ID="Image1" ImageUrl='&lt;%# getImagePath(Eval("CategoryImage")) %&gt;' runat="server" /&gt;
                              &lt;/div&gt;
                          &lt;/div&gt;
                          &lt;asp:Repeater ID="rptAlbums" runat="server" &gt;
                              &lt;ItemTemplate&gt;
                                  &lt;!-- Nested repeated data --&gt;
                              &lt;/ItemTemplate&gt;
                          &lt;/asp:Repeater&gt;
                      &lt;/ItemTemplate&gt;
              &lt;/asp:Repeater&gt;
  </code></pre>
  
  <p><strong>Code Behind</strong></p>
  
  <p>On Page Load</p>
  
  <pre><code> protected void Page_Load(object sender, EventArgs e)
      {
          if (!IsPostBack)
          {     //Get Gallery
              DataSet dsAlbumCat = new DataSet();
              string strSql = "SELECT * FROM AlbumCategory)";
              dsAlbumCat = DataProvider.Connect_Select(strSql);
              rptAlbumCategory.DataSource = dsAlbumCat;
              rptAlbumCategory.DataBind();
  }
  }
  
  protected void rptAlbumCategory_ItemBound(Object Sender, RepeaterItemEventArgs e)
  {
  
  if (e.Item.ItemType == ListItemType.Item)
  {
      Repeater childRepeater = (Repeater)e.Item.FindControl("rptAlbumCategory");
     // childRepeater.DataSource = getAlbums();
     // childRepeater.DataBind();
  }
  
  }
  
  protected void getAlbums()
  {
      DataSet dsAlbums = new DataSet();
      string strSql = "SELECT * FROM AlbumName WHERE CategoryID = " + CategoryID + ")";
      dsAlbums = DataProvider.Connect_Select(strSql);
      rptAlbums.DataSource = dsAlbums;
      rptAlbums.DataBind();
  }
  
  protected String getImagePath(object img)
  {
      string url;
      url = "~/Images/gallery/" + img;
  
      return url;
  }
  </code></pre>
  
  <p>With this code i am able to get the following result.
  <img src="https://i.stack.imgur.com/l7TaZ.png" alt="enter image description here"></p>
  
  <p>I am not sure how i can pass the CategoryID from the parent repeater to Child repeater so that it will show me the related albums.</p>
  
  <p>I am using nested repeater for first time &amp; find it confusing as i cant find complete example related to my scenario </p>
  
  <p>Table structure</p>
  
  <pre><code>TABLE AlbumCategory
  CategoryID
  CategoryName
  CategoryImageIcon
  CategoryVisible
  LanguageID
  
  TABLE AlbumName
  AlbumID
  AlbumName
  AlbumDescription
  AlbumImageIcon
  CategoryID
  LanguageID
  </code></pre>
  
  <p>I would appreciate help in this regard even best approach to accomplish the same design as show in first image</p>