I've got a RadGrid that uses an object collection as it's datasource. Each object/row has it's own collection of objects. When I display the grid I just display the first item in the sub-collection. So, for example, I have a grid of people. Each row is a person. Each person has a collection of addresses. In the "Address" column I have a Label, which I use to put the first address in the collection of addresses (using the OnItemCreated event). How do I specify the SortExpression so that I can sort this grid on the address displayed?
Here's my OnItemCreated method:
Thanks!
Eddie
Here's my OnItemCreated method:
| protected void RadGrid_ItemCreated(object sender, GridItemEventArgs e) |
| { |
| Person p = (Person) e.Item.DataItem; |
| if (e.Item.ItemType == GridItemType.Item || e.Item.ItemType == GridItemType.AlternatingItem) |
| { |
| Label lblAddress = (Label) e.Item.Cells[4].FindControl("lblAddress"); |
| if (p.Addresses != null) |
| { |
| if (p.Addresses.Count > 0) |
| { |
| Address address = p.Addresses[0]; |
| lblAddress.Text = address.StreetNumber.Trim() + " " + address.StreetName.Trim() + " " + |
| address.AptNumber.Trim(); |
| } |
| } |
| } |
| } |
Thanks!
Eddie