StrataFrame Forum

BindingSource on XtraReport

http://forum.strataframe.net/Topic4449.aspx

By Andria Jensen - 11/14/2006

I'm trying to use a BusinessBindingSource as suggested for binding a BO to an XtraReport object as a DataSource.  A couple of issues that I've come across and haven't been able to get figured out yet...

1.  How would you ever be able to preview the report this way?  The BO has no data connection at design time, so it doesn't know where to get the data.  Is there some way this feature can be added...something like a design-time data source we can point it to?

2. The XtraReport does not support dropping the BO onto the designer.  I used some code and mangled the report enough to force it to allow me to drop one onto the designer.  However, it still won't let me set the BusinessObject property of the BindingSource at design time.  I get the error: "Unable to cast object of type 'WindowsApplication1.XtraReportBase' to type 'System.Windows.Forms.Control'."

Am I going about this the wrong way?  Would it be better not to use a BO/BindingSource for the data source on an XtraReport? 

The only way I can currently get anything to work is setting everything at run-time and that just isn't going to work for the really complicated reports.  I need to be able to set things at design-time and preview the output.

By Paul Chase - 11/15/2006

Andria,

I went through the same issue's. I am pretty sure Dev express only supports design time preview when you use a data adapter etc. I would think there would be an event that you could hook into to populate an objects datasource at design time but I never found it. I looked around on the forums there and could not find out how to get design time preview to work with an object.

I think that using a business object for a report is a good idea in principle but it gets screwy when you have complex reports with multi tables as business object's really represent a single table. That being said I created my own set of "QueryObjects" that represent the fields returned from a query. Kind of like a read only chopped down version of a business object. 

I bind this object to the report to get design time binding of the fields (like I said I am unable to get design time preview to work). I also have additional properties on the query object that store the select statement and parameters as well as additional report meta data. I also have methods to retrieve the data using strataframes data access layer. like below

Public Sub QueryDataSource() Implements Report.iReportQueryProvider.QueryDataSource

Me.DataSource = MicroFour.StrataFrame.Data.DataBasics.DataSources("").GetDataTable(BuildSqlCommand, Nothing)

End Sub

Private Function BuildSqlCommand() As SqlClient.SqlCommand

Dim LoSqlCmd As New SqlClient.SqlCommand

LoSqlCmd.CommandText = oMetaDataBiz.SQL

'Build Parameters Collection

For Each p As ReportParameter In oMetaDataBiz.ParametersCollection

LoSqlCmd.Parameters.AddWithValue(p.ParameterName, p.ParameterValue)

Next

Return LoSqlCmd

End Function

However the more direct approach is to just create a report using the dev express data adapter etc. This gives you preview at design time. Then at runtime just swap the datasource with a table from a biz obj.

Hope this helps a bit.

Paul

By Andria Jensen - 11/15/2006

Is there no way to get a Fill method on a BO to execute correctly at design time?  It seems like there has to be some way of doing this.  It executes the InitializeComponent sub at design time so I stuck some things in there and got everything including preview to work.  However, I still don't get data in my preview because the Fill won't run at design time.  Any way at all to get a BO with data in it at design time??