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 / Entity Framework Operations

Next database reset in 1 hours, 6 minutes, 0 seconds
Add new recordRefresh
 ContactNameCompanyNameContactTitlePhone 
Page size:
select
 89 items in 9 pages
Alejandra CaminoRomero y tomilloAccounting Manager(91) 745 6200
Alexander FeuerMorgenstern GesundkostMarketing Assistant0342-023176
Ana TrujilloAna Trujillo Emparedados y heladosOwner(5) 555-4729
Anabela DominguesTradição HipermercadosSales Representative(11) 555-2167
André FonsecaGourmet LanchonetesSales Associate(11) 555-9482
Antonio MorenoAntonio Moreno TaqueríaOwner(5) 555-3932
Aria CruzFamilia ArquibaldoMarketing Assistant(11) 555-9857
Art BraunschweigerSplit Rail Beer & AleSales Manager(307) 555-4680
Bernardo BatistaQue DelíciaAccounting Manager(21) 555-4252
Carine SchmittFrance restaurationMarketing Manager40.32.21.21

  • The current example demonstrates RadGrid's capability for inserting new data, updating existing data and deleting data against an EntityDataSource. The only thing that is required of you is to configure the entity data source by incuding the correpsonding database tables in the entity data model and set the following properties of the grid to true to propagate automatic update/insert/delete operations:

    • AllowAutomaticUpdates
    • AllowAutomaticInserts
    • AllowAutomaticDeletes

    What is on this example:
    • You can insert a new item using the [Add new record] button in the Command row.
    • You can edit an item using the Edit button (the first button in each row).
    • You can delete an item, using the Delete button (at the end of each row).

    You may also see how to utilize Telerik OpenAccess ORM as a data access layer for our AJAX controls by visiting the OpenAccess ORM live demos here.

Source Code

C# VB.NET
Show code in new window Demo isolation steps
  • <%@ Page Language="VB" CodeFile="~/Grid/Examples/automaticoperations/efdatabinding/defaultvb.aspx.vb"
        Inherits="defaultvb" %>

    <%@ Register TagPrefix="qsf" Namespace="Telerik.QuickStart" %>
    <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
    <%@ Register TagPrefix="qsf" TagName="Header" Src="~/Common/Header.ascx" %>
    <%@ Register TagPrefix="qsf" TagName="HeadTag" Src="~/Common/HeadTag.ascx" %>
    <%@ Register TagPrefix="qsf" TagName="Footer" Src="~/Common/Footer.ascx" %>
    <%@ Register Assembly="System.Web.Entity, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
        Namespace="System.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">
        <qsf:HeadTag ID="Headtag1" runat="server"></qsf:HeadTag>
    </head>
    <body class="BODY">
        <form id="form1" runat="server">
        <div>
            <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
            </telerik:RadScriptManager>
            <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
                <AjaxSettings>
                    <telerik:AjaxSetting AjaxControlID="RadGrid1">
                        <UpdatedControls>
                            <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
                        </UpdatedControls>
                    </telerik:AjaxSetting>
                </AjaxSettings>
            </telerik:RadAjaxManager>
            <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" />
            <qsf:Header ID="Header1" runat="server" NavigationLanguage="VB" ShowDbResetTimer="true">
            </qsf:Header>
            <telerik:RadGrid ID="RadGrid1" runat="server" DataSourceID="EntityDataSourceCustomers"
                GridLines="None" AllowPaging="True" AllowAutomaticUpdates="True" AllowAutomaticInserts="True"
                AllowAutomaticDeletes="true" AllowSorting="true" Width="750px">
                <PagerStyle Mode="NextPrevAndNumeric" />
                <MasterTableView DataSourceID="EntityDataSourceCustomers" AutoGenerateColumns="False"
                    DataKeyNames="CustomerID" CommandItemDisplay="Top">
                    <Columns>
                        <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn">
                        </telerik:GridEditCommandColumn>
                        <telerik:GridBoundColumn DataField="CustomerID" HeaderText="CustomerID" SortExpression="CustomerID"
                            UniqueName="CustomerID" Visible="false" MaxLength="5">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="ContactName" HeaderText="ContactName" SortExpression="ContactName"
                            UniqueName="ContactName">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="CompanyName" HtmlEncode="true" HeaderText="CompanyName" SortExpression="CompanyName"
                            UniqueName="CompanyName">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="ContactTitle" HeaderText="ContactTitle" SortExpression="ContactTitle"
                            UniqueName="ContactTitle">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="Phone" HeaderText="Phone" SortExpression="Phone"
                            UniqueName="Phone">
                        </telerik:GridBoundColumn>
                        <telerik:GridButtonColumn Text="Delete" CommandName="Delete" ButtonType="ImageButton" />
                    </Columns>
                    <EditFormSettings>
                        <EditColumn ButtonType="ImageButton" />
                    </EditFormSettings>
                </MasterTableView>
            </telerik:RadGrid>
            <qsf:Footer ID="Footer1" runat="server"></qsf:Footer>
        </div>
    <asp:EntityDataSource ID="EntityDataSourceCustomers" runat="server" ConnectionString="name=NorthwindEntities"
    DefaultContainerName="NorthwindEntities" EntitySetName="Customers" OrderBy="it.[ContactName]"
    EntityTypeFilter="Customers" EnableUpdate="True" EnableDelete="True" EnableInsert="True">

        </asp:EntityDataSource>
        </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