SSRS & asp.net - passing parameters from .net to ssrs in report viewer
I am about to embark in using a report viewer in my .net page. I have a page that will search for a catgory, upon a button click, the category chosen will pass into the parameter of report viewer.
Now, given that I am a newbie to both SSRS and .net, I'd just like a bit of advice on how to tackle this.
Should I make the report in SSRS first and include the parameters in this report or can I make the report without the pa开发者_如何学Crameters specified, then programmatically enter this in the codebehind?
Basically, I know what I would like to do but not sure the best approach to take.
If anyone can offer advice, I would be most grateful.
Welcome to the world of ASP.NET reporting! SSRS has a bit of a learning curve, but once you get the hang of it, I'm sure you'll enjoy working with it.
I recommend creating the report first and including your parameters.
You can then set the parameter values in your code-behind like this:
Private Sub SetReportParameters(ByVal viewer As ReportViewer)
''# use parameters to pass info to report
Dim myStartDate As New ReportParameter("StartDate", Request.QueryString("startDt"))
Dim myEndDate As New ReportParameter("EndDate", Request.QueryString("endDt"))
Dim myRegion As New ReportParameter("Region", region)
Try
''# add parameters to the report
viewer.LocalReport.SetParameters( _
New ReportParameter() {myStartDate, myEndDate, myRegion})
Catch ex As Exception
ErrorLabel.Text = DATABASE_ERROR_MSG
End Try
End Sub
精彩评论