繁体   English   中英

使用导航->转到报告时,如何将数据源传递到本地报告?

[英]How do you pass data source to a local report when you use Navigation-> Go to report?

我们正在从Reporting Services远程迁移到本地,为此,我已经成功地将rdl文件转换为rdlc,并将reportviewers更改为本地处理,并通过如下代码传递数据源:

  ReportDataSource data = new ReportDataSource("PARAGAINSA", new InventarioRptCs().Selecciona_Saldos_Articulo(locid,
            BodId,depid,FamId,NBid,imId,desde,hasta));
  ReportViewer1.LocalReport.DataSources.Clear();
  ReportViewer1.LocalReport.DataSources.Add(data);
  ReportViewer1.LocalReport.Refresh();

效果很好,我也遇到了一些带有一些子报表的报表,这些报表将数据源传递给我一直在这样做的子报表:

ReportViewer1.LocalReport.SubreportProcessing += new SubreportProcessingEventHandler(SubReporteHandler);

 private void SubReporteHandler(object sender, SubreportProcessingEventArgs e)
{
    int im_id =  Convert.ToInt32(e.Parameters[1].Values[0].ToString());
    int loc_id = Convert.ToInt32(e.Parameters[0].Values[0]);
    e.DataSources.Add(new ReportDataSource("PARAGAINSA", new InventarioRptCs().Selecciona_Saldos_Articulo_Det(loc_id,im_id)));
}

它也很好用,所以我很高兴继续直到找到包含子报表的报表,并且子报表在以下字段之一中具有此功能: 在此处输入图片说明

当我单击充当另一个报表的导航链接的字段时,得到此提示。尚未为数据源“数据源”提供数据源实例。

所以我的问题是:无论如何,我是否可以将数据源传递给通过导航调用的子报告内的报告->去报告? 如果是这样怎么办?

我在SQL Server 2012中使用VS 2013

谢谢您的阅读,请原谅我的英语而不是我的第一语言

由于我无法找到另一种方法来解决此问题,因此我做了以下尝试来模拟仅在远程处理模式下(据我所知)的报表之间的导航,

首先,在rdlc文件中,我在用作其他报告链接的列的title属性中添加了“ Ver mas informationacion”,并将“颜色”设置为蓝色以提供链接样式

步

我不得不添加工具提示(将标题赋予标题属性),因为我无法找到另一种方法来选择想要的那些特定单元格

然后使用CSS样式将Cursor设置为指针

 [title="Ver mas informacion"] {
        cursor:pointer;
    }

然后使用jquery来处理click事件的脚本将我需要的值作为参数传递给另一个报告,导航到另一个报告并通过URL传递参数

 $(window).load(function () {
        $(document).on('click', '[title="Ver mas informacion"]', function () {
            var locId = $('[id$="ddLocal"]').val();
            var Fecha = $(this).parent().parent()[0].childNodes[2].childNodes[0].innerHTML;
            var TT_Id = $(this).parent().parent()[0].childNodes[9].childNodes[0].innerHTML;
            var Ap_Id = $(this).parent().parent()[0].childNodes[10].childNodes[0].innerHTML;
            window.open(window.location.origin + config.base + '/Reportes/RptSubViewer.aspx?Sub=Doc&Loc=' + locId + '&Fecha=' + Fecha + '&AP=' + Ap_Id + '&TT_Id=' + TT_Id);
        });

    });

然后在其他Web表单上,我仅添加了一个reportviewer并在后面的代码上

  protected void Page_Load(object sender, EventArgs e)
{
    if (!Page.IsPostBack)
    {
        if (Request.QueryString["Sub"] == "Doc")
        {
            string _loc = Request.QueryString["Loc"];
            string _fecha = Request.QueryString["Fecha"];
            string _Ap_Id = Request.QueryString["AP"];
            string _TT_Id = Request.QueryString["TT_Id"];
            int loc_id = 0, TT_id = 0, Ap_Id = 0;
            CultureInfo provider = new CultureInfo("en-US");
            DateTime Fecha = DateTime.Now;
            if (!string.IsNullOrEmpty(_loc))
                loc_id = Convert.ToInt32(_loc);
            if (!string.IsNullOrEmpty(_fecha))
                Fecha = DateTime.ParseExact(_fecha,"dd/MMM/yyyy",provider);
            if (!string.IsNullOrEmpty(_Ap_Id))
                Ap_Id = Convert.ToInt32(_Ap_Id);
            if (!string.IsNullOrEmpty(_TT_Id))
                TT_id = Convert.ToInt32(_TT_Id);

            if (TT_id == 14 || TT_id == 15 || TT_id == 21)
            {

                List<ReportParameter> paramList = new List<ReportParameter>();
                paramList.Add(new ReportParameter("LocId", _loc));
                paramList.Add(new ReportParameter("Fecha", Fecha.ToShortDateString()));
                paramList.Add(new ReportParameter("TT_Id", _TT_Id));
                paramList.Add(new ReportParameter("TT_Doc", _Ap_Id));
                ReportDataSource data = new ReportDataSource("ARACLDS", new InventarioRptCs().Selecciona_Saldos_Articulo_Doc(loc_id, Fecha, TT_id, Ap_Id).ToList());
                RVSubNav.LocalReport.ReportPath = "Rdlcs\\ReporteKardexDoc.rdlc";
                RVSubNav.Visible = true;
                RVSubNav.LocalReport.SetParameters(paramList);
                RVSubNav.LocalReport.DataSources.Clear();
                RVSubNav.LocalReport.DataSources.Add(data);
                RVSubNav.LocalReport.Refresh();
            }
        }

    }
}

不知道最好的方法,但是它完成了工作

暂无
暂无

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

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