Solved

Report Viewer For Datagridview

Posted on 2016-10-30
3
49 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone 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

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …
Suggested Courses

734 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