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

Object of type 'System.Int32' cannot be converted to type 'System.String'

1 Answer 1231 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Adam
Top achievements
Rank 1
Adam asked on 03 Nov 2009, 01:31 AM
Hello
  1. I have two RadListBoxes linked to two different ObjectDataSource objects RadListBox1 and RadListBox2.  (Markup below)
  2. My project uses an SQL Server 2005 database using SQL to Linq. 
  3. When I attempt to Transfer items from RadListBox1 to RadListBox2 I receive a javascript error: "Error: Sys.WebForms.PageRequestManagerServerErrorException: Object of type 'System.Int32' cannot be converted to type 'System.String'."
  4. When I clcik the trasnfer button, the "Deleted" event is fired for the first list box, but for some reason the Insert event for the second listbox is not being triggered. 

List Box Markup:
<td> 
                        <h2>Available Features</h2> 
                        <telerik:RadListBox ID="RadListBox1"  
                            runat="server"  
                            AllowTransfer="True"                              
                            DataKeyField="FeatureId"  
                            DataSortField="FeatureId"  
                            DataSourceID="FeatureDS"  
                            DataTextField="FeatureDescription"  
                            DataValueField="FeatureId"  
                            TransferToID="RadListBox2"  
                            AllowAutomaticUpdates="True"  
                            AutoPostBackOnTransfer="True"  
                            EmptyMessage="There are no available features."  
                            Skin="Office2007"  
                            Width="250px"
                            <ButtonSettings ShowTransferAll="False" /> 
                            <EmptyMessageTemplate> 
                                There are no available features. 
                            </EmptyMessageTemplate> 
                        </telerik:RadListBox> 
                    </td> 
                    <td> 
                        <h2>Competitor Features</h2> 
                        <telerik:RadListBox  
                            runat="server"  
                            ID="RadListBox2"  
                            DataKeyField="FeatureId"  
                            DataSortField="FeatureDescription"  
                            DataSourceID="CompetitorFeatureDS"  
                            DataTextField="FeatureDescription"  
                            AllowAutomaticUpdates="True"  
                            EmptyMessage="This competitor has no features assigned."  
                            Skin="Office2007"  
                            Width="250px"
                            <ButtonSettings ShowTransferAll="False" /> 
                            <EmptyMessageTemplate> 
                                This competitor has no features assigned. 
                            </EmptyMessageTemplate> 
                        </telerik:RadListBox> 
                    </td> 

DataSources:
<%--**************************************************--%> 
<%--DATA SOURCES--%> 
<%--**************************************************--%> 
<pp:ObjectContainerDataSource ID="CompetitorDS"              
    DataObjectTypeName="MagicMindsCRM.Modules.Competitors.BusinessEntities.Competitor" 
    OnUpdated="CompetitorDS_Updated"  
    runat="server" /> 
        
     
    <pp:ObjectContainerDataSource ID="CompetitorFeatureDS"              
    DataObjectTypeName="MagicMindsCRM.Modules.Competitors.BusinessEntities.CompetitorFeature" 
    OnDeleted="CompetitorFeatureDS_Deleted"  
    OnInserted="CompetitorFeatureDS_Inserted"      
    runat="server" /> 
     
    <pp:ObjectContainerDataSource ID="FeatureDS" DataObjectTypeName="MagicMindsCRM.Modules.Competitors.BusinessEntities.Feature" runat="server"  
    OnDeleted="FeatureDS_Deleted"  
    OnInserted="FeatureDS_Inserted" /> 
     
    <pp:ObjectContainerDataSource ID="CompetitorStatusDS" DataObjectTypeName="MagicMindsCRM.Modules.Competitors.BusinessEntities.CompetitorStatus" runat="server" />     
     

Screenshot attached.

Many thanks for your help.

1 Answer, 1 is accepted

Sort by
0
Simon
Telerik team
answered on 09 Nov 2009, 04:52 PM
Hello Adam,

Thank you for providing your code.

This exception means that there is an invalid cast from Int32 to String somewhere in your code. Please verify the Insert command of the CompetitorFeatureDS data source for such inconsistency.

Kind regards,
Simon
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
ListBox
Asked by
Adam
Top achievements
Rank 1
Answers by
Simon
Telerik team
Share this question
or