0

I have nested repeater. First Repeater is showing CityName coming from CityTable. And Second repeater will display CityDetails that will come from another table on the basis of cityName.

Output Will Look like this.

City1

Data1
Data2

City2

Data3
Data4 and so on.

I took nested repeater for this.

<asp:Repeater ID="rp1" runat="server">
        <ItemTemplate>
         <%# GetImageSource( Eval("CityName"))%>
            <asp:Repeater ID="rp2" runat="server" >
                <ItemTemplate>
                   <%#DataBinder.Eval(Container.DataItem, "DealHeadline")%>
                </ItemTemplate>
            </asp:Repeater>
        </ItemTemplate>
    </asp:Repeater>

Now I am not getting the point how to show that second repeater data?

May be this is the not correct way to solve this issue. Please Suggest me correct way or any solution.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Pankaj Mishra
  • 20,197
  • 16
  • 66
  • 103

1 Answers1

0

I solved it the following way I hope it helps:

Aspx code:

  <asp:Repeater ID="CityRpt" runat="server"><ItemTemplate><li>
      <%# DataBinder.Eval(Container.DataItem, "City")%>

               <!-- start child repeater -->
              <ul class="subleveltwo">
              <asp:repeater id="BuildingRpt" datasource='<%# CType(Container.Dataitem,System.Data.DataRowView).Row.GetChildRows("RelationName") %>' runat="server">
                       <itemtemplate><li><%# DataBinder.Eval(Container.DataItem, "[""ColumnName""]")%><br></li></itemtemplate>
              </asp:repeater>
              </ul>
              <!-- end child repeater -->

      </li></ItemTemplate></asp:Repeater>
     </ul>
        <!-- end Parent repeater -->

Vb.Net Code:

 Dim propertyType As String = "Property_A"

    Dim ds As DataSet = MaxxDatabaseHelper.GetBuildingsByCity()


    'get distinct results into datatable
    Dim TableC As DataTable = (From myRow In ds.Tables(1).AsEnumerable()
        Where (myRow.Field(Of String)("Property_Type") = propertyType)
                       Select myRow).Distinct().CopyToDataTable()
    'add to dataset
    ds.Tables.Add(TableC)

    ds.Relations.Add("RelationName", ds.Tables(0).Columns("City"), ds.Tables(2).Columns("City"))

    If (ds IsNot Nothing Or ds.Tables(0).Rows.Count <> 0) Then
        CityRpt.DataSource = ds.Tables(0)
        'page bind 
        Page.DataBind()
    End If
Developer
  • 2,987
  • 10
  • 40
  • 51