Im trying to make a report viewer (RDLC REPORT) with xml string as data source using asp.net c#
This is the 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>"
So i have added a dataset called st_DS
also created a rdlc report
i have added the following line of code
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager> <rsweb:ReportViewer ID="ReportViewer1" runat="server"></rsweb:ReportViewer>
and this is the code behind
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)); ReportViewer1.LocalReport.Refresh();
when i run the code it gives me a blank report with no data as
the text inside the red box is the response i got (XML)
any one can help me with this ,im so confused ! Thanks
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
i have found the solution
simply add the following dataset
Dataset ds = new Dataset(); ds.ReadXml(new XmlTextReader(new System.IO.StringReader(xml_resp))); ReportDataSource datasource = new ReportDataSource("st_DS", ds.Tables["Row"]);
i have to merge the 2 datasets at the report DataSource to make it works !