I have been trying to use report viewer for a couple of days now and got no where. I have an ASP.Net WEB APLICATION, not a WEB SITE. Which every tutorial relates to.
I used the report viewer last week in another project and it worked perfectly.
What im trying to achive is to create a new report using business objects. NOT a SQL connection. Previously when i used the report viewer when adding new DataSet to the Report Data window all of my namespaces in my objects library (a seperate assembly) were listed and I was able to select my busines object and drag the fields to the report.
Now every time I go into the add dataset wizard there is nothing in the datasource list. If I add the report to the objects library and create an object datasource then they appear in here fine. Obviously i dont want reports in the objects library, they go in the website.
Does anyone know why the add new datasource option is disabled for Web applications? (Accessed from Data > Add new datasource)
Can anyone tell me how I can use the object datasource in the designer in the report?
my classes i want to report on have both a parameterless constructor, they return a list for the get methods. and they are all serializable.
I have found a solution for this by creating a reporting class library.
if anyone is interested I added it to my blog for future reference.
http://wraithnath.blogspot.com/2011/02/visual-studio-2010-report-viewer-object.html
Related
I'm trying to bind a xtraReport-EFdatasource to a list, i have done this in designer mode quickly using the wizard, but i cant bind its datasource at runtime.
DataSource = Services.CoursesList();
I tryed this code in the report constructor, also in the XtraReport1_DataSourceDemanded event with no luck. the devexpress website show an example using bindingsource, but im using EFdatasource. Can you help me with a code sample please?
I suggest you refer this - How to use Entity Framework with Xtrareports
The best way to accomplish your task is to place your Report class and
Entity objects into a separate class library. In this case, you will
be able to bind the Report to a custom object at design time and
provide data at run time.
To pass data to your Report instance, handle the
XtraReport.DataSourceDemanded event, create your Entity objects,
and pass them to the XtraReport.DataSource property.
More References:
How to use the XtraReport with the Entity Framework
Some background on this question. I've built a webapp inside of SharePoint that walks a user through a series of forms. Each form is a ASP.NET page with a number of SharePoint and custom controls. As part of a new feature request(details not relevant here), I need to know what fields are on each form. I'm planning to maintain this data inside of a SharePoint list that other pieces of my code will access programatically.
Rather than maintaining this list by hand, I'd like to populate it in my deployment scripts (written in C#). What I'm hoping is possible is the create a new Page object for each one of my Pages, and then walk through it's Controls collection using some extension methods I've already built to find out which fields are on each form. Is there a good way to instantiate the Page object in this context? To be completely specific, the deployment code runs inside of a SharePoint event receiver, but if you're not familiar with SharePoint, it would be similar trying to accomplish the same thing inside of a console app.
Well, as long as you have access to your web application's assembly you can make the following using Reflection:
1) Load the assembly into memory.
Assembly asm = Assembly.LoadFrom(#"Your assembly path");
2) Query the types for each one of your pages:
var types = asm.GetTypes();
3) For each of your Type instances, get the constructor, invoke it, get the page's instance and then call your Helper methods.
t = types[0];
t.GetConstructor(new Type[] { });
t.GetMethod("Your Method").Invoke(t, object[] {});
OK, I think I'm getting mad here...
I thought this should be super simple, but I just can't figure out how to do that.
This is what I'm trying to do:
I want to create an rdlc report using the ReportViewer control in ASP.NET 4 (VS 2010), and, as its datasource, use a class with some properties.
I tried everything I can think of, but I just can't figure this out. All the docs I found state that the object should appear in the DataSource pane of the website, but I can't make it appear there.
I would like the fields of the class to appear in the report desiger so I can use them - but I can't do that either.
Using the designer, I can only define new dataset - I don't want to use dataset, but business objects!
So - how can I do that? Do I have to use some kind of DataSource control? How can I make the report designer know about the business object?
Thanks!
Memi
did you follow this tutorial?
everything you must do is:
define your DTO classes or generate it using EF4 (for example)
define your business classes with some methods (like GetAll...)
build your solution (that's important)
now from your report designer you can choose methods from business classes as dataset and drag and drop field from the DTO classes
when you choose that report to display in the reportviewer, the datasource object will be added for you
I found this blog very helpful.
When you create a new datasource for your rdlc, in the Dataset Properties dialog:
1) In the Data source drop down, select the namespace that contains the class which contains the public method (see #2).
2) In the Available datasets drop down, select the public method that returns an IQueryable of your business objects.
Is your business object class marked as public? I've seen in a video that it must be public.
I have the same problem and found a way around it. For some reason if you develop a ASP.NET application Microsoft took away add new datasource functionality. The way around is not great but it does work. I use all objects and I use the Enterprise library and I want to use my objects for my reports it only makes sense why they don't enable you to do this. I have no idea why Microsoft would not allow this functionality for web apps.
But that leaves windows apps it works so what I did was create a separate windows project include my objects that I want to bind to in that project and create the report on the forms project. I then bring that report into my Asp.net web app and call it through code. Here is a few pieces of code that I use to do this. This is in VB but could be converted to C#. I also have a drop down list that selects the report that is needed and a case statement that gets the data.
Private Sub LoadReport()
Try
pnlReport.Visible = True
Dim Dal As New DataAccess
Dim objRptOutputData = New Model.RptClientCollection
Dim lr As LocalReport = OutputReportViewer.LocalReport
Dim rds As New ReportDataSource
lr.DataSources.Clear()
OutputReportViewer.Visible = True
OutputReportViewer.ProcessingMode = ProcessingMode.Local
OutputReportViewer.LocalReport.EnableHyperlinks = True
Dim SelectedReport As Integer = 0
If Me.ddlReport.SelectedItem.Value IsNot "" Then
SelectedReport = Me.ddlReport.SelectedItem.Value
End If
Select Case SelectedReport
Case ConstantEnum.Reports.ActiveWaitingList
objRptOutputData = Dal.GetRptClientsByStatus(ConstantEnum.Status.ActiveWaitingList)
lr.ReportPath = "Reporting\Report1.rdlc"
rds.Name = "dsClient"
rds.Value = objRptOutputData
Me.lblCount.Text = "Count: " & objRptOutputData.Count
Case ConstantEnum.Reports.InactiveWaitingList
' This is a small app I have about 15 case statements if it was bigger I would of done this selection a bit different.
End Select
lr.DataSources.Add(rds)
lr.Refresh()
OutputReportViewer.DataBind()
Catch ex As Exception
ExceptionUtility.SendError(ex, "Reports", "LoadReport")
End Try
End Sub
Have you seen this earlier version? Is this what you need:
http://msdn.microsoft.com/en-us/library/ms252073(v=VS.80).aspx
In my project I want to use data source for a crystal report as collection of business layer object.
How do I do this? I have 3 projects together in my solution one of them is business object layer.
In grid and comboboxes or other controls I am able to bind these objects to the collection directly.
I know how to bind crystal report to the object collection when class is in the same project but not to the class which is in different project of current solution.
Thank you
May be its too late for you, but I'll post an answer, in the case that it helps others.
I had the same problem - where you cannot see the classes from other projects in .NET objects section of Crystal Report, but still you can add them.
Steps to add class as data source from other project:
Go to Database Expert
Click on Create new connection
Make new Connection form ADO.NET (XML)
In popup window add a full class name in the editable drop down
Click finish
Thats it ...
I was making an edit to a long existing project. Specifically I added some fields to a table and had to delete the table from the LINQTOSQL designer and re-add it. doesn't Also had to do the same for a view. Mode some other code changes and went to build . Now my project won't build because it can't resolve any of the data context objects (all tables and views) in my code. I don't know what I did or how this happeened. I have many tables and views in the project's L2S data context so I don't wont to try and do over. Please any suggestions on how to resolve this problem are greatly appreciated. Desparate! The error messages I am getting are the familiar
The type or namespace name 'equipment' could not be found (are you missing a using directive or an assembly reference?)
Verify that your "entities.desinger.cs" class was auto generated if not go to the .dbml file and right click on run custom tool to generate it.