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

hotexAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
hotexAuthor Commented:
Thank you for the solution davrob60, but finally I choose to use 2 objectDataSource :)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.