2016-11-21 63 views
0

我已經在數據集中做了兩個查詢,然後我想將該查詢設置爲報表 第一個查詢用於主報表 第二個查詢用於子報表主報告中屬性字段之一顯示。如何使用數據集填充水晶報表aspx中的子報表

就像我將顯示數據(與其中:從主報告屬性字段)

請人幫我...

this is the screenshot form the code

^^但是這個代碼仍然是錯誤的

+0

粘貼代碼inste截屏 –

回答

0
ReportDocument RptDocument = new ReportDocument(); 
    protected void Page_Load(object sender, EventArgs e) 
    { 
      DataSet ds = "Your Dataset";   
      CrystalReportViewer1.DisplayGroupTree = false; 
      ds.Tables[0].TableName = "Main Report";  
      RptDocument.Load(Server.MapPath("your rpt file path")); 
      RptDocument.SetDataSource(ds.Table[0]); 
      RptDocument.Subreports[0].SetDataSource(ds.Tables[1]); 
      CrystalReportViewer1.ReportSource = RptDocument; 
      CrystalReportViewer1.DataBind(); 
      CrystalReportViewer1.Visible = true;   
    } 

請參考此代碼

+0

的廣告如果我使用來自數據集的查詢,該怎麼辦? (tableadapter) *)我使用visual studio 2012 –

+0

然後你必須採取2個不同的數據集,並將其分配給主報告和子報告。 –