Solved

Report Viewer For Datagridview

Posted on 2016-10-30
3
31 Views
Last Modified: 2016-11-29
Hi Evry1....

I want to Generate Report viewer for Datagridview Contained data...I've Binded Grid Data Into Datatable but confused how to assign this table to Reportviewer ..
Can anyone Help me Please???

Thanks Regards
$@i
0
Comment
Question by:Sai Kumar
3 Comments
 

Author Comment

by:Sai Kumar
ID: 41866442
I have Tried This Code...Error has Occured


            DataTable dt = new DataTable();
            foreach (DataGridViewColumn col in dataGridView1.Columns)
            {
                dt.Columns.Add(col.HeaderText);
            }

            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                DataRow dRow = dt.NewRow();
                foreach (DataGridViewCell cell in row.Cells)
                {
                    dRow[cell.ColumnIndex] = cell.Value;
                }
                dt.Rows.Add(dRow);
            }

            ReportDataSource source = new ReportDataSource("DataTable1", dt);

            this.reportViewer1.ProcessingMode = ProcessingMode.Local;
            this.reportViewer1.LocalReport.ReportPath = "DataTable1.rdlc";
            reportViewer1.LocalReport.DataSources.Clear();
            reportViewer1.LocalReport.DataSources.Add(source);
            reportViewer1.RefreshReport();
0
 
LVL 21

Accepted Solution

by:
Tapan Pattanaik earned 500 total points
ID: 41866504
Hi Sai,

Please check your report viewer path and data source table. Follow the steps mentioned in below URL.
For more details check the below URL.

        ReportViewer1.ProcessingMode = ProcessingMode.Local;
        ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/Report.rdlc");
        Customers dsCustomers = GetData("select top 20 * from customers");// Change your code accordingly
        ReportDataSource datasource = new ReportDataSource("Customers", dsCustomers.Tables[0]);
        ReportViewer1.LocalReport.DataSources.Clear();
        ReportViewer1.LocalReport.DataSources.Add(datasource);

ASP.Net Report Viewer control:

http://www.aspsnippets.com/Articles/ASPNet-Report-Viewer-control-Tutorial-with-example.aspx

You can find Other Examples which will guide you to solve your problem:
ASP.NET 2.0 ReportViewer in Local Mode:
http://www.codeproject.com/Articles/15597/Using-the-ASP-NET-2-0-ReportViewer-in-Local-Mode
RDLC Local Report in ASP.Net to Download in Doc PDF and Excel Format :
http://www.c-sharpcorner.com/UploadFile/ca9151/how-to-use-rdlc-local-report-in-Asp-Net/
RDLC Report Example in Asp.net with Dataset or Datatable :
http://www.aspdotnet-suresh.com/2014/12/rdlc-report-example-in-aspnet-with-dataset-datatable-in-visual-studio-2010.html
How to create report using ReportViewer in ASP.NET:
http://getcodesnippet.com/2014/05/06/how-to-create-report-using-reportviewer-in-asp-net/
0
 
LVL 14

Expert Comment

by:frankhelk
ID: 41905432
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

I have recommended this question be closed as follows:

Accept: Tapan Pattanaik (https:#a41866504)

If you feel this question should be closed differently, post an objection and the moderators will review all objections and close it as they feel fit. If no one objects, this question will be closed automatically the way described above.

frankhelk
Experts-Exchange Cleanup Volunteer
0

Featured Post

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question