I found a sample of a local report that uses a prameterized query. However, this example is using a drop down list control outside of the report viewer control to set the value for the parameter. My question is I thought the report viewer provided functionality
of this sort. Thanks !!!
Sorry, but I didn't get your question. Do you wanna know how to det the control as a parameter? If so, what you have to do is, in the aspx page that contains the report, click on the arrow besides your datasort and select "Configure Data Source...". Then,
when you get to "Define Parameter" you can select different parameter sources: it can be a query string, for example, retrieved from the url, but it can also be a control, such as a drop down list.
I hope I have answered your question, but if not, feel free to post more details on what you need to know :)
You can pass the parameter from the reportviewer using ReportParameters array or you can also call a report based on the querystring and process it further like below:
now you just use this url to process your request, and you can always set the value for those querystring from your any other control.
Ashutosh Pathak
Blog: http://catchcode.blogspot.com Please mark it as answer if it helps, as clicking on the button can save time of others :)
MCP,MCAD,MCSD,MCTS
Thanks Guy's. But all I was asking is if I wanted to use a stored procedure with parameters how would I implement that? I was under the impression that the viewer control works to where it knows that you are using a stored procedure with parameters? Thanks
!!!
I create some reports earlier this week, none of them have parameter. I call the stored procedure with parameter and which will return a dataset. then I assign the dataset to the reportviewer. I don't have to pass any parameter to the reportviewer. only
to the stored procedure.
For the report I created recently, I have created a dataset file, where I included about 6 datatables I was going to need for the reports. Then, in my reports, I created about 8 graphs, where I used the datatables from the dataset file as the datasource.
In addition, above each graph, I have created a textbox, which gets the title of the graph from the database. So, the value of my textbox was something like this:
Worked like a charm! As for the parameters for the report, I have created a page graphsViewer, where I added a local report with my rdlc file as the reportPath. Finally, in the code behind of GraphsViewer, I added the following to my Page_Load event:
Sure! In my case, I have a page with five gridviews and for each gridview I have linkButton "View Graphs". Then, when the user clicks on this link, the graphs page is opened passing the parameters in the query. So, in my default page I have the following:
I define the ID parameter based on which linkButton was clicked and the Year parameter I'm getting from a dropdownlist. Then in my graphs page, I just get this parameters back using the code I posted earlier. So, the same way I got the year from a ddl, you
can get it from any other control.
RSquared
Member
277 Points
395 Posts
ASP.Net Report Viewer Control
May 24, 2012 07:14 PM|LINK
I found a sample of a local report that uses a prameterized query. However, this example is using a drop down list control outside of the report viewer control to set the value for the parameter. My question is I thought the report viewer provided functionality of this sort. Thanks !!!
Ana D.
Member
139 Points
86 Posts
Re: ASP.Net Report Viewer Control
May 24, 2012 10:02 PM|LINK
Sorry, but I didn't get your question. Do you wanna know how to det the control as a parameter? If so, what you have to do is, in the aspx page that contains the report, click on the arrow besides your datasort and select "Configure Data Source...". Then, when you get to "Define Parameter" you can select different parameter sources: it can be a query string, for example, retrieved from the url, but it can also be a control, such as a drop down list.
I hope I have answered your question, but if not, feel free to post more details on what you need to know :)
Ashutosh Pat...
Contributor
5737 Points
1105 Posts
Re: ASP.Net Report Viewer Control
May 25, 2012 05:24 AM|LINK
You can pass the parameter from the reportviewer using ReportParameters array or you can also call a report based on the querystring and process it further like below:
http://localhost/reportserver?%2fFolder%2fMyReport&rs:Command=Render&YourParameterCountry=India&YourParameterState=Delhi
now you just use this url to process your request, and you can always set the value for those querystring from your any other control.
Blog: http://catchcode.blogspot.com
Please mark it as answer if it helps, as clicking on the button can save time of others :)
MCP,MCAD,MCSD,MCTS
RSquared
Member
277 Points
395 Posts
Re: ASP.Net Report Viewer Control
May 25, 2012 03:10 PM|LINK
Thanks Guy's. But all I was asking is if I wanted to use a stored procedure with parameters how would I implement that? I was under the impression that the viewer control works to where it knows that you are using a stored procedure with parameters? Thanks !!!
makwei88
Member
498 Points
115 Posts
Re: ASP.Net Report Viewer Control
May 25, 2012 08:34 PM|LINK
I create some reports earlier this week, none of them have parameter. I call the stored procedure with parameter and which will return a dataset. then I assign the dataset to the reportviewer. I don't have to pass any parameter to the reportviewer. only to the stored procedure.
Ana D.
Member
139 Points
86 Posts
Re: ASP.Net Report Viewer Control
May 25, 2012 08:50 PM|LINK
For the report I created recently, I have created a dataset file, where I included about 6 datatables I was going to need for the reports. Then, in my reports, I created about 8 graphs, where I used the datatables from the dataset file as the datasource. In addition, above each graph, I have created a textbox, which gets the title of the graph from the database. So, the value of my textbox was something like this:
Worked like a charm! As for the parameters for the report, I have created a page graphsViewer, where I added a local report with my rdlc file as the reportPath. Finally, in the code behind of GraphsViewer, I added the following to my Page_Load event:
param1 = Request.QueryString("paramName1") param2 = Request.QueryString("paramName2") MyReportViewer.LocalReport.Refresh() MyReportViewer.DataBind()Of course, I'm ommiting a some details, but I guess you can have an idea of how to implement it. Hope it helps :)
RSquared
Member
277 Points
395 Posts
Re: ASP.Net Report Viewer Control
May 29, 2012 03:04 PM|LINK
Thanks !!! Do you mind showing me how you implemented this. I mean where does the user select the value to send to the stored procedure?
Ana D.
Member
139 Points
86 Posts
Re: ASP.Net Report Viewer Control
May 29, 2012 03:31 PM|LINK
Sure! In my case, I have a page with five gridviews and for each gridview I have linkButton "View Graphs". Then, when the user clicks on this link, the graphs page is opened passing the parameters in the query. So, in my default page I have the following:
<asp:LinkButton ID="ViewGraphsButton" runat="server" Text="View Graphs" OnClientClick="javascript:window.open('MyGraphsPage.aspx?ID=1&Year=' + document.getElementById('FiscalYearDDL').options[document.getElementById('FiscalYearDDL').selectedIndex].value, '_blank'); return false;" />I define the ID parameter based on which linkButton was clicked and the Year parameter I'm getting from a dropdownlist. Then in my graphs page, I just get this parameters back using the code I posted earlier. So, the same way I got the year from a ddl, you can get it from any other control.