Solved

Bind Gridview Results to Report Viewer

Posted on 2012-03-14
6
2,557 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
[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
  • 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
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…
Suggested Courses

752 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