Domanda

I am completely new to XtraReports (and DevExpress in general) as of today.. I have 2 days to implement a report, so please be kind and provide a thorough explanation if you would.

What I have to work with is:

  1. WebForms (.NET 4)
  2. Entity Framework (edmx, not Code First)
  3. I have created a report (inherits DevExpress.XtraReports.UI.XtraReport)
  4. Currently there are no fields in the report because I have no idea how to bind it to my entities..

I did find a site where someone was doing this:

NorthwindEntities entities = new NorthwindEntities();
report.DataSource = entities.Categories;

I tried doing that in the constructor like so:

 this.DataSource = context.Tenants.ToList();

but even though I can see there are 8 records, the report shows nothing. I am guessing I need to create some controls and bind them. Has anyone got some working code for this situation?

EDIT

And in case anyone asks.. yes, I've been searching everywhere already for an example including here: http://documentation.devexpress.com/#XtraReports/CustomDocument9814. That site did show how to bind to a DataSet.. but I don't know how I would use Entity Framework in place of that... which is why I am asking here...

È stato utile?

Soluzione

This worked: http://www.devexpress.com/Support/Center/p/Q334667.aspx

Apparently you can just drag a bindingSource on there, but you need to add one extra line of code in the designer. In my case:

this.bindingSource.DataSource = typeof(Tenant);

Now I can see the fields list populated with all the properties of that class and can just drag and drop the fields onto the designer..

Altri suggerimenti

we use XtraReports also, but in a winform solution so i don't know if everything is exactly the same.

assuming you added the xtraReport file inside your project, as we did in one of ours, you can set the datasource at design time rather then runtime. to do this, open the report and look in the properties window. when you do that, it is possible for you to select fields or a complete table from the fields windows in visual studio and add those to your report. assuming that you do not want users to be able to design the report, you can do that here as well.

in my experience though it would be wise to create a seperate edmx file that only holds the data you want to display for the report. the way devexpress works with the data is that it retrieves it all before they filter it, with large datasets this can take a while.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top