Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post May 29, 2012 03:31 PM by Ana D.
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 !!!
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 :)
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:
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.
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
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.
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")
Of course, I'm ommiting a some details, but I guess you can have an idea of how to implement it. Hope it helps :)
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?
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:
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.