locked
ReportVIewer with int parameter RRS feed

  • Question

  • User1131412122 posted
    In Page_Load method I try to got rows with specific number, let say "35":
                ReportParameter rp = new ReportParameter("NaloziIDparametar","35") ;
    ReportViewer1.LocalReport.SetParameters(new ReportParameter[] { rp });
    ReportViewer1.LocalReport.Refresh();
    
    
    In ReportViewer1.rdlc, I add parameter "NaloziIDparameter", integer and set some default value. When I run the application I
    got loading sign all the time. If I delete the code above Report works and got all rows od the dataset. What I'm doing wrong with
    passing parameter?
    Saturday, July 16, 2011 9:47 AM

Answers

  • User1471008070 posted

    Hi,

    Please add Page.IsPostBack in Page_Load event, so modify your code like this:

        protected void Page_Load(object sender, System.EventArgs e)

        {

            if (!Page.IsPostBack)

            {

                ReportParameter rp = new ReportParameter("NaloziIDparametar","35") ;
    ReportViewer1.LocalReport.SetParameters(new ReportParameter[] { rp });
    ReportViewer1.LocalReport.Refresh();

     

            }

           

        }

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, July 20, 2011 4:16 AM

All replies

  • User-843484705 posted

    First you need to add Parameter in your .RDLC 

    ReportParameter[] param = new ReportParameter[1];

    param[0] = new ReportParameter("NaloziIDparametar", "35");

    rptReportViewer.LocalReport.DataSources.Clear();

    //Get DataSet value
    reportDataAdapter.Fill(reportDataSet);

    reportDataSet.Tables[0].TableName = "StatisticsTable";

    ReportDataSource statisticsDataSourceDebt = new ReportDataSource("StatisticsTable", reportDataSet.Tables[0]);
    StatisticsSummaryDebtReportViewer.Visible = true;

    rptReportViewer.LocalReport.DataSources.Add(statisticsDataSourceDebt);

    rptReportViewer.LocalReport.SetParameters(param);

    // Finally refresh the local report.

    rptReportViewer.LocalReport.Refresh();


    Saturday, July 16, 2011 9:52 AM
  • User1131412122 posted

    I use the code below for a model:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;

    namespace MojERP.Models.Repository
    {
    public class NaloziRepository
    {
    public IQueryable<Nalozi> PokupiNaloge()
    {
    var podaci = new MojERPEntities();
    var nalozi = from p in podaci.Nalozi
    select p;
    return nalozi;
    }


    }
    }

    And can't figure out why I need to put dataset inside the code, when i already done that with the objectdatasource inside aspx page:

        <div>

    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="Verdana"
    Font-Size="8pt" InteractiveDeviceInfos="(Collection)"
    WaitMessageFont-Names="Verdana" WaitMessageFont-Size="14pt" Width="823px">
    <LocalReport ReportPath="Reports\IzvjestajNaloga.rdlc">
    <DataSources>
    <rsweb:ReportDataSource DataSourceId="ObjectDataSource1" Name="DataSetNalozi" />
    </DataSources>
    </LocalReport>
    </rsweb:ReportViewer>

    <asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
    SelectMethod="PokupiNaloge"
    TypeName="MojERP.Models.Repository.NaloziRepository"></asp:ObjectDataSource>

    </div>
    Sunday, July 17, 2011 4:23 AM
  • User1471008070 posted

    Hi,

    Please add Page.IsPostBack in Page_Load event, so modify your code like this:

        protected void Page_Load(object sender, System.EventArgs e)

        {

            if (!Page.IsPostBack)

            {

                ReportParameter rp = new ReportParameter("NaloziIDparametar","35") ;
    ReportViewer1.LocalReport.SetParameters(new ReportParameter[] { rp });
    ReportViewer1.LocalReport.Refresh();

     

            }

           

        }

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, July 20, 2011 4:16 AM