# How to Pass Additional Data With the DataSourceResult Back to the View

## Environment

<table>
    <tbody>
        <tr>
            <td>Product</td>
            <td>Telerik UI for ASP.NET MVC</td>
        </tr>
    </tbody>
</table>

## Description

How can I pass additional data through the [`DataSourceResult`](https://www.telerik.com/aspnet-mvc/documentation/api/kendo.mvc.ui/datasourceresult) from the Controller back to the View?

## Solution

The desired result can be achieved by following the steps below:

* Store the output of the `ToDataSourceResult` method in a variable.
* Return a custom JSON result with the same field names and add the additional fields.
* Handle the `RequestEnd` event of the DataSource to retrieve the additional data when the response of the request is received.

```C# Controller
    var resultFinal = result.ToDataSourceResult(request);
    return Json(new
    {
        Data = resultFinal.Data,
        Total = resultFinal.Total,
        AggregateResults = resultFinal.AggregateResults,
        Errors = resultFinal.Errors,
        myAdditionalParam = "additional data" // Add the desired parameter.
    });
```

```Razor View
    @(Html.Kendo().DataSource<OrderViewModel>()
        .Name("myDataSource")
        .Ajax(dataSource =>
        {
          dataSource.Events(ev => ev.RequestEnd("requestEnd"))
          // Additional configuration.
        })
    )

    <script>
        function requestEnd(e){
            // Access the additional data sent from the server.
            console.log(e.response.myAdditionalParam);
        }
    </script>
```

## More ASP.NET MVC DataSource Resources

* [ASP.NET MVC DataSource Documentation](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/datasource/overview)
* [Client-Side API Reference of the DataSource for ASP.NET MVC](https://docs.telerik.com/kendo-ui/api/data/datasource)
* [Server-Side API Reference of the DataSource for ASP.NET MVC](https://docs.telerik.com/aspnet-mvc/api/datasource)
