Solved

Report Viewer For Datagridview

Posted on 2016-10-30
3
14 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
Comment Utility
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
Comment Utility
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 13

Expert Comment

by:frankhelk
Comment Utility
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Introduction                                                 Was the var keyword really only brought out to shorten your syntax? Or have the VB language guys got their way in C#? What type of variable is it? All will be revealed.   Also called…
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.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

728 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now