This is a migrated thread and some comments may be shown as answers.

Reporting Best Practices

2 Answers 174 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Kerry
Top achievements
Rank 1
Kerry asked on 27 Mar 2012, 09:26 PM
Hello, 

I was wondering if it was good practice to retrieve data via the code behind and pass it to my reports textboxes.  I would create some properties in the report class that would allow me to pass it a business object.  This business object would contain data needed on the report and via the code behind I can reference the textbox objects for e.g.  this.textbox25.Value = obj.FirstName.

This would allow me to avoid adding more SQLDatasources to the report.  Would this practice be considered ok.

Thanks,

Kerry

2 Answers, 1 is accepted

Sort by
0
Ed Lance
Top achievements
Rank 1
answered on 27 Mar 2012, 11:42 PM
I guess you can say it's Ok if it works for you. If you already have the business objects made, then you can use them.  But if you are going to create them just to avoid adding more SQLDatasources, then you are just trading work here for work there.

If you already have the business objects, what about using an ObjectDataSource?  I wouldn't want to get in the business of assigning values to textboxes in code behind myself, because then you have to maintain it that way.  I prefer doing the binding to textboxes etc. in the designer (which in fact does the coding) so it's easier to see what's going on. 
0
Kerry
Top achievements
Rank 1
answered on 28 Mar 2012, 12:13 AM
Hi Ed thanks for the reply.

Yes we have the business objects already, my issue is I have a report that has the need for data from many different queries(datasources) the report body is associated with one datasource and we like the way it page breaks with the group headers etc.  Since you cannot bind a datasource directly to a textbox then the only other option is a TABLE or LIST and it proves to be a lot of playing around to get the data to appear correctly on the page, as well some of this data belongs in the page header which will not allow you to place a TABLE control in it.  Do you have any other suggestions for populating 4 or 5 fields in the page header when the body of the report is already associated with a datasource.

Thanks,

Kerry
Tags
General Discussions
Asked by
Kerry
Top achievements
Rank 1
Answers by
Ed Lance
Top achievements
Rank 1
Kerry
Top achievements
Rank 1
Share this question
or