views:

531

answers:

1

Hello all.

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 parameters 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.

+1  A: 

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

Hope this helps! --Dubs

Dubs
I changed comments in the code block to start with {''#} instead of {'} for better syntax highlighting.
Dubs
Thanks Dubs - I've been having a play today and I can see a lot of potential. now it's a case of weighing up the pros and cons of the different ways or presenting data!
Ricardo Deano
If you are looking for examples of what you can do with SSRS, this site has some very advanced reporting techniques: http://www.devx.com/dbzone/Article/37703/1954There's a few good blogs out there too, like this one: http://blogs.msdn.com/brianhartman/Have fun and good luck!
Dubs