Webform下开发rdlc报表实现钻取功能!

Webform下开发rdlc报表实现钻取功能!  

2009-10-22 20:06:08|  分类: C#.net |  标签: |字号 订阅

 

参考了蜡人张的blog

http://www.cnblogs.com/waxdoll/archive/2006/06/23/434215.html

学着做了一下rdlc Drillthrough报表,但用winform的方法始终不能在webform中成功,点击链接后提示没有为"主报表的数据源"提供数据源实例,解决方法是需要在drillthrough事件函数中再绑定一次主表数据源...

 

   CustomerInfo GI = new CustomerInfo();
    DataSet ds = new DataSet();
  private DataTable LoadEmployeesData()
    {
        string strConn = ConfigurationManager.AppSettings["ConnectionString"].ToString(); ;
        SqlConnection conn = new SqlConnection(strConn);
        conn.Open();

        string strSql = "select * from tb_CustomerAnswer ";
        SqlCommand cmd = new SqlCommand(strSql, conn);
        SqlDataAdapter da = new SqlDataAdapter(cmd);
        da.Fill(ds,"1");
        conn.Close();


       
       
        return ds.Tables["1"];
    }

    private DataTable LoadDepartmentsData()
    {
        string strConn = ConfigurationManager.AppSettings["ConnectionString"].ToString(); ;
        SqlConnection conn = new SqlConnection(strConn);
        conn.Open();

        string strSql = "select * from tb_CustomerInfo ";
        SqlCommand cmd = new SqlCommand(strSql, conn);
        SqlDataAdapter da = new SqlDataAdapter(cmd);
        da.Fill(ds,"2");
        conn.Close();
        return ds.Tables["2"];
    }


    protected void ReportViewer1_Drillthrough(object sender, DrillthroughEventArgs e)
    {
      
        

        LocalReport Report = (LocalReport)e.Report;
      
        Report.DataSources.Add(new ReportDataSource("dsCustomerInfo_tb_CustomerAnswer",
                LoadEmployeesData()));
        Report.DataSources.Add(new ReportDataSource("dsCustomerInfo_tb_CustomerInfo",
                LoadDepartmentsData())); //这里是必须的,浪费了好长时间
          
       
    }
    protected void Page_Load(object sender, EventArgs e)
    {
      
        if (!IsPostBack)
        {
         
            // Supply a DataTable corresponding to each report data source.
            ReportViewer1.LocalReport.ReportPath = Server.MapPath("rptCustomerInfo.rdlc");
            ReportViewer1.LocalReport.DataSources.Add(
                new ReportDataSource("dsCustomerInfo_tb_CustomerInfo", LoadDepartmentsData())); 
                    }
       
        ReportViewer1.Drillthrough += new DrillthroughEventHandler(ReportViewer1_Drillthrough);
       
       
      
    }

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值