We help IT Professionals succeed at work.

programmatically work with object data source and report viewer

mugsey
mugsey asked
on
6,432 Views
Last Modified: 2013-11-05
Trying to use object data source control programmatically.  I need to use it with a report viewer control.  Just trying to hardcode some values which seems to work fine. but I don't know how to bind the report

Here is my sample code

        ObjectDataSource os = new ObjectDataSource("TutorManager", "GetList");
        os.DataObjectTypeName = "BizObject.clsTutor";
        genericReportViewer.LocalReport.DataSources.Clear();
        genericReportViewer.LocalReport.ReportPath = Server.MapPath("TutorReport.rdlc");
        genericReportViewer.LocalReport.DataSources.Add(new ReportDataSource(???????

Any pointers?

Comment
Watch Question

Commented:
See if this helps:
http://forums.microsoft.com/msdn/showpost.aspx?postid=59856&siteid=1

    -dZ.

Author

Commented:
Thanks but I am a bit lost on this.  
Essentially all I want is a way to have one "report viewer control" and have many rdlc files.

Commented:
You set the datasource with
    genericReportViewer.LocalReport.DataSources.Add(...);
then you call refresh:
    genericReportViewer.LocalReport.Refresh();

Does this help?
     -dZ.

Author

Commented:
Thanks but it does not.  Has anyone got any approach of using one report viewer with multiple rldc files.  Thanks

Commented:
Can you show the full code that does not work?  Perhaps we can find what's wrong with it.

    -dZ.

Commented:
Ok.  Check this example out:
http://www.codeproject.com/useritems/reportdisplay.asp

According to that, you add the DataSource first and then you set the ReportPath to bind it.

I also think that you are out of luck if you want to reuse the ReportViewert.  I found the following comment in a forum:

"Both winforms and webforms only allow you to set the report definition of a local report once.  In winforms, you can call ReportViewer.Reset() to cause the control to generate a new instance of LocalReport.  In webforms, you will need to instantiate a new instance of the control. "
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=196684&SiteID=1

And here is another article explaining how to use multiple data collections with one report:
http://aspalliance.com/762_Binding_the_ReportViewer_Control_to_Multiple_Generic_Collections

I'm sorry if I cannot give you express custom code for your issue, but I do not have access to ASP.NET 2.0 at the moment.

     -dZ.

Commented:
Here's a FAQ on using the ReportViewer, perhaps it can offer some enlightenment:
http://www.gotreportviewer.com/

     -dZ.

Author

Commented:
Thanks but I know it can work, I have asked a similar question here

https://www.experts-exchange.com/Microsoft/Development/.NET/Visual_Studio_.NET_2005/Q_22763777.html
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
Yes thanks but that is for a windows app.  I am using asp.net

Commented:
Did you ever find a solution? I am attempting the same thing in VS.NET 2005 for a web app and am having the exact same issue.

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.