带有#erro对象的ReportViewer字段?

时间:2016-09-21 19:27:57

标签: c# winforms reportviewer

我正在使用Visual Studio 2012,现在我正在使用ReportViewer创建报告。为此,我创建了一个DataSet对象以将List作为DataSource传递。问题是我的对象与嵌套的其他对象有关系,当我向对象显示报告列时显示#Erro。我正在寻找一些解决方案,但还没有找到任何解决方案。

我怎么能这样做?

试图

public class Conta {

        public virtual long id                      { set; get; }
        public virtual Cliente cliente              { set; get; }
        public virtual String historico             { set; get; }
        public virtual DateTime dtLancamento        { set; get; }
        public virtual DateTime dtVencimento        { set; get; }
        public virtual decimal valorFinal           { set; get; }

        public Conta() {
        }
    }


public class Cliente {
        public virtual int id               { set; get; }
        public virtual string nome          { set; get; }

        public Cliente() {
        }

        public override string ToString() {
            return nome;
        }

    }

的ReportViewer

enter image description here

1 个答案:

答案 0 :(得分:0)

我找到了解决方案,非常简单。只在课程上添加[Serializable]

我做了

[Serializable]
public class Conta {

        public virtual long id                      { set; get; }
        public virtual Cliente cliente              { set; get; }
        public virtual String historico             { set; get; }
        public virtual DateTime dtLancamento        { set; get; }
        public virtual DateTime dtVencimento        { set; get; }
        public virtual decimal valorFinal           { set; get; }

        public Conta() {
        }
    }

[Serializable]
public class Cliente {
        public virtual int id               { set; get; }
        public virtual string nome          { set; get; }

        public Cliente() {
        }

        public override string ToString() {
            return nome;
        }

    }