0
I’m having a problem running a report on Viewer in c#.
The problem is the following I have to add a list in the data source, but it adds the first list, then no longer updates.
What Can Be ?
Code example.
List<auxFertilizanteRel> lstFert = new List<auxFertilizanteRel>();
for (int i = 0; i < ccbOpcaoFertilizante.Items.Count; i++)
{
if (ccbOpcaoFertilizante.GetItemChecked(i))
{
var listFertilizante = pFertilizante.ReturnAllByCiclo(ObjCiclo.objID, int.Parse(ccbOpcaoFertilizante.Items[i].ToString()), true);
var vMediaFertilizantes = cFertilizante.ReturnMedia(ObjCiclo, int.Parse(ccbOpcaoFertilizante.Items[i].ToString()));
foreach (var item in listFertilizante)
{
auxFertilizanteRel list = new auxFertilizanteRel();
list.cabecalho = ccbOpcaoFertilizante.Items[i].ToString();
list.codigoEstagio = item.codigoEstagio;
list.objID = item.objID;
list.descricao = item.descricao;
list.kgha = item.kgha;
list.daedap = item.daedap;
list.n = item.n;
list.p2o5 = item.p2o5;
list.k2o = item.k2o;
list.s = item.s;
list.ca = item.ca;
list.mg = item.mg;
list.b = item.b;
list.zn = item.zn;
list.cu = item.cu;
list.mn = item.mn;
list.co = item.co;
list.mo = item.mo;
list.marcado = item.marcado;
list.IDEstagioCultura = item.IDEstagioCultura;
list.IDCicloProducao = item.IDCicloProducao;
list.IDFornecedor = item.IDFornecedor;
list.opcao = item.opcao;
list.opcaoMarcada = item.opcaoMarcada;
list.eficiencia = item.eficiencia;
lstFert.Add(list);
}
}
}
reportAnalises.LocalReport.DataSources.Add(new ("dsFertilizante", lstFert))
this.reportAnalises.SetDisplayMode(DisplayMode.PrintLayout);
this.reportAnalises.ZoomMode = ZoomMode.FullPage;
this.reportAnalises.LocalReport.SetParameters(parametros);
this.btnEnviarPdf.Enabled = true;
this.reportAnalises.RefreshReport();
Tried cleaning reportAnalises.LocalReport.Datasources before adding again?
– Bruno Warmling
Yes I used at the beginning of the structure
– Michel Oliveira
I used this code "this.reportAnalises.Localreport.DataSources.Clear();" Only when I press the button to generate the report it accuses, saying that there is no data for dsFertilizante
– Michel Oliveira
Is your example correct? In Datasources.Add, are you actually adding a direct tuple? Shouldn’t it be a Reportdatasource?
– Bruno Warmling