Returning other types besides Double for LINQ

10 posts, 1 answers
  1. Brett
    Brett avatar
    23 posts
    Member since:
    Feb 2006

    Posted 02 Sep 2008 Link to this post

    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?
  2. Plamen Peshev
    Admin
    Plamen Peshev avatar
    886 posts

    Posted 02 Sep 2008 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Brett
    Brett avatar
    23 posts
    Member since:
    Feb 2006

    Posted 02 Sep 2008 Link to this post

    Please read the 3rd paragraph of my original note.
  5. John
    John avatar
    416 posts
    Member since:
    Oct 2006

    Posted 05 Sep 2008 Link to this post

    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 />
  6. Brett
    Brett avatar
    23 posts
    Member since:
    Feb 2006

    Posted 05 Sep 2008 Link to this post

    Hi John

    I'm using LINQ classes not datasets.
  7. John
    John avatar
    416 posts
    Member since:
    Oct 2006

    Posted 08 Sep 2008 Link to this post

    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 />
  8. Answer
    Cris
    Cris avatar
    13 posts
    Member since:
    Feb 2008

    Posted 13 Oct 2008 Link to this post

    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> 

     

     

     

  9. Brett
    Brett avatar
    23 posts
    Member since:
    Feb 2006

    Posted 16 Oct 2008 Link to this post

    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.
  10. Nicolo
    Nicolo avatar
    9 posts
    Member since:
    Aug 2012

    Posted 11 Apr 2009 Link to this post

    Found this after long searching. Thanks!
  11. Rich Coleman
    Rich Coleman avatar
    19 posts
    Member since:
    Jan 2008

    Posted 17 Nov 2009 Link to this post

    This answer saved my life.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017