Saed Al Shaar Dev Tips and Tricks

.NET and SharePoint from a different angle!

Report Viewer Parameters in Visual Studio 2010 – No Code


Hi Folks,

I’ve been trying since a long time finding an article of how to pass parameters to a Report Viewer control in Visual Studio 2010, but most of the articles needs lots of code to be written.

But, now I have found the way to create a report and pass parameters easily with only 1 line of code, yes I am serious 1 line of code!! 🙂

And below I will describe the steps with screen shots:
1- You need to create a new Visual Studio Web Site:

2- Then you will have an empty web site.

3- Now, I will create a new database with one table with three columns (ID, Name, City):

Then fill it with some data:

Now I will create a data set for the Contacts table:

Now I will Rebuild the web site:

Now, we need to add reference to Microsoft.ReportViewer.WebForms:
Make sure to select Version 10.0.0.0

Now, I will create a report:


Save the report.

Now, I will start to build the page of the report:
– Add a DropdownList and a Button:

– Drop a Script Manager control into the page:

– Drop a ReportViewer control:

– Choose the Report we created before, and an ObjectDataSource will be created directly:

– On the Click event of the button write the only Code you need to write to refresh the report:
ReportViewer1.LocalReport.Refresh()

Congratulations!! the web site is ready and the report takes the parameter and refreshes.

Happy programming!
Saed

Advertisements

Single Post Navigation

10 thoughts on “Report Viewer Parameters in Visual Studio 2010 – No Code

  1. F*ckin’ amazing things here. I’m very glad to see your post. Thanks a lot and i am looking forward to contact you. Will you kindly drop me a e-mail?

  2. Nizam on said:

    very nice…..thanks

  3. This post was awesome! Step by Step process that worked the first time.

    Thanks
    Rick

  4. Renga Iyengar on said:

    Hi.. Quite an Interesting post.. Can it work for Winforms ?

  5. I read a lot of interesting content here.
    Probably you spend a lot of time writing, i know how to save you a lot of work, there is an online tool that creates high quality,
    SEO friendly posts in minutes, just search in google – laranitas free content
    source

  6. Thank you saed. But what if we have more than one parameters?

  7. Thank you Saed. What if we have more than one parameter?

  8. Seven lavide on said:

    I used to use and old way to create my apps (Visual Basic 6) and I use VBA a lot. But I wanted to create something more sophisticate. I just began to use VS and MySql. I was almost giving up when I found your post. This is what I was needing to move on. Thank you a million.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: