I am attempting to set default values to a Telerik RadDataForm in the InitializingNewItem Event. RadDataForm is linked to a RadGridView as the Source, the intention is that when an item is selected in the grid and this is present in the dataform, clicking the Add New Item will pre-populate the dataform with some key data from the previously selected item.
You (Telerik) state: "Occurs when a new item is being added but after the AddingNewItem event. You can use this to set initial values for the initialized objects by passing an instance to the InitializingNewItemEventArgs' DataItem property."
However simply using:
private void RadDataForm_InitializingNewItem(object sender, Telerik.Windows.Controls.Data.DataForm.InitializingNewItemEventArgs e)
{
RadDataForm d = sender as RadDataForm;
// Copy and set all data to existing record
e.DataItem = d.CurrentItem as GetParts_Result;
// Change some data to another default value
(GetParts_Result)e.DataItem).Name = "New Name";
}
This causes a ArgumentNullException error for 'Parameter name: Key'?
Is there a working example of this event being utilised available...