<%@ Page Language="C#" AutoEventWireup="true" CodeFile="DatabaseUpdate.aspx.cs" Inherits="DatabaseUpdate" %>

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager runat="server" ID="ScriptManager1">
    </asp:ScriptManager>
    <div>
        <telerik:RadListBox   
            runat="server"   
            ID="RadListBox1"   
            AllowTransfer="True" 
            AllowDelete="false" 
            AutoPostBackOnTransfer="true" 
            AllowAutomaticUpdates="true"   
            TransferToID="RadListBox2"   
            DataSourceID="SqlDataSource1"   
            DataKeyField="ID"   
            DataTextField="Value"   
            DataValueField="ID"
            CheckBoxes="true">  
        </telerik:RadListBox> 
        <telerik:RadListBox ID="RadListBox2" runat="server"   
            AllowAutomaticUpdates="true" 
            AllowDelete="true"
            AllowTransferDuplicates="true"  
            DataKeyField="ID" 
            DataSourceID="SqlDataSource2"   
            DataTextField="Value"   
            DataValueField="ID"
            CheckBoxes="true">  
        </telerik:RadListBox> 
        
        
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConflictDetection="CompareAllValues" 
            ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
            DeleteCommand="DELETE FROM [Table1] WHERE [ID] = @original_ID AND (([Value] = @original_Value) OR ([Value] IS NULL AND @original_Value IS NULL))" 
            InsertCommand="INSERT INTO [Table1] ([Value]) VALUES (@Value)" 
            OldValuesParameterFormatString="original_{0}" 
            SelectCommand="SELECT * FROM [Table1]" 
            UpdateCommand="UPDATE [Table1] SET [Value] = @Value WHERE [ID] = @original_ID AND (([Value] = @original_Value) OR ([Value] IS NULL AND @original_Value IS NULL))" >
            <DeleteParameters>
                <asp:Parameter Name="original_ID" Type="Int32" />
                <asp:Parameter Name="original_Value" Type="String" />
            </DeleteParameters>
            <UpdateParameters>
                <asp:Parameter Name="Value" Type="String" />
                <asp:Parameter Name="original_ID" Type="Int32" />
                <asp:Parameter Name="original_Value" Type="String" />
            </UpdateParameters>
            <InsertParameters>
                <asp:Parameter Name="Value" Type="String" />
            </InsertParameters>
           
        </asp:SqlDataSource>
        <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
            ConflictDetection="CompareAllValues" 
            ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
            DeleteCommand="DELETE FROM [Table2] WHERE [ID] = @original_ID AND (([Value] = @original_Value) OR ([Value] IS NULL AND @original_Value IS NULL))" 
            InsertCommand="INSERT INTO [Table2] ([Value]) VALUES (@Value)" 
            OldValuesParameterFormatString="original_{0}" 
            SelectCommand="SELECT * FROM [Table2]" 
            UpdateCommand="UPDATE [Table2] SET [Value] = @Value WHERE [ID] = @original_ID AND (([Value] = @original_Value) OR ([Value] IS NULL AND @original_Value IS NULL))" >
            <DeleteParameters>
                <asp:Parameter Name="original_ID" Type="Int32" />
                <asp:Parameter Name="original_Value" Type="String" />
            </DeleteParameters>
            <UpdateParameters>
                <asp:Parameter Name="Value" Type="String" />
                <asp:Parameter Name="original_ID" Type="Int32" />
                <asp:Parameter Name="original_Value" Type="String" />
            </UpdateParameters>
            <InsertParameters>
                <asp:Parameter Name="Value" Type="String" />
            </InsertParameters>
           
        </asp:SqlDataSource>
    </div>
    </form>
</body>
</html>
