Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 792
  • Last Modified:

How to display property list<> from ObjectDataSource to ListView

Dear Experts,

is it possible to put <asp:listview /> in <asp:listview /> ?
How to display RoomTypeName and RoomAmenities to the ListView Control from ObjectDataSource?

Thank you.

public class RoomInformation
        public string RoomTypeName { get; set; }
        public List<string> RoomAmenities { get; set; }
public List<RoomInformation> GetRoomInformation()
<asp:ListView ID="ListViewRoomInformation" runat="server" DataSourceID="objRoomInformation">
            <asp:PlaceHolder runat="server" ID="itemPlaceholder"></asp:PlaceHolder>
<asp:ObjectDataSource ID="objRoomInformation" runat="server"

Open in new window

1 Solution
David RobitailleAnalyst ProgrammerCommented:
i did something similar. i fastly adapted it, but you should get the point...
it work wit 2 neasted ListView, so you should add a ListViewRoomAmenities listview
Sorry, but it<s a VB.net

Protected Sub ListViewRoomInformation_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs)
        'check if it's a item
        If e.Item.ItemType = ListItemType.AlternatingItem Or _
            e.Item.ItemType = ListItemType.Item Then
            'get the item's data
            Dim RoomInformationData As RoomInformation = CType(e.Item.DataItem, RoomInformation)
            Dim RoomAmenities As ListView = e.Item.FindControl("ListViewRoomAmenities")
            RoomAmenities.DataSource = RoomInformationData.RoomAmenities 
        End If
    End Sub

Open in new window

hotexAuthor Commented:
Thank you for the solution davrob60, but finally I choose to use 2 objectDataSource :)

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now