以顾客和订单为例,一个顾客有多个订单.

主报表是顾客,子报表是订单,创建customer.rdlc,order.rdlc

customer.rdlc文本框属性,操作,转到报表,填写报表名,添加参数.

order.rdlc添加参数customerID

 

ReportView控件:

  protected void rpViewer_Drillthrough(object sender, DrillthroughEventArgs e)        

{            

          LocalReport lp = (LocalReport)e.Report;            

          string customerID= lp.GetParameters()["customerID"].Values[0].Trim();            

          List<Employee> lstOrder = OrderBLL.GetCustomerOrders(customerID);            

          lp.DataSources.Clear();               

          lp.DataSources.Add(new ReportDataSource("DataSet1", lstOrder));

 }