Binding C1OlapPage or C1OlapPanel to a Data Source

You can easily bind C1OlapPage or C1OlapPanel to a data source using the C1OlapPage.DataSource or C1OlapPanel.DataSource property. For this example, we load Northwind product data from an XML data schema file. Note that the nwind.zip is installed with the OlapQuickStart sample. We use ComponentOne Data for Silverlight, which provides us the familiar DataSet and DataTable objects to read the data in. We also use ComponentOne Zip for Silverlight to unpackage the zipped XML file on the client.

To bind the C1OlapPage control, follow these steps:

1.   Add the following code:

// load data from embedded zip resource

var ds = new DataSet();

var asm = Assembly.GetExecutingAssembly();

using (var s = asm.GetManifestResourceStream("OlapQuickStart.nwind.zip"))

{

     var zip = new C1ZipFile(s);

     using (var zr = zip.Entries[0].OpenReader())

     {

           // load data

           ds.ReadXml(zr);

     }

}

2.   Set the DataSource property on the C1OlapPage control. We could use any data binding method with this control.

// bind olap page to data

_c1OlapPage.DataSource = ds.Tables[0].DefaultView;


Send us comments about this topic.
Copyright © GrapeCity, inc. All rights reserved.