Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2715
  • Last Modified:

Bind Gridview Results to Report Viewer

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
jordanhelen
Asked:
jordanhelen
  • 3
  • 3
1 Solution
 
abhinayp86Commented:
a better way is to use asp.net reportviewer and give it all the parameters required.
0
 
jordanhelenAuthor Commented:
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
 
abhinayp86Commented:
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
jordanhelenAuthor Commented:
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
 
abhinayp86Commented:
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
 
jordanhelenAuthor Commented:
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now