This is a migrated thread and some comments may be shown as answers.

Database update problems

0 Answers 39 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Hassen
Top achievements
Rank 1
Hassen asked on 31 Aug 2010, 11:05 PM
Hi 
i have database update problems with two related listboxes , the errors appear when i try to move an item from the first listbox to the second (it seems like the fields value is not transferred with the item) or when i try to delete an item from the second listbox (scalar variable isn't declared error)!
Got a problem also with my ajaxpanel it dosent seem to work (the page reloads when i try to move an item)

i would liked to attach my project but it says File is not of correct type so here is the aspxpage code !

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication3._Default" %>
 
<%@ 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">
 
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    
     
    
     
    <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" height="200px"
        width="737px" HorizontalAlign="NotSet"
        LoadingPanelID="RadAjaxLoadingPanel1" RenderMode="Inline">
 
          
        <div style="float:left; margin-left:20px">
 
         <telerik:RadListBox
            runat="server" ID="RadListBox1"
            DataSourceID="SqlDataSource1"
            DataKeyField="mail" DataTextField="mail" DataSortField="mail" Height="200px"
            AllowTransfer="True" TransferToID="RadListBox2"
            AutoPostBackOnTransfer="True" DataValueField="mail"
                style="top: 0px; left: 0px; width: 222px" AllowAutomaticUpdates="True"
                TransferMode="Copy" />
 
 
        </div>
     
    <div style="float:left; margin-left:20px;">
     
    <telerik:RadListBox
            runat="server" ID="RadListBox2"
            DataSourceID="SqlDataSource2"
            DataKeyField="mail" DataTextField="mail" DataSortField="SortOrder"
            Width="230px" Height="200px"
            AllowReorder="True" AutoPostBackOnReorder="True"
            AllowDelete="True" AutoPostBackOnDelete="True"
            AllowAutomaticUpdates="True" DataValueField="mail"
            TransferToID="RadListBox1" />
 
     
    </div>
     
     
 
    </telerik:RadAjaxPanel>
     
            <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" Runat="server"
                Skin="Default">
            </telerik:RadAjaxLoadingPanel>
     
    <asp:SqlDataSource ID="SqlDataSource1" runat="server"
        ConnectionString="<%$ ConnectionStrings:notifications_dbConnectionString %>"
        DeleteCommand="DELETE FROM [utilisateurs] WHERE [mail] = @mail"
        InsertCommand="INSERT INTO [utilisateurs] ([mail]) VALUES (@mail)"
        SelectCommand="SELECT [mail] FROM [utilisateurs]">
        <DeleteParameters>
            <asp:Parameter Name="mail" Type="String" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="mail" Type="String" />
        </InsertParameters>
    </asp:SqlDataSource>
    <telerik:RadScriptManager ID="RadScriptManager1" Runat="server">
    </telerik:RadScriptManager>
    <asp:SqlDataSource ID="SqlDataSource2" runat="server"
        ConnectionString="<%$ ConnectionStrings:notifications_dbConnectionString %>"
        DeleteCommand="DELETE FROM [presents] WHERE [mail] = @mail AND [id_plan] = @id_plan"
        InsertCommand="INSERT INTO [presents] ([mail], [id_plan]) VALUES (@mail, @id_plan)"
        SelectCommand="SELECT [mail], [id_plan] FROM [presents]">
        <DeleteParameters>
            <asp:Parameter Name="mail" Type="String" />
            <asp:Parameter Name="id_plan" Type="Int32" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="mail" Type="String"/>
   <%--in my project the id_plan key is transferred with a link but you can do the same by adding to the current page
   adresse in the browser " ?id_plan=key" key could be 2 or 1 here --%>        
            <asp:QueryStringParameter DefaultValue="2" Name="id_plan"
                QueryStringField="id_plan" Type="Int32" />
        </InsertParameters>
         
    </asp:SqlDataSource>
     
    </form>
</body>
</html>

No answers yet. Maybe you can help?

Tags
ListBox
Asked by
Hassen
Top achievements
Rank 1
Share this question
or