InvalidCastException when Inserting record

8 posts, 0 answers
  1. Perry
    Perry avatar
    19 posts
    Member since:
    Jan 2008

    Posted 13 Mar 2009 Link to this post

    I have a grid which has this column:

    <telerik:GridDateTimeColumn UniqueName="date" DataField="date" HeaderText="Date" ItemStyle-Width="120px"></telerik:GridDateTimeColumn> 

    I have a FormTemplate with this line:

    <telerik:RadDatePicker ID="datenews" runat="server" SelectedDate='<%# Bind("date") %>'

    When I edit a record, this works fine.

    When I go to insert a new record I get this:
    System.InvalidCastException: Specified cast is not valid 

    On the RadDatePicker line above.

    Help?

    Second question:

    I tried to avoid creating the FormTemplate in the first place and use the automatically generated edit / insert form. I could not locate how to manipulate (change width, height, textmode) the text boxes automatically created.







  2. Sebastian
    Admin
    Sebastian avatar
    9934 posts

    Posted 16 Mar 2009 Link to this post

    Hi Perry,

    Onto your questions:

    1. You need to bind the DbSelectedDate property of the date picker instance to avoid the exception (since it is of nullable type and can intercept null value on init insert operation). See this demo for more details:

      http://demos.telerik.com/aspnet-ajax/calendar/examples/datepicker/databinding/defaultcs.aspx
    2. For the second part you can use declarative style editors as explained in this help topic. For more flexible edit form customization you can use FormTemplate or WebUserControl custom edit form.
    Best regards,
    Sebastian
    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.
  3. Perry
    Perry avatar
    19 posts
    Member since:
    Jan 2008

    Posted 16 Mar 2009 Link to this post

    I have to tell you the thing that most angers me about your products. The documentation never matches the examples which never matches the version I have. I don't have a DbSelectedDate - when did that become available?
  4. Perry
    Perry avatar
    19 posts
    Member since:
    Jan 2008

    Posted 16 Mar 2009 Link to this post

    I just downloaded the 2009 ASP.NET AJAX version.

    I deleted the old dll from the project.

    I added a reference to the new DLL.

    I closed VS2008 and reopened it.

    The new DLL is in the project.

    There is no evidence of DbSelectedDate - what am I doing wrong?
  5. Sebastian
    Admin
    Sebastian avatar
    9934 posts

    Posted 17 Mar 2009 Link to this post

    Hello Perry,

    Since the DbSelectedDate is nullable property, it is not displayed when using the Visual Studio Intellisense. Nevertheless, specifying this property value through the date picker tag should do the trick.

    I am sorry to hear that you are having a hard time finding the information you need in the support resources available for our products. I encourage you to explore the resources linked in the footer of this message which provide useful tips about how to optimize your support resources searches.

    Kind regards,
    Sebastian
    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.
  6. Matt
    Matt avatar
    99 posts
    Member since:
    Jun 2012

    Posted 04 Jun 2018 in reply to Sebastian Link to this post

    I know this post is very old... perhaps someone else will come across it and painfully waste their time looking for instructions that don't work... I wish this old stuff would get deleted.

    BTW, the practice hasn't changed. I still use this product (2015 Q2) because it's paid for but I'm phasing it out. At the moment, I have to fix something that gives me the same error message but on a RadButton in a RadGrid. Click the "insert" button to begin adding a record (all out-of-the-box stuff) and I get this error. Why? I suppose because SQL usings bit and they use boolean and something gets lost in translation.

    I'm guessing the fix is to use back-mark up because front-end mark up won't work.

    Oh when will I learn...

  7. Matt
    Matt avatar
    99 posts
    Member since:
    Jun 2012

    Posted 04 Jun 2018 in reply to Matt Link to this post

    Actually, it's on EVERY databound item in the RadGrid... ugh... it's like this was never even tested with all of the possibilities advertised.
  8. Marin Bratanov
    Admin
    Marin Bratanov avatar
    5522 posts

    Posted 07 Jun 2018 Link to this post

    Hi Matt,

    I am sorry that you are facing such issues and that our controls are not suitable for your project anymore. We do try to test, and we have a great many scenarios covered. The possibilities in a real application are, however, endless, and in all likelihood there is something we haven't thought of.

    If you need help with this case, I encourage you to open a ticket and send us a small mockup of the problem so we can take a look.

    It is even possible that we have fixed it in a later version, so you can give R1 2018 a quick test to see if it works as expected for you.

    I have also added a noindex robots meta tag to this page as it is, indeed, quite old (from 2009), so hopefully Google will honor it and stop putting it in results.


    Regards,
    Marin Bratanov
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top