Report is not displayed in Report Viewer when I pass parameters

4

I'm 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 it works normally.

Report Viewer code:

<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 on the lines of Page_Load it works normally.

    
asked by anonymous 13.11.2014 / 17:35

2 answers

1

Arrows the parameters as follows:

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(Parametros);

    
28.10.2015 / 15:29
1

Hi, Here's the 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();
    
09.08.2016 / 22:25