TreeList - NET 3.5 automatic data editing

Next database reset in 0 hours, 39 minutes, 54 seconds
 IDCategoriesParent ID
1
Page size:
PageSizeComboBox
select
 2Politics 
 3Sports 
 4Events 

Edit Mode Configurator



Isolate this demo as a stand-alone application

This example illustrates how automatic insert, update and delete data operations can be achieved with RadTreeList and all ASP 3.5 DataSource control types like EntityDataSource:

What you need to do is to set the following properties:

  • DataSourceID property of the RadTreeList to the ID of the Data Source control
  • EnableUpdate, EnableInsert, EnableDelete properties of the Data Source control to true
  • DataKeyNames and ParentDataKeyNames properties of RadTreeList by listing the data source table Primary keys

The RadTreelist control expects the key to be incremented when you insert items, therefore the new items are located at the bottom of the group.

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.

<%@ Page Language="c#" CodeFile="~/TreeList/Examples/DataEditing/Net35AutomaticDataEditing/DefaultCS.aspx.cs"Inherits="Telerik.Web.Examples.TreeList.DataEditing.NET35AutomaticDataEditing.DefaultCS"  %>

<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<%@ Register TagPrefix="qsf" Namespace="Telerik.QuickStart" %>
<!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">
    <title>Telerik ASP.NET Example</title>
    <style type="text/css">
        .MyImageButton {
            cursor: pointer;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
    <telerik:RadSkinManager ID="RadSkinManager1" runat="server" ShowChooser="true" />
    <div class="demo-container no-bg">
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server"></telerik:RadAjaxLoadingPanel>
        <telerik:RadAjaxPanel ID="RadAjaxPanel1" LoadingPanelID="RadAjaxLoadingPanel1" runat="server">

            <telerik:RadTreeList runat="server" ID="RadTreeList1" DataSourceID="EntityDataSource1" AllowPaging="true" PageSize="5" DataKeyNames="id" ParentDataKeyNames="parentId" AutoGenerateColumns="false">
                <Columns>
                    <telerik:TreeListEditCommandColumn UniqueName="EditCommandColumn" ButtonType="ImageButton" HeaderStyle-Width="80px">
                        <ItemStyle CssClass="MyImageButton"></ItemStyle>
                    </telerik:TreeListEditCommandColumn>
                    <telerik:TreeListButtonColumn UniqueName="DeleteCommandColumn" Text="Delete" CommandName="Delete" HeaderStyle-Width="40px" ButtonType="ImageButton"></telerik:TreeListButtonColumn>
                    <telerik:TreeListBoundColumn DataField="id" UniqueName="id" HeaderText="ID" ReadOnly="true"></telerik:TreeListBoundColumn>
                    <telerik:TreeListBoundColumn DataField="Text" UniqueName="Categories" HeaderText="Categories"></telerik:TreeListBoundColumn>
                    <telerik:TreeListBoundColumn DataField="parentid" UniqueName="parentid" HeaderText="Parent ID" ReadOnly="true"></telerik:TreeListBoundColumn>
                </Columns>
            </telerik:RadTreeList>
        </telerik:RadAjaxPanel>
        <asp:EntityDataSource runat="server" ID="EntityDataSource1" ConnectionString="name=TelerikReadWriteEntities" DefaultContainerName="TelerikReadWriteEntities" EntitySetName="Links" EnableInsert="True" EnableUpdate="True" EnableDelete="True">
        </asp:EntityDataSource>
    </div>
    <qsf:ConfiguratorPanel runat="server" ID="ConfigurationPanel1" Title="Edit Mode Configurator" Expanded="true">
        <Views>
            <qsf:View>
                <qsf:ConfiguratorColumn runat="server" Size="Medium">
                    <qsf:RadioButtonList ID="RadioButtonList1" runat="server" AutoPostBack="true" OnSelectedIndexChanged="RadioButtonList1_SelectedIndexChanged">
                        <asp:ListItem Text="In-forms editing mode" Value="EditForms" Selected="True"></asp:ListItem>
                        <asp:ListItem Text="In-line editing mode" Value="InPlace"></asp:ListItem>
                        <asp:ListItem Text="Pop-up editing mode" Value="PopUp"></asp:ListItem>
                    </qsf:RadioButtonList>
                </qsf:ConfiguratorColumn>
            </qsf:View>
        </Views>
    </qsf:ConfiguratorPanel>
    </form>
</body>
</html>

Support & Learning Resources

Find Assistance

Help Us Improve

Was this example helpful?