locked
ASP.NET C# Report viewer total RRS feed

  • Question

  • User-1683022223 posted

    Hello , i have problem with  total calculate 

    ok in report viewer am making  parameter  for each raw

    in total expression i add

    =Sum(Parameters!ReportElectrical3.Value) 
    + Sum(Parameters!Reportcivil3.Value) 
    + Sum(Parameters!ReportMechanical3.Value) 
    + Sum(Parameters!Reportadaptation3.Value) 
    + Sum(Parameters!Reportcomputer3.Value)

    am getting total = 0

    screenshot

    Monday, March 15, 2021 6:13 PM

All replies

  • User-939850651 posted

    Hi kankonq8,

    I am not sure how you defined these parameters, I tried the ones you mentioned and got the correct results.

    This is my test:

    Result:

    So could you provided more details?

    Best regards,

    Xudong Peng

    Tuesday, March 16, 2021 6:58 AM
  • User-1683022223 posted

    my data from sql server

     protected void btnAllEng_Click(object sender, EventArgs e)
            {
                DataSet1 dsCustomers = new DataSet1();
    
                ReportViewer1.ProcessingMode = ProcessingMode.Local;
                ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/reportviewer/Report12.rdlc");
                ReportDataSource datasource = new ReportDataSource("DataSet1", dsCustomers.Tables[0]);
    
                ReportParameter[] param = new ReportParameter[23];
    
                param[0] = new ReportParameter("ReporlblUk2", lblUk2.Text);
    
                param[1] = new ReportParameter("ReportlblUsa", lblUsa.Text);
    
                param[2] = new ReportParameter("ReportlblUk", lblUk.Text);
    
                param[3] = new ReportParameter("Reportofficial", official.Text);
    
                param[4] = new ReportParameter("ReportAccountant", Accountant.Text);
    
                param[5] = new ReportParameter("ReportSecurity", Security.Text);
    
                param[6] = new ReportParameter("ReportSecurity2", Security2.Text);
    
                param[7] = new ReportParameter("ReportDriver", Driver.Text);
    
                param[8] = new ReportParameter("ReportElectrical1", Electrical1.Text);
    
                param[9] = new ReportParameter("ReportElectrical2", Electrical2.Text);
    
                param[10] = new ReportParameter("ReportElectrical3", Electrical3.Text);
    
                param[11] = new ReportParameter("Reportcivil1", civil1.Text);
    
                param[12] = new ReportParameter("Reportcivil2", civil2.Text);
    
                param[13] = new ReportParameter("Reportcivil3", civil3.Text);
    
                param[14] = new ReportParameter("ReportMechanical1", Mechanical1.Text);
    
                param[15] = new ReportParameter("ReportMechanical2", Mechanical2.Text);
    
                param[16] = new ReportParameter("ReportMechanical3", Mechanical3.Text);
    
                param[17] = new ReportParameter("Reportadaptation1", adaptation1.Text);
    
                param[18] = new ReportParameter("Reportadaptation2", adaptation2.Text);
    
                param[19] = new ReportParameter("Reportadaptation3", adaptation3.Text);
    
                param[20] = new ReportParameter("Reportcomputer1", computer1.Text);
    
                param[21] = new ReportParameter("Reportcomputer2", computer2.Text);
    
                param[22] = new ReportParameter("Reportcomputer3", computer3.Text);
    
                //param[23] = new ReportParameter("Reportmonthly", TextBox13.Text);
    
                ReportViewer1.LocalReport.SetParameters(param);
    
                ReportViewer1.LocalReport.DataSources.Clear();
                ReportViewer1.LocalReport.DataSources.Add(datasource);
    
                ReportViewer1.Visible = true;
                ReportViewer1.LocalReport.Refresh();
                
            }

    Tuesday, March 16, 2021 12:25 PM
  • User-939850651 posted

    Hi kankonq8,

    Sorry, at first I thought you were performing a test in SSRS. Now based on the information you provided, I also used the ReportViewer control and reproduced your problem。

    By modifying the expression, I solved the problem:

    =Parameters!ReportElectrical3.Value
    + Parameters!Reportcivil3.Value
    + Parameters!ReportMechanical3.Value
    + Parameters!Reportadaptation3.Value
    + Parameters!Reportcomputer3.Value

    There is no need to use built-in functions, just add them directly.

    You also need to set the parameter type correctly, like this:

    My test:

        <form id="form1" runat="server">
            <div>
                <asp:ScriptManager runat="server"></asp:ScriptManager>
                <rsweb:ReportViewer ID="ReportViewer1" runat="server"></rsweb:ReportViewer>
                <asp:TextBox runat="server" ID="Electrical3" />
                <asp:TextBox runat="server" ID="civil3" />
                <asp:TextBox runat="server" ID="Mechanical3" />
                <asp:TextBox runat="server" ID="adaptation3" />
                <asp:TextBox runat="server" ID="computer3" />
                <asp:Button Text="btnAllEng" ID="btnAllEng" OnClick="btnAllEng_Click" runat="server" />
            </div>
        </form>
    protected void btnAllEng_Click(object sender, EventArgs e)
            {
                DataSet1 dsCustomers = new DataSet1();
    
                ReportViewer1.ProcessingMode = ProcessingMode.Local;
                ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/reportviewer/Report12.rdlc");
                ReportDataSource datasource = new ReportDataSource("DataSet1", dsCustomers.Tables[0]);
                ReportParameter[] param = new ReportParameter[5];
                param[0] = new ReportParameter("ReportElectrical3", Electrical3.Text);
    
                param[1] = new ReportParameter("Reportcivil3", civil3.Text);
    
                param[2] = new ReportParameter("ReportMechanical3", Mechanical3.Text);
    
                param[3] = new ReportParameter("Reportadaptation3", adaptation3.Text);
    
                param[4] = new ReportParameter("Reportcomputer3", computer3.Text);
    
                ReportViewer1.LocalReport.DataSources.Clear();
        
                ReportViewer1.LocalReport.DataSources.Add(datasource);
                ReportViewer1.LocalReport.SetParameters(param);
                ReportViewer1.Visible = true;
                ReportViewer1.LocalReport.Refresh();
            }

    Result:

    Best regards,

    Xudong Peng

    Friday, March 19, 2021 8:11 AM