Reputation: 13
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??
Upvotes: 1
Views: 9014
Reputation: 543
you can use below code for viewing data in report viewer with gridview data.
int id =Convert.ToInt32(txtID.Text);
ReportViewer1.ProcessingMode = ProcessingMode.Local;
ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/Report1.rdlc");
DataTable dt = GridView1.DataSourceObject;
if (dt.Rows.Count > 0)
{
ReportDataSource rds = new ReportDataSource("DatasetName", dt);
ReportViewer1.LocalReport.DataSources.Clear();
ReportViewer1.LocalReport.DataSources.Add(rds);
}
Upvotes: 1
Reputation: 2867
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);
Upvotes: 1