Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Report Viewer For Datagridview

Posted on 2016-10-30
3
Medium Priority
?
110 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 2000 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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!
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Loops Section Overview
Suggested Courses

885 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