ReportViewer 動態綁定

1.  aspx頁面代碼       

                 <asp:ScriptManager ID="ScriptManager1" runat="server">
                  </asp:ScriptManager>
                  <rsweb:ReportViewer ID="ReportViewer1" runat="server" Width="1090px" Font-Names="Verdana"
                          Font-Size="8pt" InteractiveDeviceInfos="(集合)" WaitMessageFont-Names="Verdana"
                          WaitMessageFont-Size="14pt" Height="523px">
                </rsweb:ReportViewer>

2.  頁面註冊 

            <%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
                   Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>

           也可在web.config註冊,避免每個頁面都需更改

 

3.

            this.ReportViewer1.LocalReport.DataSources.Clear();
            this.ReportViewer1.LocalReport.ReportPath =rdlc 文件路徑;
            this.ReportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource("數據集名稱", 綁定的數據源));
            this.ReportViewer1.LocalReport.Refresh();

4. 先建立數據集文件.xsd,可以添加數據集;可以添加自定義Table表,表的列名要和報表文件、數據源中的列名對應。

5.簡歷報表文件.rdlc,選擇需要的顯示類型,綁定數據集對應的列名進行顯示;自定義樣式,建立列、行的父組子組等操作。

發佈了33 篇原創文章 · 獲贊 9 · 訪問量 8萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章