Telerik is a leading vendor of ASP.NET AJAX, ASP.NET MVC, Silverlight, WinForms and WPF controls and components, as well as .NET Reporting, .NET ORM , .NET CMS, Code Analysis, Mocking, Team Productivity and Automated Testing Tools. Building on its expertise in interface development and Microsoft technologies, Telerik helps customers build applications with unparalleled richness, responsiveness and interactivity. Telerik products help thousands of companies to be more productive and deliver reliable applications under budget and on time.
select

Grid / NET 2 DataSource Controls

SqlDataSource

CustomerIDCompanyNameContactNameContactTitleAddress
Page size:
select
 91 items in 19 pages
ALFKIAlfreds FutterkisteMaria AndersSales RepresentativeObere Str. 57
ANATRAna Trujillo Emparedados y heladosAna TrujilloOwnerAvda. de la Constitución 2222
ANTONAntonio Moreno TaqueríaAntonio MorenoOwnerMataderos 2312
AROUTAround the HornThomas HardySales Representative120 Hanover Sq.
BERGSBerglunds snabbköpChristina BerglundOrder AdministratorBerguvsvägen 8

XmlDataSource

ObjectDataSource



  • You can use the below ASP.NET 2.0 DataSource control types for RadGrid data-binding:

    • SqlDataSource
    • ObjectDataSource
    • XmlDataSource
    • AccessDataSource

    All you need to do is set the DataSourceID property of the RadGrid to the ID of the Data Source control. Then you use ASP.NET binding expressions (Eval or Bind) for the fields that will be visualized in the grid.

Source Code

C# VB.NET
Show code in new window Demo isolation steps
  • <%@ Page Language="vb" %>

    <%@ Register TagPrefix="telerik" Namespace="Telerik.QuickStart" %>
    <%@ Register TagPrefix="telerik" TagName="Header" Src="~/Common/Header.ascx" %>
    <%@ Register TagPrefix="telerik" TagName="HeadTag" Src="~/Common/HeadTag.ascx" %>
    <%@ Register TagPrefix="telerik" TagName="Footer" Src="~/Common/Footer.ascx" %>
    <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <telerik:HeadTag runat="server" ID="Headtag2"></telerik:HeadTag>
    </head>
    <body class="BODY">
        <form runat="server" id="mainForm" method="post">
        <div>
            <telerik:Header runat="server" ID="Header1" NavigationLanguage="VB">
            </telerik:Header>
            <!-- content start -->
            <telerik:RadScriptManager ID="RadScriptManager1" runat="server" />
            <telerik:RadFormDecorator ID="RadFormDecorator1" runat="server" />
            <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
                <AjaxSettings>
                    <telerik:AjaxSetting AjaxControlID="RadGrid1">
                        <UpdatedControls>
                            <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
                        </UpdatedControls>
                    </telerik:AjaxSetting>
                    <telerik:AjaxSetting AjaxControlID="RadGrid2">
                        <UpdatedControls>
                            <telerik:AjaxUpdatedControl ControlID="RadGrid2" LoadingPanelID="RadAjaxLoadingPanel1" />
                        </UpdatedControls>
                    </telerik:AjaxSetting>
                    <telerik:AjaxSetting AjaxControlID="RadGrid3">
                        <UpdatedControls>
                            <telerik:AjaxUpdatedControl ControlID="RadGrid3" LoadingPanelID="RadAjaxLoadingPanel1" />
                        </UpdatedControls>
                    </telerik:AjaxSetting>
                </AjaxSettings>
            </telerik:RadAjaxManager>
            <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server">
            </telerik:RadAjaxLoadingPanel>
            <h3>
                SqlDataSource</h3>
            <telerik:RadGrid ID="RadGrid1" AllowPaging="true" AllowSorting="true" PageSize="5"
                DataSourceID="SqlDataSource1" runat="server" AllowFilteringByColumn="true">
                <MasterTableView DataKeyNames="CustomerID" AutoGenerateColumns="false">
                    <Columns>
                        <telerik:GridBoundColumn DataField="CustomerID" UniqueName="CustomerID" HeaderText="CustomerID">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="CompanyName" UniqueName="CompanyName" HeaderText="CompanyName">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="ContactName" UniqueName="ContactName" HeaderText="ContactName">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="ContactTitle" UniqueName="ContactTitle" HeaderText="ContactTitle">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="Address" UniqueName="Address" HeaderText="Address">
                        </telerik:GridBoundColumn>
                    </Columns>
                </MasterTableView>
            </telerik:RadGrid>
            <br />
            <table cellpadding="0" cellspacing="0">
                <tr>
                    <td valign="top" style="width:500px">
                        <h3>
                            XmlDataSource</h3>
                        <telerik:RadGrid ID="RadGrid2" AllowPaging="true" AllowSorting="true" PageSize="3"
                            DataSourceID="XmlDataSource1" runat="server" Width="480px" AllowFilteringByColumn="true">
                        </telerik:RadGrid>
                    </td>
                    <td valign="top">
                        <h3>
                            ObjectDataSource</h3>
                        <telerik:RadGrid ID="RadGrid3" AllowPaging="true" AllowSorting="true" DataSourceID="ObjectDataSource1"
                            runat="server" AllowFilteringByColumn="true">
                            <PagerStyle AlwaysVisible="true" />
                        </telerik:RadGrid>
                    </td>
                </tr>
            </table>
            <br />
            <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
                ProviderName="System.Data.SqlClient" SelectCommand="SELECT * FROM Customers" />
    <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" TypeName="ShippersDataSetTableAdapters.ShippersTableAdapter"
    SelectMethod="GetData" />

            <asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile="RadGrid.xml" />
            <!-- content end -->
            <telerik:Footer runat="server" ID="Footer1"></telerik:Footer>
        </div>
        </form>
    </body>
    </html>

Get more than expected!

Take your time to truly experience the power of RadControls for ASP.NET AJAX with a free 60-day trial backed up by Telerik’s unlimited dedicated support.

Download your RadControls for ASP.NET AJAX trial and jumpstart your development with the available Getting Started resources.

If you have any questions, do not hesitate to contact us at sales@telerik.com.

Copyright 2002-2012 © Telerik. All right reserved
Telerik Inc, 201 Jones Rd, Waltham, MA 02451