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

InvalidCastException when Inserting record

7 Answers 51 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Perry
Top achievements
Rank 1
Perry asked on 13 Mar 2009, 08:41 PM
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.







7 Answers, 1 is accepted

Sort by
0
Sebastian
Telerik team
answered on 16 Mar 2009, 04:08 PM
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.
0
Perry
Top achievements
Rank 1
answered on 16 Mar 2009, 08:13 PM
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?
0
Perry
Top achievements
Rank 1
answered on 16 Mar 2009, 08:45 PM
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?
0
Sebastian
Telerik team
answered on 17 Mar 2009, 10:39 AM
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.
0
Matt
Top achievements
Rank 1
answered on 04 Jun 2018, 09:11 PM

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...

0
Matt
Top achievements
Rank 1
answered on 04 Jun 2018, 09:15 PM
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.
0
Marin Bratanov
Telerik team
answered on 07 Jun 2018, 09:16 AM
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.
Tags
Grid
Asked by
Perry
Top achievements
Rank 1
Answers by
Sebastian
Telerik team
Perry
Top achievements
Rank 1
Matt
Top achievements
Rank 1
Marin Bratanov
Telerik team
Share this question
or