locked
Bind ListView inside Listview RRS feed

  • Question

  • User944339287 posted

    Hi guys.. i getting error while i try to Bind Listview inside Listview. Please help me. TQ

    Object reference not set to an instance of an object.

    CODE BEHIND

        Protected Sub lvCarouselSlider_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.ListViewItemEventArgs) Handles lvCarouselSlider.ItemDataBound
    
            If (e.Item.ItemType = ListViewItemType.DataItem) Then
    
                Dim lvIndicators As ListView = CType(e.Item.FindControl("lvIndicators"), ListView)
    
                Dim DS As New DataSet()
                DS.ReadXml(MapPath("~/App_Data/rhythmSlider.xml"))
    
                Dim DR As DataRow() = DS.Tables(0).Select("status = 'Active'")
    
                DS.Tables(0).DefaultView.Sort = "priority DESC"
                DS.AcceptChanges()
    
                lvIndicators.DataSource = DR.CopyToDataTable
                lvIndicators.DataBind()
    
            End If
    
        End Sub

    HTML:

    <asp:ListView ID="lvCarouselSlider" runat="server" GroupItemCount="1">
        <LayoutTemplate>
           <div>
              <asp:ListView ID="lvIndicators" runat="server" GroupItemCount="1">
                  <LayoutTemplate>
                     <asp:PlaceHolder runat="server" ID="groupPlaceHolder"></asp:PlaceHolder>
                  </LayoutTemplate>
                  <GroupTemplate>                                                    
                     <asp:PlaceHolder runat="server" ID="itemPlaceHolder"></asp:PlaceHolder>
                  </GroupTemplate>
                  <ItemTemplate>
                     <li data-slide-to='<%# Container.DataItemIndex %>'></li>
                  </ItemTemplate>
              </asp:ListView>
        </LayoutTemplate>
        <GroupTemplate>                                                    
              <asp:PlaceHolder runat="server" ID="itemPlaceHolder"></asp:PlaceHolder>
        </GroupTemplate>
        <ItemTemplate>
              // MY CODE HERE
        </ItemTemplate>
    </asp:ListView>    


    Friday, February 23, 2018 6:41 AM

All replies