This is a migrated thread and some comments may be shown as answers.

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

1 Answer 99 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Chris asked on 20 Jun 2012, 09:46 AM

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...

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

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

Hope somebody can help me out! Thanks

1 Answer, 1 is accepted

Sort by
0
Tsvetina
Telerik team
answered on 25 Jun 2012, 09:02 AM
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:
http://www.telerik.com/help/aspnet-ajax/listview-accessing-controls.html

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,
Tsvetina
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.
Tags
ListView
Asked by
Chris
Top achievements
Rank 1
Answers by
Tsvetina
Telerik team
Share this question
or