Reports for WPF | ComponentOne
C1.C1Report Namespace / DataSource Class / Recordset Property
Example

In This Topic
    Recordset Property (DataSource)
    In This Topic
    Sets or gets the data source object that provides data to the report.
    Syntax
    'Declaration
     
    Public Property Recordset As Object
    public object Recordset {get; set;}

    Property Value

    You can assign objects of the following types to the Recordset property: (1) System.Data.DataTable objects, (2) System.Data.DataView objects, or (3) any object that implements the IC1ReportRecordset interface.
    Remarks

    Usually, the control creates a System.Data.DataTable object based on the value of the ConnectionString and RecordSource properties, and uses that object as the report data source.

    Alternatively, you may want to create the data source object yourself, and assign it to the control. You can do that by assigning your data source object to the Recordset property.

    When a DataTable or DataView object is assigned to the Recordset property, C1Report automatically creates an internal wrapper class that implements the IC1ReportRecordset interface. Because of this, you can't get the original DataTable or DataView objects back by reading the property value. Instead, you must cast the wrapper object to an System.ComponentModel.IListSource and use the System.ComponentModel.IListSource.GetList method instead, as shown in the example below.

    You can assign objects of the following types to the Recordset property: (1) System.Data.DataTable objects, (2) System.Data.DataView objects, or (3) any object that implements the IC1ReportRecordset interface.
    Example
    // create a DataTable
    DataTable dt = new DataTable("my table");
                
    // assign it to c1report
    // automatically creates IC1ReportRecordset wrapper
    c1r.DataSource.Recordset = dt;
                
    // 1) this doesn't work (dbBad == null)
    object wrapper = c1Report1.DataSource.Recordset;
    DataTable dtBad = wrapper as DataTable;
                
    // 2) this does (dtGood == dt)
    DataView dv = ((IListSource)wrapper).GetList() as DataView;
    DataTable dtGood = dv.Table;
    See Also