繁体   English   中英

通过asp.net代码填充rdlc报告

[英]Filling rdlc report via asp.net code

我正在尝试使用类型化数据集填充RDLC报告。 我正在尝试通过代码填充它,但不知道在特定位置放置什么内容。

数据集名称为GPSDBDataSet.XSD,如果为Report.rdlc,则为报告名称,数据表名称为坐标。

使用Microsoft.Reporting.WebForms;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        ReportViewer1.Visible = true;

            ReportDataSource rds = new ReportDataSource();

            ReportViewer1.Reset();

            ReportViewer1.ProcessingMode = ProcessingMode.Local;

            LocalReport rep = ReportViewer1.LocalReport;                      

            rep.Refresh();

            rep.ReportPath = "Report.rdlc";


            rds.Name = ???????;


            rds.Value = ????;

            rep.DataSources.Add(rds);
    }
}

已经有一段时间了,但是尝试一下。

rds.name =“ yourdatasetname” //在您的情况下,直到被修改为止

rds.value = ds.table [0];

代码DataSet ds = new DataSet();

try
{
    ds = RetrieveData();//some func that returns dataset...
    ReportDataSource reportDataSource = new ReportDataSource();
    // Must match the DataSource in the RDLC
    reportDataSource.Name = "DataSet1";//coordinates in your case.
    reportDataSource.Value = ds.Tables[0];
    ReportViewer1.LocalReport.DataSources.Clear();
    ReportViewer1.LocalReport.DataSources.Add(reportDataSource);
    ReportViewer1.LocalReport.Refresh();

}
catch (Exception Ex)
{
    throw new Exception("Error Generating the Report", Ex);
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM