This topic describes the steps required to add data in the OLAP control using model binding. You can also perform remote data binding in OLAP. For more information about remote data binding, see Remote Data Binding topic.
Complete the following steps to implement model data binding in Olap control.
The following image shows how OLAP control appears in the browser after completing the above steps:
OLAP Control
Step 1: Create a Datasource for OLAP
Create a new class inside the Models folder to create data source for the OLAP control.
- Add a new class to the folder Models (for example:
ProductData.cs
). For more information about how to add a new model, see Adding controls.
- Add the following code to the model to define the data for OLAP.
Back to Top
Step 2: Add an OLAP control
Create a controller and view for OLAP control and follow the below steps to initialize an OLAP control.
Complete the following steps to initialize an OLAP control.
Add a new Controller
- In the Solution Explorer, right click the folder Controllers.
- From the context menu, select Add | Controller. The Add Scaffold dialog appears.
- Complete the following steps in the Add Scaffold dialog:
- Select Empty MVC Controller template.
- Set name of the controller (for example:
OlapController
).
- Click Add.
- Replace the method Index() with the following method.
Add a View for the Controller
- From the Solution Explorer, expand the folder Controllers and double click the
OlapController.
- Place the cursor inside the method
Index()
.
- Right click and select Add View. The Add View dialog appears.
- In the Add View dialog, verify that the view name is Index and View engine is Razor (CSHTML).
- Click Add to add a view is for the controller. Copy the following code and paste it inside Index.cshtml.
Step 3: Build and Run the Project
- Click Build | Build Solution to build the project.
- Press F5 to run the project.
Append the folder name and view name to the generated URL (for example: http://localhost:1234/
Olap/Index) in the address bar of the browser to see the view.
Back to Top
See Also