<
OLAP for WPF and Silverlight | ComponentOne
OLAP for WPF and Silverlight Task-Based Help / Binding C1OlapPage or C1OlapPanel a Data Source
In This Topic
    Binding C1OlapPage or C1OlapPanel a Data Source
    In This Topic

    You can easily bind C1OlapPage or C1Olap 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, which provides us the familiar DataSet and DataTable objects to read the data in. We also use ComponentOne Zip to unpackage the zipped XML file on the client.

    To bind the C1OlapPage control, follow these steps:

    1. Add the following code:
      Visual Baisc
      Copy Code
      ' load data from embedded zip resourcevar ds = new DataSet();
      Dim asm = Assembly.GetExecutingAssembly()
      Using s = asm.GetManifestResourceStream("OlapQuickStart.nwind.zip")
          Dim zip = New C1ZipFile(s)
          Using zr = zip.Entries(0).OpenReader()
              ' load data         
              ds.ReadXml(zr)
          End Using
      End Using
      
      C#
      Copy Code
      // load data from embedded zip resourcevar 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 C1OlapPage.DataSource property on the C1OlapPage control. We could use any data binding method with this control.
      Visual Basic
      Copy Code
      // bind olap page to data
      _c1OlapPage.DataSource = ds.Tables[0].DefaultView;
      
      C#
      Copy Code
      // bind olap page to data
      _c1OlapPage.DataSource = ds.Tables[0].DefaultView;