C# 使用导航时,如何将数据源传递到本地报表->;去报到吗?

C# 使用导航时,如何将数据源传递到本地报表->;去报到吗?,c#,reporting-services,sql-server-2012,reporting,C#,Reporting Services,Sql Server 2012,Reporting,我们正在从Reporting Services远程迁移到本地,为此,我成功地将rdl文件转换为rdlc,并将ReportViewer更改为本地处理,并通过如下代码传递数据源: ReportDataSource data = new ReportDataSource("PARAGAINSA", new InventarioRptCs().Selecciona_Saldos_Articulo(locid, BodId,depid,FamId,NBid,imId,desde

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

  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)));
}
非常好,我也遇到过一些报告,其中有一些子报告要将数据源传递给子报告。我一直这样做:

  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)));
}
它也很有效,所以我很高兴地继续,直到我找到一个包含子报表的报表,子报表在其中一个字段中包含:

当我点击作为其他报告导航链接的字段时,我会看到 尚未为数据源“datasource”提供数据源实例。

所以我的问题是:我是否可以通过导航->转到报表将数据源传递到子报表中的报表?如果是,怎么做

我正在使用VS 2013和SQL server 2012


感谢阅读,请原谅我的英语不是我的第一语言,因为我无法找到另一种方法来解决这个问题,我做了以下操作来尝试模拟报告之间的导航,仅在远程处理模式下可用(据我所知)

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

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

然后使用css样式将光标设置为指针

 [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);
        });

    });
然后在另一个webform上,我只添加了一个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();
            }
        }

    }
}
受保护的无效页面加载(对象发送方,事件参数e)
{
如果(!Page.IsPostBack)
{
if(Request.QueryString[“Sub”]=“Doc”)
{
字符串_loc=Request.QueryString[“loc”];
字符串_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=新的CultureInfo(“en-US”);
DateTime Fecha=DateTime.Now;
如果(!string.IsNullOrEmpty(_loc))
loc_id=转换为32(_loc);
如果(!string.IsNullOrEmpty(_fecha))
Fecha=DateTime.ParseExact(_Fecha,“dd/MMM/yyyyy”,提供者);
如果(!string.IsNullOrEmpty(\u Ap\u Id))
Ap\u Id=转换为32(\u Ap\u Id);
如果(!string.IsNullOrEmpty(_TT_Id))
TT_id=转换为32(_TT_id);
如果(TT|u id==14 | TT|u id==15 | TT|u id==21)
{
List paramList=新列表();
paramList.Add(新报告参数(“LocId”,_loc));
添加(新的ReportParameter(“Fecha”,Fecha.ToShortDateString());
Add(新报告参数(“TT_Id”,“TT_Id”);
添加(新的报告参数(“TT_Doc”,_Ap_Id));
ReportDataSource data=新的ReportDataSource(“ARACLDS”,new InventariorPCS().Selecciana_Saldos_Articulo_Doc(loc_id,Fecha,TT_id,Ap_id).ToList());
RVSubNav.LocalReport.ReportPath=“Rdlcs\\ReporteKardexDoc.rdlc”;
RVSubNav.Visible=真;
RVSubNav.LocalReport.SetParameters(paramList);
RVSubNav.LocalReport.DataSources.Clear();
RVSubNav.LocalReport.DataSources.Add(数据);
RVSubNav.LocalReport.Refresh();
}
}
}
}
不确定这是不是最好的方法,但它完成了任务