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

x
  • 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">
        <LayoutTemplate>
            <asp:PlaceHolder runat="server" ID="itemPlaceholder"></asp:PlaceHolder>
        </LayoutTemplate>
        <ItemTemplate>
 
        </ItemTemplate>
    </asp:ListView>
 
 
<asp:ObjectDataSource ID="objRoomInformation" runat="server"
        TypeName="RequestRoomInformation"
        SelectMethod="GetRoomInformation"
        OnSelecting="objRoomInformation_Selecting">
</asp:ObjectDataSource>

Open in new window

0
hotex
Asked:
hotex
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 
            RoomAmenities.DataBind()
        End If
 
    End Sub

Open in new window

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

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