Hi,
I need to produce report using Report Viewer,
I have created my DataSet.xsd file, designed my RDLC file and finally have it all working on the aspx file using the Report Viewer control. No problem at all.
My problem:
I need to change the data retrieved in the Dataset before displaying it in the RDLC report only, not to send the changes back to the Database.If it is a GridView matter, I will use GridView_RowDataBound to change the data before displaying it. In RDLC, I don’t'
have this flexibility.
Am I suppose to modify the data in the DataSet before using it?Any plans?
I solved my problem. Below is my solution that worked with me:
This code goes in aspx.vb file where the ReportViewer Control is placed on.
Dim mAdapter As New myDataSetAdapters.myTableAdapter
Dim mTable As myDataSet.myDataTable
mTable = mAdapter.GetData()
' The following will iterate in the Dataset DataTable and simply change the data.
For Each mItem As myDataSet.myDataTableRow In mTable
mItem.FIELDNAME = "UPDATED DATA"
Next
' Passing the updated DataTable in the DataSet to the RDLC report.
Dim repDataSource As ReportDataSource = New ReportDataSource("myDataSet_Table", mTable)
ReportViewer1.LocalReport.DataSources.Clear()
ReportViewer1.LocalReport.DataSources.Add(repDataSource)
ReportViewer1.LocalReport.ReportPath = MapPath("Report1.rdlc")
ReportViewer1.DataBind()
kbudijaja
0 Points
16 Posts
Update data in DataSet before passing it to the RDLC report
Feb 25, 2009 08:10 AM|LINK
Hi,
I need to produce report using Report Viewer,
I have created my DataSet.xsd file, designed my RDLC file and finally have it all working on the aspx file using the Report Viewer control. No problem at all.
My problem:
I need to change the data retrieved in the Dataset before displaying it in the RDLC report only, not to send the changes back to the Database.If it is a GridView matter, I will use GridView_RowDataBound to change the data before displaying it. In RDLC, I don’t' have this flexibility.
Am I suppose to modify the data in the DataSet before using it?Any plans?
Jian Kang - ...
All-Star
33132 Points
2465 Posts
Re: Update data in DataSet before passing it to the RDLC report
Mar 02, 2009 07:54 AM|LINK
Hi Khalid,
Based on your description, I think we can modify it in the corresponding “.cs” file of your Typed DataSet.
For example, we create the report page as follows:
<rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="Verdana" Font-Size="8pt" Height="400px" Width="400px"> <LocalReport ReportPath="Report11.rdlc"> <DataSources> <rsweb:ReportDataSource DataSourceId="ObjectDataSource1" Name="northwindDataSet1_Products" /> </DataSources> </LocalReport> </rsweb:ReportViewer> <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="GetData" TypeName="WebApplication1.northwindDataSet1TableAdapters.ProductsTableAdapter"> </asp:ObjectDataSource>And then we modify the records before rending:
northwindDataSet1.Designer.cs
Microsoft Online Community Support
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
kbudijaja
0 Points
16 Posts
Re: Update data in DataSet before passing it to the RDLC report
Mar 02, 2009 12:23 PM|LINK
Hi Jian,
Thank you for your reply.
I solved my problem. Below is my solution that worked with me:
This code goes in aspx.vb file where the ReportViewer Control is placed on.
Dim mAdapter As New myDataSetAdapters.myTableAdapter
Dim mTable As myDataSet.myDataTable
mTable = mAdapter.GetData()
' The following will iterate in the Dataset DataTable and simply change the data.
For Each mItem As myDataSet.myDataTableRow In mTable
mItem.FIELDNAME = "UPDATED DATA"
Next
' Passing the updated DataTable in the DataSet to the RDLC report.
Dim repDataSource As ReportDataSource = New ReportDataSource("myDataSet_Table", mTable)
ReportViewer1.LocalReport.DataSources.Clear()
ReportViewer1.LocalReport.DataSources.Add(repDataSource)
ReportViewer1.LocalReport.ReportPath = MapPath("Report1.rdlc")
ReportViewer1.DataBind()
Buzzthefrog
Member
2 Points
1 Post
Re: Update data in DataSet before passing it to the RDLC report
Jun 25, 2012 05:05 AM|LINK
Hi kbudijaja,
Can you tell me in which method did you put your code ?
Thanks & Regards,
Steve