Solved

Report Viewer For Datagridview

Posted on 2016-10-30
3
57 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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

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…
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

630 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