mezencio mezencio - 1 month ago 10
C# Question

c# - How to pass the data from grid view to report Viewer?

Staff gave some research, but still could not understand how to do, I have little knowledge in C #.

I have a grid view where I add several items that were in it, now I need to move these items to a report View report.

I do not know how to do, it would be better to pass all data grid for vestments or pick up the item ids of each output as they are distinct values ​​(eg, are items that correspond to various outputs) and make a query and bring the data to the report ... what would be the most feasible??

Answer

Assuming you're in Local-Processing Mode since no further information was supplied.

ReportDataSource is how you supply data to a ReportViewer Control in local-mode. http://msdn.microsoft.com/en-us/library/ms251736(v=vs.90).aspx

Now after going to GridView Page on MSDN, I found that GridView.DataSourceObject implements IDataSource. (Which is a parameter option for creating a ReportDataSource).

Meaning you should be able to create a ReportDataSource to supply to your ReportViewer Control, just create the ReportDataSource (Rds) from your GridView like so,

ReportDataSource Rds = new ReportDataSource("DataSetName", GridView.DataSourceObject);
Comments