The requested page is not available for the requested platform. You are viewing the content for Default platform.

How to: Provide Data for ObjectDataSource with a Fill Service

  • 3 min to read

This example shows how to bind the ASP.NET Web Forms Dashboard Control to the Object Data Source and supply it with data using a custom fill service. To do this, you need to implement an IObjectDataSourceCustomFillService interface. In this example, the ObjectDataSourceFillParameters.Parameters collection of dashboard parameters is used to load the specified number of records.


A complete sample project is available at ASPxDashboard - How to Use a Service to Fill the ObjectDataSource.

public class CustomObjectDataSourceCustomFillService : IObjectDataSourceCustomFillService {
    public object GetData(DashboardObjectDataSource dataSource, ObjectDataSourceFillParameters fillParameters) {
        if (fillParameters.DataFields == null || fillParameters.DataFields.Length == 0) {
            return null;

        List<SalesPersonData> data = DataGenerator.Data;

        DataTable table = new DataTable();
        foreach (string field in fillParameters.DataFields) {

        int NumberOfRecordsToRetrieveParameter = (int)(fillParameters.Parameters.FirstOrDefault(i => i.Name == "NumberOfRecords")?.Value);
        int NumberOfRecordsToRetrieve = NumberOfRecordsToRetrieveParameter <= data.Count ? NumberOfRecordsToRetrieveParameter : data.Count;

        for (int i = 0; i < NumberOfRecordsToRetrieve; i++) {
            object[] row = new object[fillParameters.DataFields.Length];
            for (int j = 0; j < fillParameters.DataFields.Length; j++) {
                row[j] = GetPropertyValue(data[i], fillParameters.DataFields[j]);
        return table.DefaultView;
    object GetPropertyValue(SalesPersonData obj, string propName) {
        return propName == "SalesPerson" ? (object)obj.SalesPerson : (object)obj.Quantity;