How to: Use OpenAccessLinqDataSource in ASP.NET Applications
This topic will walk you through the common task of using OpenAccessLinqDataSource with Telerik Data Access model in ASP.NET Applications.
It is assumed that the following initial steps are performed:
- First, a new ASP.NET Web Application is created and integrated with the Telerik.DataAccess.Core NuGet package.
- Second, the SofiaCarRental model is created.
- The web application project is configured to consume the model.
-
Build your project.
How to Add and Configure a New OpenAccessDataSource
To add and configure a new OpenAccessDataSource to your page:
- Integrate the Telerik.DataAccess.Web NuGet package with the SofiaCarRentalWebApp project.
-
Open the Default.aspx page in Source mode, and register the Telerik.OpenAccess.Web.40 assembly:
<%@ Register Assembly="Telerik.OpenAccess.Web.40" Namespace="Telerik.OpenAccess.Web" TagPrefix="telerik" %>
-
Define a new instance of OpenAccessLinqDataSource, inside the first <div> tag of the page. The ID property should be OpenAccessLinqDataSourceCategory, the ContextTypeName should be the fully qualified name of the context class, i.e. SofiaCarRental.Model.FluentModel, and the ResourceSetName property should be set to a name of an endpoint of the context (the name of an IQueryable<T> property), i.e. Categories. The control should run on the server.
<telerik:OpenAccessLinqDataSource ID="OpenAccessLinqDataSourceCategory" runat="server" ContextTypeName="SofiaCarRental.Model.FluentModel" ResourceSetName="Categories"> </telerik:OpenAccessLinqDataSource>
Adding RadScriptManager
The next step is to add a RadScriptManager and register a HttpHandler. For more information how to complete this task, check out How to: Bind Data to ASP.NET Controls.
Reading and Displaying Data
The final step is to connect the OpenAccessLinqDataSource component to a data control. For example:
- Drag a new RadGrid control to your page.
- Type the name of your OpenAccessLinqDataSource control (in this case OpenAccessLinqDataSourceCategory) as a value of the DataSourceID property.
Next Steps
For additional information, you could refer to the following sections: