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 / Programmatic Creation from XML

Customer IDCompany NameContact NameContact TitleAddressPostal Code
      
 Page 1 of 7, items 1 to 15 of 91.
ALFKIAlfreds FutterkisteMaria AndersSales RepresentativeObere Str. 5712209
ANATRAna Trujillo Emparedados y heladosAna TrujilloOwnerAvda. de la Constitución 222205021
ANTONAntonio Moreno TaqueríaAntonio MorenoOwnerMataderos 231205023
AROUTAround the HornThomas HardySales Representative120 Hanover Sq.WA1 1DP
BERGSBerglunds snabbköpChristina BerglundOrder AdministratorBerguvsvägen 8S-958 22
BLAUSBlauer See DelikatessenHanna MoosSales RepresentativeForsterstr. 5768306
BLONPBlondesddsl père et filsFrédérique CiteauxMarketing Manager24, place Kléber67000
BOLIDBólido Comidas preparadasMartín SommerOwnerC/ Araquil, 6728023
BONAPBon app'Laurence LebihanOwner12, rue des Bouchers13008
BOTTMBottom-Dollar MarketsElizabeth LincolnAccounting Manager23 Tsawassen Blvd.T2F 8M4
BSBEVB's BeveragesVictoria AshworthSales RepresentativeFauntleroy CircusEC2 5NT
CACTUCactus Comidas para llevarPatricio SimpsonSales AgentCerrito 3331010
CENTCCentro comercial MoctezumaFrancisco ChangMarketing ManagerSierras de Granada 999305022
CHOPSChop-suey ChineseYang WangOwnerHauptstr. 293012
COMMIComércio MineiroPedro AfonsoSales AssociateAv. dos Lusíadas, 2305432-043

  • This approach is quite useful when you want to load grid instances with equal predefined settings on different pages in our web site. For this purpose you can use XSL transformation to import the grid content into XML file (using StringWriter to transfer the data from the xsl definition to the .xml file). After this operation you can generate StringBuilder object and get the StringWriter instance content. Finally, simply call the Page.ParseControl(stringDefinition) method and add the control returned by that method to the Controls collection of a placeholder control. This placeholder control should reside in the webform on which you want to visualize the grid.

    You can refer to this topic from the grid help as well:
    Populate grid from XML

    Note: the steps described above should take place in the PageInit handler.

    XSL definition:
    <?xml version="1.0" encoding="utf-8"?>
    
    <xsl:stylesheet version="1.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:telerik="remove">
    
      <xsl:template match="/">
        <div>
          <radG:RadGrid ID="RadGrid1" Width="95%"
                      AllowFilteringByColumn="True" AllowSorting="True" PageSize="15" ShowFooter="True"
                      ShowGroupPanel="True" AllowPaging="True" AllowMultiRowSelection="True" runat="server">
            <HeaderStyle Width="150px" />
            <ClientSettings ReorderColumnsOnClient="True" AllowDragToGroup="True" AllowColumnsReorder="True">
              <Scrolling AllowScroll="True" UseStaticHeaders="True"></Scrolling>
              <Resizing AllowRowResize="True" AllowColumnResize="True"></Resizing>
              <Selecting AllowRowSelect="True"></Selecting>
            </ClientSettings>
          </radG:RadGrid>
        </div>
      </xsl:template>
    
    </xsl:stylesheet>
    

Source Code

C# VB.NET
Show code in new window Demo isolation steps
  • <%@ Page Language="c#" Inherits="Telerik.GridExamplesCSharp.Programming.GridFromXml.DefaultCS" CodeFile="DefaultCS.aspx.cs" %>
    <%@ 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>
        <!-- custom head section -->
        <!-- end of custom head section -->
    </head>
    <body class="BODY">
        <form runat="server" id="mainForm" method="post">
            <telerik:Header runat="server" ID="Header1" NavigationLanguage="CS"></telerik:Header>
            <telerik:RadScriptManager ID="RadScriptManager" runat="server"></telerik:RadScriptManager>
            <!-- content start -->
            <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            </telerik:RadAjaxManager>
            <asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder>
    <asp:SqlDataSource ID="SqlDataSource1"
    ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"

                ProviderName="System.Data.SqlClient"
              SelectCommand="SELECT CustomerID, CompanyName, ContactName, ContactTitle, Address, PostalCode FROM Customers"
              runat="server"></asp:SqlDataSource>
            <!-- content end -->
            <telerik:Footer runat="server" 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