How do you display array data that is within an object in a Telerik RadListView?

2 posts, 0 answers
  1. Chris
    Chris avatar
    3 posts
    Member since:
    Jun 2012

    Posted 20 Jun 2012 Link to this post

    I am not sure of the best way to describe my question, as the title doesn't even make sense to me!

    What I am doing is calling a WCF Service and I get an Object back, within this object are a selection of elements and some arrays.

    So the object would be something like...(I would be passed the Person)

        public class Person
    string firstName;
    string lastName;
    Address[] addressDetails;
    public class Address
    string address1;
    string address2;
    string postcode;

    So then on my page, I would like to display not only firstName and lastName. But the details of the address. If you can imagine this page to be a profile view. So all the fields in a list and the ability to edit them.

    Currently I can access any element that is "top level" i.e. not within an array. I do that on the ascx page using the following code within a Telerik RadListView...

    <asp:Label ID="firstNameLabel" runat="server"
    AssociatedControlID="firstNameTextBox" Text="firstName"></asp:Label>
    <asp:TextBox ID="firstNameTextBox" runat="server" CssClass="rlvInput"
    Text='<%# Bind("firstName") %>' />

    So I guess what I am asking is; how do I display 'address1' on the page.

    Hope somebody can help me out! Thanks

  2. Tsvetina
    Tsvetina avatar
    1862 posts

    Posted 25 Jun 2012 Link to this post

    Hello Chris,

    If you have an array of addresses you could hardly use binding expressions, as you would need to hardcode indexes in mark-up. You should rather use the ItemDataBound event of the control and show the required values by accessing the labels that should display them:

    If you have a single Address in the Person class, you can use the approach shown in the project attached to this message - expose public properties and use them to display subclass information.

    Kind regards,
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. DevCraft R3 2016 release webinar banner
Back to Top