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.
Version Q1 2012 released 04/11/2012
select

Grid / Data Binding RadGrid to DomainDataSource

Add new recordRefresh
  Customer IDCompany NameContact NameCity 
Page size:
select
 88 items in 9 pages
ANATRAna Trujillo Emparedados y heladosAna TrujilloMéxico D.F.
ANTONAntonio Moreno TaqueríaAntonio MorenoMéxico D.F.
AROUTAround the HornThomas HardyLondon
BERGSBerglunds snabbköpChristina BerglundLuleå
BLAUSBlauer See DelikatessenHanna MoosMannheim
BLONPBlondesddsl père et filsFrédérique CiteauxStrasbourg
BOLIDBólido Comidas preparadasMartín SommerMadrid
BONAPBon app'Laurence LebihanMarseille
BOTTMBottom-Dollar MarketsElizabeth LincolnTsawassen
BSBEVB's BeveragesVictoria AshworthLondon

  • The DomainDataSource control introduces a new way of accessing data by giving us a nice separation from the particular representation of our Data Model and more control over how the data is being retrieved or manipulated. This example demonstrates binding RadGrid to the DomainDataSource control that goes with MS Silverlight 4.0 RIA Services.

Source Code

C# VB.NET
Show code in new window Demo isolation steps
  • <%@ Page Language="VB" AutoEventWireup="false" CodeFile="DefaultVB.aspx.vb" Inherits="Grid_Examples_Programming_DomainDataSource_DefaultVB" %>
    <%@ 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" %>
    <%@ Register Assembly="Microsoft.Web.DomainServices.WebControls" Namespace="Microsoft.Web.UI.WebControls"
        TagPrefix="asp" %>
    <!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>
        <!-- custom head section -->
        <style type="text/css">
            .RadGrid th
            {
                font: bold 11px tahoma;
                white-space: nowrap;
            }
        </style>
        <!-- end of custom head section -->
    </head>
    <body class="BODY">
        <form id="form1" runat="server">
        <telerik:Header runat="server" ID="Header1" NavigationLanguage="VB"></telerik:Header>
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <!-- content start -->
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="CustomersGrid">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="CustomersGrid" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
        <telerik:RadGrid ID="CustomersGrid" runat="server" AllowPaging="true"
            DataSourceID="CustomersDomainDataSource">
            <MasterTableView DataSourceID="CustomersDomainDataSource" CommandItemDisplay="Top"
                AllowAutomaticInserts="true" AllowAutomaticDeletes="true" AllowAutomaticUpdates="true"
                AutoGenerateColumns="false" DataKeyNames="CustomerID">
                <Columns>
                    <telerik:GridEditCommandColumn ButtonType="ImageButton">
                    </telerik:GridEditCommandColumn>
                    <telerik:GridBoundColumn DataField="CustomerID" HeaderText="Customer ID" UniqueName="CustomerID"
                        SortExpression="CustomerID">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="CompanyName" HeaderText="Company Name" UniqueName="CompanyName"
                        SortExpression="CompanyName">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="ContactName" HeaderText="Contact Name" UniqueName="ContactName"
                        SortExpression="ContactName">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="City" HeaderText="City" UniqueName="City" SortExpression="City">
                    </telerik:GridBoundColumn>
                    <telerik:GridButtonColumn ButtonType="ImageButton" CommandName="Delete">
                    </telerik:GridButtonColumn>
                </Columns>
                <DetailTables>
                    <telerik:GridTableView DataSourceID="OrdersDomainDataSource" AutoGenerateColumns="false"
                        DataKeyNames="OrderID, CustomerID">
                        <ParentTableRelation>
                            <telerik:GridRelationFields DetailKeyField="CustomerID" MasterKeyField="CustomerID" />
                        </ParentTableRelation>
                        <Columns>
                            <telerik:GridBoundColumn DataField="OrderID" HeaderText="Order ID" UniqueName="OrderID"
                                SortExpression="OrderID">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="CustomerID" HeaderText="Customer ID" UniqueName="CustomerID"
                                SortExpression="CustomerID">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="Freight" HeaderText="Freight" UniqueName="Freight"
                                SortExpression="Freight">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="ShipName" HeaderText="Ship Name" UniqueName="ShipName"
                                SortExpression="ShipName">
                            </telerik:GridBoundColumn>
                        </Columns>
                    </telerik:GridTableView>
                </DetailTables>
            </MasterTableView>
        </telerik:RadGrid>
    <asp:DomainDataSource ID="CustomersDomainDataSource" runat="server" DomainServiceTypeName="RadGridAndDomainDataSource.NorthwindDomainService"
    EnableDelete="True" EnableInsert="True" EnableUpdate="True" QueryName="GetCustomers">

        </asp:DomainDataSource>
    <asp:DomainDataSource ID="OrdersDomainDataSource" runat="server" DomainServiceTypeName="RadGridAndDomainDataSource.NorthwindDomainService"
    EnableDelete="True" EnableInsert="True" EnableUpdate="True" QueryName="GetOrdersByCustomerID">

            <QueryParameters>
                <asp:Parameter Name="CustomerID" />
            </QueryParameters>
        </asp:DomainDataSource>
        <!-- content end -->
        <telerik:Footer runat="server" ShowVBLink="true" ID="Footer1"></telerik:Footer>
        </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