DataSource Issue

0
tmarkovich posted this 17 November 2013

I am working with your demo product. The following code is how I am getting my data Source "Customers". I am using entity framework.

> wordDocDataEntities5 context = new wordDocDataEntities5();
>     
>                var query = from c in context.test3 select c;
>     
>                List<test3> customers = query.ToList();

When debugging "customers" is a listing a list of data from the database. I then pass customers into

DocumentGenerator dg = new DocumentGenerator(customers);

The variable "Result":

DocumentGenerationResult result = dg.GenerateDocument(reportTemplateStream, reportDocumentStream); if (result.HasErrors)

it is returning the following error message:

"Element binding for property Value failed: Binding error (Path='test', Source='System.Collections.Generic.List1[[TestWordDoc.test3, TestWordDoc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]'). Details: Object of type 'System.Collections.Generic.List1[TestWordDoc.test3]' doesn't define member 'test'.."

Any ideas of what I am doing wrong?

2 Posts
2 Points
2 Comments
Order By: Standard | Newest | Votes
0
jles posted this 17 November 2013

Hi,

You only showed your code-behind and not how your template looks like. The error you are getting is telling you that there is a tagging element that is obviously data-bound to data source value's (list/collection of 'test3' objects) member 'test' and the type 'List' does not define member 'test'. I believe your root tagging element on the template is the FIELD element and that your intention is to write some customer data using these FIELD elements. If this is true, than this is inconsistent with your input: your template expects a list of customer (test3) objects (your data source is of type List<test3> and not just test3) which means that you template/document is about a list of customers and not about a single customer. This means that you should start with a LIST as the root tagging element on the template and it should be bound directly to the default data source (with empty Path). And only then you should nest FIELD elements inside it bound to 'Current Data Context' with Binding Paths something like customer name or in your specific case 'test'.

My assumption above was that you intention was to create a document containing multiple customers. But if you want to write a single one then you should pass a single test3 object as the data source value (and not a List<test3> like in your code snippet).

There are several examples showing how to render collections/lists of objects in the "Example Browser" application that was installed along with Docentric Toolkit. Please see example "Rendering Collection".

If you still have problems, please send me your template (you can only attach zip files) so I will be able to inspect it.

Last edited 17 November 2013

154 Posts
294 Points
0
tmarkovich posted this 17 November 2013

That was it. Thanks for your help!

Cheers

2 Posts
2 Points

Our 226005 members have posted 342 times in 101 discussions