【问题标题】:How to make rdlc report from xml string?如何从 xml 字符串制作 rdlc 报告?
【发布时间】:2020-12-30 07:42:32
【问题描述】:

我正在尝试使用 asp.net c# 使用 xml 字符串作为数据源制作报表查看器 (RDLC REPORT) 这是xml

"<Data><Result>success</Result><Rowset><Row><Date>08-09-2020</Date><TrNo>2015</TrNo><Debit>355</Debit><Credit></Credit><Remark>rem in 2020015-500 USD/Commession</Remark><Balance>-809.5</Balance></Row></Rowset></Data>"  

所以我添加了一个名为 st_DS 的数据集

this is a photo for the dataset

还创建了 rdlc 报告 rdlc report

我添加了以下代码行

    <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>  
      <rsweb:ReportViewer ID="ReportViewer1" runat="server"></rsweb:ReportViewer> 

这是背后的代码

string xml_resp = objCmd.Parameters["p_out"].Value.ToString();  
        XmlTextReader reader = new XmlTextReader(new System.IO.StringReader(xml_resp));  
        st_DS stt = new st_DS();  
        stt.ReadXml(new XmlTextReader(new System.IO.StringReader(xml_resp)));   
        ReportViewer1.ProcessingMode = ProcessingMode.Local;  
        ReportViewer1.LocalReport.ReportPath = Server.MapPath("st.rdlc");  
        ReportViewer1.LocalReport.DataSources.Clear();             
        ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource("st_DS",stt.Tables[0])); 
        ReportViewer1.LocalReport.Refresh();  

当我运行代码时,它给了我一个没有数据的空白报告 the text inside the red box is the response i got (XML)

任何人都可以帮助我解决这个问题,我很困惑!谢谢

【问题讨论】:

    标签: c# asp.net dataset reporting reportviewer


    【解决方案1】:

    我找到了解决方案 只需添加以下数据集

     Dataset ds = new Dataset();
        ds.ReadXml(new XmlTextReader(new System.IO.StringReader(xml_resp)));
         ReportDataSource datasource = new ReportDataSource("st_DS", ds.Tables["Row"]); 
    

    我必须合并报表 DataSource 中的 2 个数据集才能使其正常工作!

    【讨论】:

      猜你喜欢
      • 2013-06-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-10-07
      • 1970-01-01
      • 2020-01-13
      相关资源
      最近更新 更多