比方說,我有一個像這樣的數據:綁定ASP.NET 2.0的GridView我自己的IList <T> .SomeMemberOfMyOwnCustomType.SomeProperty
class Location
{
public int Id { get; private set; }
public string City { get; set; }
public string State { get; set; }
public string Country { get; set; }
}
class Friend
{
public int Id { get; }
public string FriendName { get; set; }
public Location Address { get; set; }
public int Age { get; set; }
public bool IsReliable { get; set; }
}
比方說,我綁定一個ASP.NET 2.0 GridView控件我自己的IList像這樣:
GridView1.DataSource = new List<Friend>
{
new Friend { Name = "...", Age = 22, ... }
};
GridView1.DataBind();
但我想有隻在我的GridView下面列,分別自定義標題/列標題:
- FRIENDNAME(列標題:好友名稱)
- 市(列標題:市)
- 年齡(列標題:年齡)
我該怎麼辦呢?
換句話說,我如何選擇性地將GridView控件綁定到自定義IList的自定義成員?