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

[Solved] RadDateInput inside EditItemTemplate

1 Answer 100 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Chris asked on 28 Jul 2009, 12:19 PM
Hi and thanks for your help in advance.

I've currently got a RadGrid bound to an EntityDataSource and I'm trying to do the following it works fine for edits but the moment I try and do an insert I get the following message 'Telerik.Web.UI.GridInsertionObject' does not contain a property with the name 'StartDate'.

<EditItemTemplate> 
    <telerik:RadDatePicker ID="StartDate" runat="server" SelectedDate='<%# Bind("StartDate") %>' /> 
    <asp:RequiredFieldValidator ID="DataRequired" runat="server" ControlToValidate="StartDate" 
        ErrorMessage="Required" /> 
</EditItemTemplate> 

I've noticed most of the examples seem to avoid using a RadDatePicker inside a grid and I'm starting to think I've discovered why...

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 28 Jul 2009, 01:24 PM
Hello Chris,

The reason for this error is that your grid instance can not bind a value for the newly inserted item through the Eval()/Bind() syntax you hard-coded(This you can find mentioned in this help document as well)
To resolve this issue, you would have to preset the default value of the RadDatePicker when binding to a grid item on the
InitInsert Command as shown below:

c#:

protected void RadGrid1_ItemCommand(object  source, Telerik.Web.UI.GridCommandEventArgs e) 
            if (e.CommandName == RadGrid.InitInsertCommandName) 
            {               
               e.Canceled = true
               //Prepare an IDictionary with the predefined values 
               System.Collections.Specialized.ListDictionary newValues = new  System.Collections.Specialized.ListDictionary(); 
               newValues["StartDate"] = "value"
               //Insert the item and rebind 
               e.Item.OwnerTableView.InsertItem(newValues); 
           } 
}  

Thanks
Princy.
Tags
Grid
Asked by
Chris
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or