在报告RDLC中传递参数

时间:2016-12-27 15:52:26

标签: c# asp.net rdlc

我正在生成报告并尝试将参数传递给此报告。我有两个文本文本框,我想插入范围,当我点击下载按钮时,它应该只下载该范围内的字段(例如rownumber为1到10的下载):

我的.aspx页面

<asp:Panel ID="pnlReport" runat="server" Visible="false">
        <rsweb:ReportViewer ID="rptViewer" runat="server" Font-Names="Verdana" Font-Size="8pt" WaitMessageFont-Names="Verdana" WaitMessageFont-Size="14pt" HyperlinkTarget="_blank">
            <LocalReport ReportPath="Reports/allAbstractByThemeRange.rdlc" ReportEmbeddedResource="RA.Reports.allAbstractByThemeRange.rdlc">
                <DataSources>
                    <rsweb:ReportDataSource DataSourceId="ObjectDataSource1" Name="allAbstractByThemeRangeDS" />
                </DataSources>
            </LocalReport>
        </rsweb:ReportViewer>
        <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="GetData" TypeName="allAbstractByThemeRangeDSTableAdapters.allAbstractByThemeRangeTableAdapter"></asp:ObjectDataSource>
        <asp:ObjectDataSource ID="odsAllAbstractByCategoryDS" runat="server" SelectMethod="GetData" TypeName="RA.Reports.allAbstractByThemeRangeDSTableAdapters.allAbstractByThemeRangeTableAdapter" OldValuesParameterFormatString="original_{0}"></asp:ObjectDataSource>
    </asp:Panel>

我的源代码:

ReportParameter rp1 = new ReportParameter("Parameter1", minRange.Text.ToString());
        ReportParameter rp2 = new ReportParameter("Parameter2", maxRange.Text.ToString());

        rptViewer.LocalReport.EnableHyperlinks = true;
        rptViewer.LocalReport.DataSources.Clear();
        getAllAbstractByThemeRangeDS();

        ReportDataSource datasource = new ReportDataSource("allAbstractByThemeRangeDS", dsResult.Tables[0]);

  /* here I am getting all the data , and in the dsResult I am able to fetch all the data, for e.g. all the records are getting stored into dsResult, now I want only 10 records from these all records. So I am trying to pass the parameter*/

        rptViewer.LocalReport.SetParameters(new ReportParameter[] { rp1, rp2 });
        rptViewer.LocalReport.DataSources.Add(datasource);
        this.rptViewer.LocalReport.Refresh();

我不知道如何编写该代码,以及如何将这些参数传递到.xsd文件中:

SELECT 
'' AS rowNumber,
'' AS title,
'' AS previewCategory,
'' AS previewTheme

0 个答案:

没有答案