1

VS 2010 を使用しており、サンプル Web アプリケーションを作成しています。データセットとレポートを追加し、1 行だけを返す SP を作成しました。現在、変数は含まれていません。パラメータなしの単純な SP。Web アプリに aspx ページを追加し、そのページにレポート ビューアー コントロールを追加しました。私の Aspx ページは次のようになります。

    <rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="Verdana" 
        Font-Size="8pt" InteractiveDeviceInfos="(Collection)" 
        WaitMessageFont-Names="Verdana" WaitMessageFont-Size="14pt">
    </rsweb:ReportViewer>

コードビハインドは次のようになります。

protected void Page_Load(object sender, EventArgs e)
        {
            ReportViewer1.Visible = true;
            ReportDataSource dataSource = new ReportDataSource("DataSet1", LoadData().Tables[0]);
            ReportViewer1.LocalReport.DataSources.Clear();
            ReportViewer1.LocalReport.DataSources.Add(dataSource);
            ReportViewer1.LocalReport.Refresh();
        }

        private DataSet LoadData()
        {
            var dataset = new DataSet();
            using (var con = new SqlConnection(ConfigurationManager.ConnectionStrings["CString"].ConnectionString))
            {
                var command = new SqlCommand("[spSampleReport]")
                                  {
                                      Connection = con,
                                      CommandType = CommandType.StoredProcedure
                                  };

                var adap = new SqlDataAdapter(command);
                con.Open();
                adap.Fill(dataset, "DataSet1");
            }

            return dataset;
        }

私の Web 構成では、httphandlers セクションに以下を追加しました。

実行中、ページには何も表示されません。レポート ビューアのツールバーも表示されません。

4

2 に答える 2

2

私は ReportViewer の専門家ではありませんが、レポート ビューアーに何を表示するかを伝えるには .rdlc が必要だと思います。

ReportViewer.LocalReport.ReportPath = Server.MapPath(string.Format(@"~\Reports\Definitions\{0}.rdlc", reportName));

.rdlc の DataSet 名が、ReportDataSource の作成時に指定した DataSource と同じであることを確認してください

于 2012-11-02T05:51:03.827 に答える
0

コード例を使用してasp.netでrdlcレポートを生成する良い例を見つけました

http://www.dotnetsharepoint.com/2013/09/how-to-create-rdlc-reports-in-aspnet.html#.UjhvAsafh88

于 2013-09-17T15:04:31.417 に答える