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 / LinqToSql Manual Operations

Next database reset in 0 hours, 47 minutes, 13 seconds
Add new recordRefresh
 Product IDProduct NameUnits In StockPrice 
Page size:
select
 61 items in 7 pages
12Queso Manchego La Pastora86$38.00
13Konbu24$6.00
14Tofu35$23.25
15Genen Shouyu39$15.50
16Pavlova29$17.45
18Carnarvon Tigers42$62.50
19Teatime Chocolate Biscuits25$9.20
20Sir Rodney's Marmalade40$81.00
21Sir Rodney's Scones3$10.00
22Gustaf's Knäckebröd104$21.00

  • The current example demonstrates RadGrid's capability for inserting new data, updating existing data and deleting data handled using RadGrid public API and Linq to SQL data context.

    Main points in this demo: 
    • Using GridEditCommandColumn to change the edit state of an item in the grid
    • Handling Update server event
    • Handling Insert event and new record insertion with the build-in insert mechanism
    • Extracting the new values from the cells for each column thus simplifying the code required to insert/update items.
    • How Telerik RadGrid automatically extracts the new values from the cells for each column

    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="defaultvb.aspx.vb" AutoEventWireup="false" Inherits="Telerik.GridExamplesVBNET.DataEditing.ProgramaticLinqUpdates.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" %>
    <!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" />
            <qsf:Header ID="Header1" runat="server" NavigationLanguage="VB" ShowDbResetTimer="true">
            </qsf:Header>
            <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">

                <script type="text/javascript">
                    function rowDblClick(sender,eventArgs) {
                        sender.get_masterTableView().editItem(eventArgs.get_itemIndexHierarchical());
                    }
                </script>

            </telerik:RadCodeBlock>
            <telerik:RadAjaxManager runat="server" ID="RadAjaxManager1" DefaultLoadingPanelID="RadAjaxLoadingPanel1">
                <AjaxSettings>
                    <telerik:AjaxSetting AjaxControlID="RadGrid1">
                        <UpdatedControls>
                            <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
                            <telerik:AjaxUpdatedControl ControlID="RadWindowManager1" />
                            <telerik:AjaxUpdatedControl ControlID="RadInputManager1" />
                        </UpdatedControls>
                    </telerik:AjaxSetting>
                </AjaxSettings>
            </telerik:RadAjaxManager>
            <telerik:RadAjaxLoadingPanel runat="server" ID="RadAjaxLoadingPanel1" />
            <telerik:RadGrid runat="server" ID="RadGrid1" AutoGenerateColumns="false"
                AllowPaging="true">
                <MasterTableView DataKeyNames="ProductID" CommandItemDisplay="Top" InsertItemPageIndexAction="ShowItemOnCurrentPage">
                    <Columns>
                        <telerik:GridEditCommandColumn ButtonType="ImageButton" />
                        <telerik:GridBoundColumn DataField="ProductID" HeaderText="Product ID" ReadOnly="true"
                            ForceExtractValue="Always" ConvertEmptyStringToNull="true" />
                        <telerik:GridBoundColumn DataField="ProductName" HeaderText="Product Name" />
                        <telerik:GridBoundColumn DataField="UnitsInStock" HeaderText="Units In Stock" />
                        <telerik:GridBoundColumn DataField="UnitPrice" HeaderText="Price" DataFormatString="{0:c}"/>
                        <telerik:GridButtonColumn ConfirmText="Delete this product?" ConfirmDialogType="RadWindow"
                            ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" />
                    </Columns>
                    <EditFormSettings>
                        <EditColumn ButtonType="ImageButton" />
                    </EditFormSettings>
                </MasterTableView>
                <PagerStyle Mode="NextPrevAndNumeric" />
                <ClientSettings>
                    <ClientEvents OnRowDblClick="rowDblClick" />
                </ClientSettings>
            </telerik:RadGrid>
            <telerik:RadInputManager runat="server" ID="RadInputManager1" Enabled="true">
                <telerik:TextBoxSetting BehaviorID="TextBoxSetting1">
                </telerik:TextBoxSetting>
                <telerik:NumericTextBoxSetting BehaviorID="NumericTextBoxSetting1" Type="Currency"
                    AllowRounding="true" DecimalDigits="2">
                </telerik:NumericTextBoxSetting>
                <telerik:NumericTextBoxSetting BehaviorID="NumericTextBoxSetting2" Type="Number"
                    AllowRounding="true" DecimalDigits="0" MinValue="0">
                </telerik:NumericTextBoxSetting>
            </telerik:RadInputManager>
            <telerik:RadWindowManager ID="RadWindowManager1" runat="server" />
            <qsf:Footer ID="Footer1" runat="server"></qsf: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