Does reportviewer display no object value?

Asked

Viewed 216 times

0

I am trying to generate a report with Reportviewer about the items of a sale, the report is displayed but in the product column instead of appearing the product appears #Erro. My classes are all with [Serializable] but still not working and returns the Warning: Warning: A expressão Value para textrun ‘produto.Paragraphs[0].TextRuns[0]’ contém um erro: Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed. (rsRuntimeErrorInExpression).

The strange thing is that if I give one foreach in the list before generating the report the information is displayed in the Console and tbm in Reportviewer correctly. But passing the list directly without the foreach doesn’t work.

How to solve this problem ?

Generating report.

private void geraRelContasReceberDetalhado() {
            foreach (ItemVenda iv in this.listaItens) {
                Console.WriteLine("produto: " + iv.produto.descricao);
            }
            reportViewer.Reset();
            reportViewer.LocalReport.ReportPath = @"..\..\reports\RelContasReceberDetalhado.rdlc";
            ReportDataSource rds = new ReportDataSource("DataSetRelContasReceberDetalhado", this.listaItens);
            //List<ReportParameter> listParams = new List<ReportParameter>();                
            // rv.LocalReport.SetParameters(listParams);
            reportViewer.LocalReport.DataSources.Add(rds);
        }

Classes

//ItemVenda
[Serializable]
    public class ItemVenda {

        public virtual long id                      { set; get; }
        public virtual Venda venda                  { set; get; }
        public virtual Produto produto              { set; get; }
        public virtual decimal valorUn              { set; get; }
        public virtual int quantidade               { set; get; }
        public virtual decimal total                { set; get; }

        public ItemVenda() {            
        }
    }


[Serializable]
    public class Produto {

        public virtual long id                              { set; get; }        
        public virtual string descricao                     { set; get; }
        public virtual CategoriaProduto categoriaProduto    { set; get; }
        public virtual UnidadeProduto unidadeProduto        { set; get; }
        public virtual decimal valorCusto                   { set; get; }
        public virtual decimal valorVenda                   { set; get; }
        public virtual int qtdEstoque                       { set; get; }
        public virtual int estoqueMin                       { set; get; }
        public virtual int estoqueMax                       { set; get; }
        public virtual int status                           { set; get; }
        public virtual string imagem                        { set; get; }

        public Produto() {            
        }

        public override string ToString() {
            return descricao;
        }

    }

Print of the report.

inserir a descrição da imagem aqui

  • This list comes from the ORM Entity Framework?

  • @Virgilionovic I’m using Nhibernate with Fluentnhibernate.

  • 1

    Make a check and bring those formatted items gets better or make a query with Join.

  • @Virgilionovic I will try !

  • You did it @Fernandopaiva?

  • @Virgilionovic no, so I kept the foreach before invoking the report and so a gambiarra that works.

  • put in the question where the variable results this.listItens. I’ll see and answer you.

  • @Virgilionovic she is a IList<ItemVenda> which I pass as Dataset for the report. The weirdest thing is how I said, if I pass it without doing the foreach before it does not display the description of the product that is in its mapping. I have other reports that step tbm a IList like Dataset and I don’t have this problem, only in this item list that gave it. And all my classes are with [Serializable] so I have no idea what it might be. Thank you.

  • Okay, put the lines that carry this list

Show 4 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.