一些重要的代码如下: 公共类用户{ public int UserID {get; set;} public string UserName {get; set;} public Company TheCompany {get; set;} }
公共类公司{ public override ToString(){ return CompanyName; } public string CompanyName {get; set;} }
列出用户列表
问题:
|用户ID |用户名|公司名称| 我认为这些数据字段应该是UserID,UserName,TheCompany.CompanyName,但是我看不到CompanyName是空的;
I think these datafields should be UserID , UserName, TheCompany,and override Company.ToString() = CompanyName
But I can't sorting the companyName column and can't change company because the datatype is string can't covert to Company;
这些是解决这些问题的好方法吗?
答案 0 :(得分:0)
有点晚了,但是......
向UserList添加一个readonly字符串属性,返回TheCompany.CompanyName。