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

ListBox won't insert into Database

6 Answers 175 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Tobias Jeckle
Top achievements
Rank 1
Tobias Jeckle asked on 12 Aug 2009, 01:42 PM
I have to Listboxes populated by a database. The goal is to copy items from RadListBoxSource to RadListBoxTarget. RadListBoxSource should insert the record via Autopostback into the database. The database is a Oracle 10.
The problem is, that the records in RadListBoxTarget won't be inserted into the database. Deleting from db works fine.
What's wrong with the code? Anyone got an idea?

<telerik:RadScriptManager runat="server" ID="RadScriptManager1" /> 
    <telerik:RadAjaxLoadingPanel runat="server" ID="RadAjaxLoadingPanel1" /> 
    <telerik:RadAjaxPanel runat="server" ID="RadAjaxPanel1" LoadingPanelID="RadAjaxLoadingPanel1">  
          
        <telerik:RadListBox ID="RadListBoxSource" runat="server" Width="400px" Height="200px" 
            SelectionMode="Multiple" AllowTransfer="true"   
            TransferToID="RadListBoxTarget" AutoPostBackOnTransfer="true" 
            AllowReorder="false" TransferMode="Copy"   
            DataSourceID="SqlDataSourceSource" DataKeyField="ID" 
            DataTextField="ID" DataValueField="ID">  
        </telerik:RadListBox> 
 
        <telerik:RadListBox ID="RadListBoxTarget" runat="server" Width="400px" Height="200px" 
            SelectionMode="Multiple" AllowDelete="True" DataKeyField="ID"   
            DataSourceID="SqlDataSourceTarget"   
            DataTextField="ID" DataValueField="ID" 
            AutoPostBackOnDelete="true" AutoPostBackOnReorder="true"   
            TransferToID="RadListBoxSource">  
        </telerik:RadListBox> 
          
        <asp:SqlDataSource ID="SqlDataSourceSource" runat="server" ConnectionString="<%$ ConnectionStrings:BayerAgrarTVConnectionString %>" 
        ProviderName="<%$ ConnectionStrings:BayerAgrarTVConnectionString.ProviderName %>" 
        SelectCommand="SELECT ID, HEADLINE FROM AGRARTV2009_MOVIES WHERE (PUBLISH = 1) ORDER BY HEADLINE">  
        </asp:SqlDataSource> 
          
        <asp:SqlDataSource ID="SqlDataSourceTarget" runat="server" ConnectionString="<%$ ConnectionStrings:BayerAgrarTVConnectionString %>" 
        ProviderName="<%$ ConnectionStrings:BayerAgrarTVConnectionString.ProviderName %>" 
        SelectCommand="SELECT AGRARTV2009_MOVIES_TSR_BOX.ID_MOVIE AS ID, AGRARTV2009_MOVIES.HEADLINE FROM AGRARTV2009_MOVIES_TSR_BOX, AGRARTV2009_MOVIES WHERE AGRARTV2009_MOVIES_TSR_BOX.ID_MOVIE = AGRARTV2009_MOVIES.ID ORDER BY AGRARTV2009_MOVIES.HEADLINE" 
        InsertCommand="INSERT INTO AGRARTV2009_MOVIES_TSR_BOX (ID_MOVIE) VALUES (&ID)" 
        DeleteCommand="DELETE FROM AGRARTV2009_MOVIES_TSR_BOX WHERE ID_MOVIE = &ID">  
        <DeleteParameters> 
            <asp:Parameter Name="ID" Type="Int32" /> 
        </DeleteParameters> 
        <InsertParameters> 
            <asp:ControlParameter Name="ID" Type="Int32" /> 
        </InsertParameters> 
    </asp:SqlDataSource> 
          
    </telerik:RadAjaxPanel> 

6 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 12 Aug 2009, 02:44 PM
Hi Tobias Jeckle,

By default RadListBox will not update the underlying datasource. You need to set the AllowAutomaticUpdates to true. Please refer to the online example for additional info.

Regards,
Albert
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Tobias Jeckle
Top achievements
Rank 1
answered on 12 Aug 2009, 03:12 PM
Hi Albert,

I have added AllowAutomaticUpdates = true to the RadListBoxTarget.
What now happens is: When I try to transfer one item from source to destination RadListBox in the webbrowser (IE7), a javascript error appears and the item will not be moved / copied.
The Error is: Sys.WebForms.PageRequestManagerServerErrorException.
The page i am using is based an a Master Page. I'm not sure if this info is important.

Regards
0
Tobias Jeckle
Top achievements
Rank 1
answered on 13 Aug 2009, 12:01 PM
I am still searching for the failure.
I replaced the Oracle DB with a MS SQL Express. Thought that the Data Layer may cause the failure. But I still receive the JavaScript Error when transfering from Source to Target. Deleting items in the Target Control works fine.

I decided to remove the SQL Data Source and use "static data" in the Controls. It works.
As far as I bind the Controls to a SQL Data Source transfering from Source to Target stops worlking.
0
Genady Sergeev
Telerik team
answered on 17 Aug 2009, 10:29 AM
Hello Tobias Jeckle,

Can you try to disable the AJAX and paste here the error stack trace (this is server side error). Also, is there something special regarding your application? For example, do you use templates?

All the best,
Genady Sergeev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Tobias Jeckle
Top achievements
Rank 1
answered on 17 Aug 2009, 12:27 PM
Hi Genady Sergeev,

here is the stack trace.
 
[NullReferenceException: Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt.]  
   Telerik.Web.UI.RadListBoxItem.ExtractValues() +10  
   Telerik.Web.UI.RadListBox.PerformInsert(IList`1 items, Int32 position) +251  
   Telerik.Web.UI.RadListBox.PerformTransfer(RadListBox sourceListBox, RadListBox destinationListBox, IList`1 items) +852  
   Telerik.Web.UI.RadListBox.Transfer(IList`1 itemsToTransfer, RadListBox sourceListBox, RadListBox destinationListBox) +184  
   Telerik.Web.UI.RadListBox.OnTransfer(ListBoxPostBackCommand command, Func`2 callback) +137  
   Telerik.Web.UI.RadListBox.RaisePostBackEvent(String eventArgument) +292  
   Telerik.Web.UI.RadListBox.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10  
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13  
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +175  
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565  
 
   
 

I use a master page in my project. Thats it. Nothing special.
To be sure that's nothing wrong with my solution map, i created a new one from the scratch. Containing only one aspx page without templates.
But the failure is the same. You can find the posting here. http://www.telerik.com/community/forums/aspnet-ajax/listbox/transfermode-copy-gt-system-nullreferenceexception.aspx#912178
0
Genady Sergeev
Telerik team
answered on 17 Aug 2009, 03:44 PM
Hi Tobias Jeckle,

I have replied in the other thread as well. We are working on the fix for the bug. I will write a follow up to you when we are ready.

Best wishes,
Genady Sergeev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
ListBox
Asked by
Tobias Jeckle
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Tobias Jeckle
Top achievements
Rank 1
Genady Sergeev
Telerik team
Share this question
or