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

RadGrid GridDateTimeColumn DefaultInsertValue Error

4 Answers 258 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Chuck
Top achievements
Rank 1
Chuck asked on 22 Jul 2011, 04:03 PM
I am trying to set a default insert value.  I have read the forums on how to do this from code-behind, and I have that working.  However I am very curious if there is a way to do this using the documented DefaultInsertValue property.  Whenever I try it, a javascript error is generated:

<

 

telerik:GridDateTimeColumn DataField="InspectionDate" DataType="System.DateTime" DefaultInsertValue='<% = Now().ToString() %>'

FilterControlAltText="Filter colInspectionDate column" HeaderText="Date"

UniqueName="colInspectionDate">

</telerik:GridDateTimeColumn>


I have also tried '<% = Now() %>'.

I get the following error:

Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerServerErrorException: The default insert value for column colInspectionDate cannot be converted to type System.DateTime

I am using Q2 2011.  Is this a bug?  Is DefaultInsertValue supposed to work?  Is there a formating option I have to use on the date?  I have been unable to find anyone who has a working example other than the code-behind solution.

Thanks.

4 Answers, 1 is accepted

Sort by
0
Tsvetoslav
Telerik team
answered on 28 Jul 2011, 12:08 PM
Hello Chuck,

Thank you for contacting us and for your question.

First of all, the syntax of your binding expression is incorrect, it should be:
DefaultInsertValue='<%#  Now().ToString() %>'

However, that won't do as well since the GridDateTimeColumn does not support binding expressions. You need to use the code-behind approach.

Hope it helps.

Regards,
Tsvetoslav
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
Chuck
Top achievements
Rank 1
answered on 28 Jul 2011, 01:42 PM
Tsvetoslav,

Thank you for the response.  Just for my own education, for the GridDateTimeColumn does the DefaultInsertValue property do anything?  Or it it just there to spread confusion?  (Not trying to be snarky - I love your products - just curious.)
0
Accepted
Tsvetoslav
Telerik team
answered on 29 Jul 2011, 05:34 AM
Hello Chuck,

It certainly does - try setting a valid date for it, e.g.: DefaultInsertValue="09/6/2011". What it allows is a hard-coded date, not a binding expression.

Best wishes,
Tsvetoslav
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
Chuck
Top achievements
Rank 1
answered on 02 Aug 2011, 02:45 PM
Thank you.
Tags
Grid
Asked by
Chuck
Top achievements
Rank 1
Answers by
Tsvetoslav
Telerik team
Chuck
Top achievements
Rank 1
Share this question
or