New to Telerik UI for ASP.NET AJAX? Download free 30-day trial

Database Update

  • USA
  • Kenya
  • Brazil
  • Egypt
Event log
  • Demo Configurator

RadListBox can perform transfer, delete and reorder operations and update the underlying datasource control.

To enable automatic updates you should set the AllowAutomaticUpdates property to true. Automatic updates require postback so any of the AutoPostBackOnReorder/AutoPostBackOnTransfer/AutoPostBackOnDelete properties should be also set to true.

  • DefaultVB.aspx
  • DefaultVB.aspx.vb
<%@ Page Language="VB" AutoEventWireup="True" CodeFile="DefaultVB.aspx.vb" Inherits="ListBox.Examples.PopulatingWithData.DatabaseUpdate.DefaultVB" %>
<%@ Register TagPrefix="qsf" Namespace="Telerik.QuickStart" %>
<%@ Register TagPrefix="sds" Namespace="Telerik.Web.SessionDS" %>
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<!DOCTYPE html>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head runat="server">
    <title>Telerik ASP.NET Example</title>
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
    <telerik:RadSkinManager ID="RadSkinManager1" runat="server" ShowChooser="true" />
    <telerik:RadAjaxManager runat="server" ID="RadAjaxManager1">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="ConfiguratorPanel1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="DemoPanel" LoadingPanelID="RadAjaxLoadingPanel1" />
                    <telerik:AjaxUpdatedControl ControlID="ConfiguratorPanel1" LoadingPanelID="RadAjaxLoadingPanel1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <telerik:RadAjaxLoadingPanel runat="server" ID="RadAjaxLoadingPanel1"></telerik:RadAjaxLoadingPanel>

    <asp:Panel ID="DemoPanel" runat="server">

        <div class="demo-container size-narrow">
            <telerik:RadListBox RenderMode="Lightweight" runat="server" ID="RadListBox1" DataSourceID="SourceDataSource"
                DataKeyField="ID" DataTextField="Name" DataSortField="SortOrder" Width="240px"
                Height="200px" AllowTransfer="true" TransferToID="RadListBox2" AutoPostBackOnTransfer="true">
            </telerik:RadListBox>
            <telerik:RadListBox RenderMode="Lightweight" runat="server" ID="RadListBox2" DataSourceID="DestinationDataSource"
                DataKeyField="ID" DataTextField="Name" DataSortField="SortOrder" Width="240px"
                Height="200px" AllowReorder="true" AutoPostBackOnReorder="true" AllowDelete="True"
                AutoPostBackOnDelete="true">
            </telerik:RadListBox>
        </div>

        <qsf:EventLogConsole runat="server" ID="EventLogConsole1"></qsf:EventLogConsole>

        <asp:SqlDataSource runat="server" ID="SourceDataSource"
            ConnectionString="<%$ ConnectionStrings:TelerikConnectionString35 %>"
            DeleteCommand="DELETE FROM [Countries] WHERE [ID] = @ID"
            InsertCommand="INSERT INTO [Countries] ([Name], [ContinentID], [SortOrder]) VALUES (@Name, @ContinentID, @SortOrder)"
            SelectCommand="SELECT [Name], [ID], [ContinentID], [SortOrder] FROM [Countries] ORDER BY [SortOrder]"
            UpdateCommand="UPDATE [Countries] SET [Name] = @Name, [ContinentID] = @ContinentID, [SortOrder] = @SortOrder WHERE [ID] = @ID"
            OnDeleted="SourceDataSource_Deleted" OnInserted="SourceDataSource_Inserted">
            <UpdateParameters>
                <asp:Parameter Name="Name" Type="String"></asp:Parameter>
                <asp:Parameter Name="ContinentID" Type="Int32"></asp:Parameter>
                <asp:Parameter Name="SortOrder" Type="Int32"></asp:Parameter>
                <asp:Parameter Name="ID" Type="Int32"></asp:Parameter>
            </UpdateParameters>
            <DeleteParameters>
                <asp:Parameter Name="ID" Type="Int32"></asp:Parameter>
            </DeleteParameters>
            <InsertParameters>
                <asp:Parameter Name="Name" Type="String"></asp:Parameter>
                <asp:Parameter Name="ContinentID" Type="Int32"></asp:Parameter>
                <asp:Parameter Name="SortOrder" Type="Int32"></asp:Parameter>
            </InsertParameters>
        </asp:SqlDataSource>
        <asp:SqlDataSource runat="server" ID="DestinationDataSource"
            ConnectionString="<%$ ConnectionStrings:TelerikConnectionString35 %>"
            DeleteCommand="DELETE FROM [DestinationCountries] WHERE [ID] = @ID"
            InsertCommand="INSERT INTO [DestinationCountries] ([Name], [SortOrder], [ContinentID]) VALUES (@Name, @SortOrder, @ContinentID)"
            SelectCommand="SELECT [ID], [Name], [SortOrder], [ContinentID] FROM [DestinationCountries] ORDER BY [SortOrder]"
            UpdateCommand="UPDATE [DestinationCountries] SET [Name] = @Name, [SortOrder] = @SortOrder, [ContinentID] = @ContinentID WHERE [ID] = @ID"
            OnDeleted="DestinationDataSource_Deleted" OnInserted="DestinationDataSource_Inserted"
            OnUpdated="DestinationDataSource_Updated">
            <UpdateParameters>
                <asp:Parameter Name="Name" Type="String"></asp:Parameter>
                <asp:Parameter Name="SortOrder" Type="Int32"></asp:Parameter>
                <asp:Parameter Name="ContinentID" Type="Int32"></asp:Parameter>
                <asp:Parameter Name="ID" Type="Int32"></asp:Parameter>
            </UpdateParameters>
            <DeleteParameters>
                <asp:Parameter Name="ID" Type="Int32"></asp:Parameter>
            </DeleteParameters>
            <InsertParameters>
                <asp:Parameter Name="Name" Type="String"></asp:Parameter>
                <asp:Parameter Name="SortOrder" Type="Int32"></asp:Parameter>
                <asp:Parameter Name="ContinentID" Type="Int32"></asp:Parameter>
            </InsertParameters>
        </asp:SqlDataSource>
    </asp:Panel>

    <qsf:ConfiguratorPanel runat="server" ID="ConfiguratorPanel1">
        <Views>
            <qsf:View>
                <qsf:ConfiguratorColumn ID="ConfiguratorColumn1" runat="server" Size="Medium">
                    <asp:CheckBox runat="server" ID="AutomaticUpdatesCheckBox" Text="Allow Automatic Database Updates" AutoPostBack="true" Checked="true"></asp:CheckBox>
                </qsf:ConfiguratorColumn>
            </qsf:View>
        </Views>
    </qsf:ConfiguratorPanel>
    </form>
</body>
</html>

Support & Learning Resources

Find Assistance