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

Using RadDateTimePicker in RadGrid

2 Answers 56 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Esperanza Ramos
Top achievements
Rank 1
Esperanza Ramos asked on 28 Aug 2008, 01:00 PM
Hi, All:

I copied from an example at telerik.com:

<

rad:GridTemplateColumn HeaderText="DateIn" DataField="DateIn" SortExpression="DateIn">
<EditItemTemplate>
<rad:RadDateTimePicker ID="RadDateTimePicker1" runat="server" Culture="English (United States)" DbSelectedDate='<%# Bind("DateIn", "{0:D}") %>' SharedCalendarID="" MinDate="01-01-1900"> <DateInput runat="server" />
</rad:RadDateTimePicker>
</EditItemTemplate>

But this won't compile: "Cannot convert type 'string' to 'System.DateTime'".

Please help.

Stanley

2 Answers, 1 is accepted

Sort by
0
Missing User
answered on 28 Aug 2008, 01:36 PM
Hello Stanley,

Binding a RadDatePicker, RadTimePicker, or RadDateTimePicker control to a data source is easy provided you use the DbSelectedDate property. It works almost like the SelectedDate one, but does not throw an exception when given a null value. Data-binding expressions are contained within <%# and %> delimiters and use the Eval and Bind functions. The Eval function is used to define one-way (read-only) binding. The Bind function is used for two-way (updatable) binding. You have to use <%# Bind("DateIn") %> instead of <%# Bind("DateIn", "{0:D}") %>


DbSelectedDate='<%# Bind("DateIn", "{0:D}") %>'


Kind regards,
Plamen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Esperanza Ramos
Top achievements
Rank 1
answered on 28 Aug 2008, 02:22 PM
Hi, Telerik Team:

Thank you.  Now it works.  You had helped so much.

The "cannot convert 'string' to 'System.DateTime?' error message is from
codes I put: <!--  something --> inside my aspx file.

thanks.

Stanley
Tags
Grid
Asked by
Esperanza Ramos
Top achievements
Rank 1
Answers by
Missing User
Esperanza Ramos
Top achievements
Rank 1
Share this question
or