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

Returning other types besides Double for LINQ

9 Answers 109 Views
Input
This is a migrated thread and some comments may be shown as answers.
Brett
Top achievements
Rank 2
Brett asked on 02 Sep 2008, 09:16 AM
I'm trying to do a bind on a RadNumericTextbox in a Radgrid :
DbValue='<%# Bind("MaxCorePerWeek") %>'. I'm using a LinqDataSource.

I can see the value in the textbox but clicking update causes the error- Object of type 'System.Double' cannot be converted to type 'System.Int16'

I've set a break on the Updating event of the LinqDatasource but when I view the the args the exception has already occurred at this point.

Is there no simple way to tell a RadNumericTextBox what specific type to return?

9 Answers, 1 is accepted

Sort by
0
Missing User
answered on 02 Sep 2008, 10:00 AM
Hello Brett,

You can handle the Updating event handler to examine data validation errors from the data class, to change a value before the Update operation, or to cancel the Update operation.

Here is an example:

    protected void LinqDataSource1_Updating(object sender, LinqDataSourceUpdateEventArgs e) 
    { 
        //Your code goes here 
    } 




Kind regards,
Plamen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Brett
Top achievements
Rank 2
answered on 02 Sep 2008, 10:10 AM
Please read the 3rd paragraph of my original note.
0
plamen
Top achievements
Rank 1
answered on 05 Sep 2008, 07:26 AM
Hi,


You may check your .xsd to see if the filed was set in the right Type. Change the Type of the property for an entity to anything compatible with the Server Data Type.


Regards...
<John:Peel />
0
Brett
Top achievements
Rank 2
answered on 05 Sep 2008, 07:41 AM
Hi John

I'm using LINQ classes not datasets.
0
plamen
Top achievements
Rank 1
answered on 08 Sep 2008, 07:33 AM
hi


You could configure the MyField to be System.Double by selecting it within the LINQ to SQL designer and by settings its Type in the property grid.


Hope this helps...
<John:Peel />
0
Accepted
Cres
Top achievements
Rank 1
answered on 13 Oct 2008, 07:46 AM
hi brett,

i have the same problem and solved it by adding the actual datatypes on insert and update parameters of my linq datasource.

hth
-cris

 

<UpdateParameters> 
        <asp:Parameter Name="ctrl_tot" Type="Decimal" ConvertEmptyStringToNull="true" /> 
        <asp:Parameter Name="ctrl_cnt" Type="Int32" ConvertEmptyStringToNull="true" /> 
        <asp:Parameter Name="tran_id" Type="Int32"  ConvertEmptyStringToNull="true" /> 
        <asp:Parameter Name="emp_id" Type="Int32"  ConvertEmptyStringToNull="true" /> 
</UpdateParameters> 

 

 

 

0
Brett
Top achievements
Rank 2
answered on 16 Oct 2008, 05:38 AM
Thanks Cris for a simple working solution. I was not happy with changing my type to Double all the time. Even Telerik support said I should change the type to Double in my dbml.
0
Nicolo
Top achievements
Rank 1
answered on 11 Apr 2009, 07:05 AM
Found this after long searching. Thanks!
0
Rich Coleman
Top achievements
Rank 1
answered on 17 Nov 2009, 02:34 PM
This answer saved my life.
Tags
Input
Asked by
Brett
Top achievements
Rank 2
Answers by
Missing User
Brett
Top achievements
Rank 2
plamen
Top achievements
Rank 1
Cres
Top achievements
Rank 1
Nicolo
Top achievements
Rank 1
Rich Coleman
Top achievements
Rank 1
Share this question
or