Data Access has been discontinued. Please refer to this page for more information.

How to: Bind Data to ASP.NET Controls

This article is relevant to entity models that utilize the deprecated Visual Studio integration of Telerik Data Access. The current documentation of the Data Access framework is available here.

Telerik Data Access enables you to bind ASP.NET controls such as RadComboBox and RadGrid.

Adding RadScriptManager

The first step when you want to use RadControls for ASP.NET AJAX is to add a RadScriptManager. By default each of the RadControls for ASP.NET Ajax serves a set of files (JS code) needed for its proper client-side operation. When loading a page with several controls on it, the number of these files can become very large, often resulting in a reduced page load time and increased traffic. The reason for this problem is that browsers make a separate request to the server for each of these resources. With the newly added RadScriptManager control, RadControls for ASP.NET Ajax suite gives developers the advantage of a simple drag-and-drop to achieve the combination of resources to a single request. All you need is to add a RadScriptManager to your page and the javascript files get combined into a single file.

Open your page in Design mode. Drag a new RadScriptManager component from the Toolbox to the designer.

RadScriptManager needs an HttpHandler to be declared in the application configuration file to operate properly. The addition of the handler is made easy by the SmartTags of the control. Right-click the RadScriptManager and select Show Smart Tag. Then select Register Telerik.Web.UI.WebResource.axd.

Binding Data to RadControls for ASP.NET AJAX

You can bind object using the code-behind method as well. You can easily do this by retrieving all the objects that you wish to bind and by taking advantage of the DataSource property of the control to which you wish to bind the result set. The following example shows how to retreive a single column from a data table and bind it to a RadComboBox.

using (EntitiesModel dbContext = new EntitiesModel())
   RadComboBox.DataSource = dbContext.Categories.ToList();
   RadComboBox.DataTextField = "CategoryName";
Using dbContext As New EntitiesModel()
 RadComboBox.DataSource = dbContext.Categories.ToList()
 RadComboBox.DataTextField = "CategoryName"
End Using

Next Step

For more information, please refer to: