Rdlc报告未在网页上显示数据

时间:2017-01-16 07:10:20

标签: c# asp.net

string sql = "select Prg_Name, Goal, Domain,Step_Desc_Oreginal FROM dbo.TBL_CTL_ControlProgram  where PRG_ID = " + prg_id;
DataSet ds = db.GetDS(sql, "CIBCTL");
DataTable dt = new DataTable();
dt.Columns.Add(new DataColumn("Step_Desc_Oreginal", typeof(string)));
dt.Columns.Add(new DataColumn("Prg_Name", typeof(string)));
dt.Columns.Add(new DataColumn("Domain", typeof(string)));
dt.Columns.Add(new DataColumn("Goal", typeof(string)));

        ///////////////////


        //////////////////
foreach (DataRow ProgRow in ds.Tables[0].Rows)
{
    dt.Rows.Add(ProgRow["Step_Desc_Oreginal"].ToString(), ProgRow["Prg_Name"].ToString(), ProgRow["Domain"].ToString(), ProgRow["Goal"].ToString());
}
ReportViewer1.ProcessingMode = ProcessingMode.Local;
ReportViewer1.Reset();
ReportDataSource rds = new ReportDataSource("DataSet1", dt);
//ReportViewer1.LocalReport.ReportPath = Server.MapPath(@"CIB_CTL\\ReportProg.rdlc"); //"CIB_CTL\\ReportProg.rdlc";

ReportViewer1.LocalReport.ReportPath = "ReportProg.rdlc";  //"CIB_CTL\\ReportProg.rdlc";//Server.MapPath(@"ReportProg.rdlc");

ReportViewer1.LocalReport.DataSources.Clear();
ReportViewer1.LocalReport.DataSources.Add(rds);
ReportViewer1.LocalReport.Refresh();






<rsweb:ReportViewer ID="ReportViewer1" runat="server"  Font-Names="Verdana" Font-Size="8pt"  WaitMessageFont-Names="Verdana" WaitMessageFont-Size="14pt" Width="950px" Height="550px" AsyncRendering="False">
    <ServerReport ReportServerUrl="" />
    <LocalReport ReportPath="ReportProg.rdlc">
        <DataSources>
            <rsweb:ReportDataSource DataSourceId="ObjectDataSource1" Name="DataSet1" />
        </DataSources>
    </LocalReport>
</rsweb:ReportViewer>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"  SelectMethod="GetData" TypeName="CIBPRJ.CIB_CTL.ProgDataSetTableAdapters.DataTable1TableAdapter"></asp:ObjectDataSource>

1 个答案:

答案 0 :(得分:0)

我认为没有必要提及aspx中的所有数据集信息以及后面的代码。您刚刚在aspx中输入了所有必需的代码。在其中排除这一行。

 <ServerReport ReportServerUrl="" />

没必要。您已在标记中指定了SelectMethod="GetData",但我无法在后端看到任何返回与Dataset1匹配的数据项的GetData方法。 因此,如果删除这些行,它将起作用

ReportViewer1.ProcessingMode = ProcessingMode.Local;
ReportViewer1.Reset();
ReportDataSource rds = new ReportDataSource("DataSet1", dt);
//ReportViewer1.LocalReport.ReportPath = Server.MapPath(@"CIB_CTL\\ReportProg.rdlc"); //"CIB_CTL\\ReportProg.rdlc";

ReportViewer1.LocalReport.ReportPath = "ReportProg.rdlc";  //"CIB_CTL\\ReportProg.rdlc";//Server.MapPath(@"ReportProg.rdlc");

ReportViewer1.LocalReport.DataSources.Clear();
ReportViewer1.LocalReport.DataSources.Add(rds);
ReportViewer1.LocalReport.Refresh();

并正确定义GetData。