Report is not displayed in Report Viewer when you pass parameters

Asked

Viewed 658 times

4

I am trying to display a report, but when I pass the parameters via code it does not load the report, if I let it open the browser and pass the parameters at runtime works normally.

Code of the Report Viewer:

<form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
        <rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="Verdana" Font-Size="8pt" Height="615px" ProcessingMode="Remote" WaitMessageFont-Names="Verdana" WaitMessageFont-Size="14pt" Width="820px">
            <ServerReport ReportPath="/Compras/Pedido" ReportServerUrl="http://srv-teste/ReportServer" />
        </rsweb:ReportViewer>
    <div>

    </div>
</form>

Code-Behind:

protected void Page_Load(object sender, EventArgs e)
{
    Microsoft.Reporting.WebForms.ReportParameter p1 = new Microsoft.Reporting.WebForms.ReportParameter("idFornecedor", "23");
    Microsoft.Reporting.WebForms.ReportParameter p2 = new Microsoft.Reporting.WebForms.ReportParameter("idPedido", "23");
    Microsoft.Reporting.WebForms.ReportParameter p3 = new Microsoft.Reporting.WebForms.ReportParameter("idPedidoCabecalho", "23");
    Microsoft.Reporting.WebForms.ReportParameter p4 = new Microsoft.Reporting.WebForms.ReportParameter("idobra", "23");
    Microsoft.Reporting.WebForms.ReportParameter p5 = new Microsoft.Reporting.WebForms.ReportParameter("idFat", "23");
    Microsoft.Reporting.WebForms.ReportParameter p6 = new Microsoft.Reporting.WebForms.ReportParameter("idMaterial", "23");

    this.ReportViewer1.ServerReport.SetParameters(p1);
    this.ReportViewer1.ServerReport.SetParameters(p2);
    this.ReportViewer1.ServerReport.SetParameters(p3);
    this.ReportViewer1.ServerReport.SetParameters(p4);
    this.ReportViewer1.ServerReport.SetParameters(p5);
    this.ReportViewer1.ServerReport.SetParameters(p6);
}

When I comment Page_load lines it works normally.

2 answers

1

Arrow the parameters this way:

ReportParameter[] Parametros = new ReportParameter[4];
Parametros[0] = new ReportParameter("idFornecedor", "23");
Parametros[1] = new ReportParameter("idPedido", "23"););
Parametros[2] = new ReportParameter("idPedidoCabecalho", "23");
Parametros[3] = new ReportParameter("idobra", "23");

Reportviewer1.LocalReport.Setparameters(Parameters);

1

Hi, Follow example below:

ReportParameter[] parametros = 
     { new ReportParameter("DATA_INICIAL",txtDataInicial.Text),
       new ReportParameter("DATA_FINAL",txtDataFinal.Text),
       new ReportParameter("SITUACAO_PEDIDO_VENDA", DwLSituacaoPedidoVenda.SelectedValue)
     };

        ReportViewer1.LocalReport.SetParameters(parametros);
        ReportViewer1.LocalReport.Refresh();

Browser other questions tagged

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