Solved

Bind Gridview Results to Report Viewer

Posted on 2012-03-14
6
2,462 Views
Last Modified: 2012-03-25
I have a web page with a gridview on it.  The gridview results are based on a data view through a session variable.

I need to bind the gridview results to report viewer, so that what's in the gridview shows in the report.

Anyone know of a quick concise way to get this accomplished?

Thanks!
0
Comment
Question by:jordanhelen
  • 3
  • 3
6 Comments
 
LVL 9

Expert Comment

by:abhinayp86
ID: 37722668
a better way is to use asp.net reportviewer and give it all the parameters required.
0
 

Author Comment

by:jordanhelen
ID: 37724938
Can you detail a little bit more?  I already have the gridview populating with data and need to populate report view with the data from the gridview.

Thanks.
0
 
LVL 9

Expert Comment

by:abhinayp86
ID: 37725255
something like this.
http://www.codeproject.com/Articles/15597/Using-the-ASP-NET-2-0-ReportViewer-in-Local-Mode

Since you dont have database in picture,
create an empty ssrs report, then use asp.net reportviewer control and give it a datatable (convert ur dataview into datatable)

in short, here are the things you need to set for the reportviewer control
ReportViewer1.ProcessingMode = Microsoft.Reporting.WinForms.ProcessingMode.Local 
        ReportViewer1.LocalReport.ReportPath = System.Environment.CurrentDirectory & "\yourReportName.rdlc" 
        ReportViewer1.LocalReport.DataSources.Clear() 
        ReportViewer1.LocalReport.DataSources.Add(New Microsoft.Reporting.WinForms.ReportDataSource("urDatasetNameInSSRS", yourDataTable)) 
        ReportViewer1.DocumentMapCollapsed = True 
        ReportViewer1.RefreshReport() 

Open in new window

0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:jordanhelen
ID: 37725874
Thank you.

I think I need to make myself a little clearer, sorry.

The report is not in SSRS, it is in Report Viewer and Report Viewer is on an .aspx page.
The gridview is on a separate .aspx page.
After the user filters the gridview and get results, a button (Print Report) is available on this page for the user to open report viewer and view, print or download the filtered data in the gridview.

For the gridview I have a dataset (mydataset)
A datatable (mydatatable)  equals the dataset
A dataview (mydataview) equals the datatable
And a session variable (mycriteria) equals the dataview.

In the Print Report on_click event, what would be the best way to retrieve the gridview’s filtered data so that it populates report viewer?
0
 
LVL 9

Accepted Solution

by:
abhinayp86 earned 500 total points
ID: 37726297
ohk.. So u essentially want another page or popup to just show the filter results and print or download them.

Say, Page1.aspx -- ur main gridview page
Create a new page Page2.aspx and put another gridview in it.

if page 1, when u click filter, save all your filter settings in another session variable in some format . Now after user clicks print report in page 1, open page2.aspx as a popup.
Since you have your filter settings and your dataview in session, they will also be available in page2.
So in Page2's page load, filter your dataview automatically and bind it to the gridview. Now to download that gridview, use the export to excell function here
http://web.archive.org/web/20101125095729/http://mattberseth.com/blog/2007/04/export_gridview_to_excel_1.html
0
 

Author Comment

by:jordanhelen
ID: 37729429
Thank you.

Actually I can only have one page with a gridview.  
I have created a session variable that holds this page's gridview selected value.
Now, how to get these values into report viewer is my issue.
I appreciate any detailed help with this.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.

912 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

21 Experts available now in Live!

Get 1:1 Help Now