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

EditTemplate and Insert New Record issue

1 Answer 45 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jaymie
Top achievements
Rank 1
Jaymie asked on 07 Jan 2011, 02:49 PM
Hi,

I have a issue at the moment which I can't seem to fix.
Basically I have my own custom edit form which looks like this:
<EditFormSettings EditFormType="Template">
    <FormTemplate>
        <div style="padding: 5px;">
            <telerik:RadDatePicker ID="RadDatePicker1" SelectedDate='<%# Bind( "HolidayDate" ) %>' runat="server" /><br />
            <asp:LinkButton ID="Button1" Text='<%# Iif (TypeOf Container is GridEditFormInsertItem, "Insert", "Update") %>'
                runat="server" CommandName='<%# Iif (TypeOf Container is GridEditFormInsertItem, "PerformInsert", "Update") %>' /> 
            <asp:LinkButton ID="Button2" Text="Cancel" runat="server" CausesValidation="False" CommandName="Cancel" />
        </div>
    </FormTemplate>
</EditFormSettings>

This works fine when editing a record, but if I click 'Add new record' I get this error message:

System.InvalidCastException: Specified cast is not valid.

It points to the RadDatePicker and I found that if I remove the SelectedDate it works fine. But I need the selected Date when editing an existing record.
Could someone tell me (which I assume is simple!) how to resolve this?

1 Answer, 1 is accepted

Sort by
0
Mike Nogen
Top achievements
Rank 1
answered on 07 Jan 2011, 04:28 PM
Hello!

Try use it like this.
<telerik:RadDatePicker ID="RadDatePicker1" runat="server" MinDate="1/1/1900" DbSelectedDate='<%# Bind("HolidayDate") %>'
                                               TabIndex="4">
                                           </telerik:RadDatePicker>

Or look at this example where they use the DatePicker in an EditTemmplate
http://demos.telerik.com/aspnet-ajax/grid/examples/dataediting/templateformupdate/defaultcs.aspx

/M
Tags
Grid
Asked by
Jaymie
Top achievements
Rank 1
Answers by
Mike Nogen
Top achievements
Rank 1
Share this question
or