2014年4月9日 星期三

RDLC Subreport 讀取

設計RDLC時,通常都是習慣先在BISD(後來改叫SSDT) 建一個報表專案,然後撰寫SQL設計LAYOUT確認報表內容沒問題後再將

讀取MAIN RDLC應該不是問題

 讀取子報表,只需在原來讀取MAIN RDLC的程式碼加入以下

ReportVierwe1.LocalReport.SubreportProcessing += new SubreportProcessingEventHandler(SetSubReportData);

ReportViewer1.LocalReport.Refresh();

void SetSubReportData(object sender, SubreportProcessingEventArgs e)
 {

        int sn = int.Parse(e.Parameters["p_sn"].Values[0]); //子表傳遞參數值
      
        string dsname= string.Empty; //每張子表的datasetname,不同子表要給不同名
      
        DataTable dtsource =new DataTable();//報表資料來源,這里是用datatable回傳型態

        switch(e.ReportPath)  //依子表名稱(rdlc的檔名)來讀取資料
                {
                    case "rdlcname1":
                         dsname = "DS1"; //dataset name in rdlc
                         dt = datasource1; //your sql data table ,code by self
                      break;
                    case "rdlcname1":
                         dsname = "DS2"; //dataset name in rdlc
                         dt = datasource2; //your sql data table ,code by self
                      break;
                 }

           e.DataSources.Add(new ReportDataSource(dsname,dt ));  //設定來源

}

IIS 網站無法下載中文檔名檔案因為取消高位元字元

 網址+中文檔案名稱方式下載檔案顯示 404 - 找不到檔案或目錄。 但英數字檔案名稱則可下載。 因為設定GCB IIS,其中1項 將高位元字元預設取消勾選了。 27 TWGCB-04-014-0028 要求篩選與其他限制模組 允許高位元字元 這項原則設定決定查詢...