2014-06-15 62 views
0

我正在创建一个小型应用程序,并使用了Business Class。现在,我想创建报告。 首先,这是我的物业类别:如何在报表查看器中显示子类 - VS 2010

public class Property 
    { 
     public int PropertyId { get; set; } 
     public int OwnerId { get; set; } 

     //User is another Class 
     public User Owner { get; set; } 

     public int StaffUserId { get; set; } 
     public Staff StaffPerson { get; set; } 

     public string Address { get; set; } 
     public int NoGarage { get; set; } 
     public int NoRoom { get; set; } 
     public int NoToilet { get; set; } 
     public string PropertyType { get; set; } 
     public string PropertyStatus { get; set; } 
     public double SalePrice { get; set; } 

     public double RentPricePerMonth { get; set; } 
     public bool IsAvailable { get; set; } 
............... 

,这里是我的用户类别:

public class User 
{ 
    public int UserId { get; set; } 
    public string UserName { get; set; } 
    public string FirstName { get; set; } 
    public string LastName { get; set; } 
    public string Password { get; set; } 
    public string PhoneNo { get; set; } 
    public string Email { get; set; } 

现在我想创建一个使用Property类报告,也希望显示的User类。 我能够显示Property类的对象,但无法显示用户类。

我该怎么做?

目前我使用这生成报告:

 Property p = Property.GetPropertyByPropertyId(propertyId); 
     PropertyBindingSource.DataSource = p; 
     reportViewer1.RefreshReport(); 

回答

0

1.implement Serializable接口,以“用户”类

[Serializable] 
    public class User 
    { 

2.如果,如果你想显示的用户名,

在报告的设计中,该项目的表达设定

= Fields!Owner.Value.UserName

+0

我试过你的方式,但似乎没有发生。 –

相关问题