Solved

Bind Gridview Results to Report Viewer

Posted on 2012-03-14
6
2,490 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Run time Error 4 48
ASP.NET - Bind Gridview Datasource to a specific table in dataset 3 27
mail.To.Add 5 28
No Data for DropDown List 2 26
I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
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.

821 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