I have a bit of a problem. I have a RadGrid with EditTemplate Columns.
I try to add a new Container and all goes well. I have implemented the GridInsertionObject like you described in order to avoid the missing property error.
When i Cancel the Insert operation i get the same error 'Telerik.WebControls.GridInsertionObject does not contain a property with the name mapviewer_Container1’ Error
I have attached a screendump of the error.
I have includded RadGridContainers_ItemCommand event at the bottom but as you can see from the code in it i have tried different scenarios with no luck.
<telerik:RadGrid ID="RadGridContainers" runat="server" Skin="Office2007" AllowSorting="True"
GridLines="None" AllowMultiRowSelection="True" OnNeedDataSource="RadGridContainers_NeedDataSource"
Width="800px" Visible="False" ShowStatusBar="True" OnItemCommand="RadGridContainers_ItemCommand"
OnCancelCommand="RadGridContainers_CancelCommand"
AutoGenerateColumns="False"
onitemdatabound="RadGridContainers_ItemDataBound">
<MasterTableView AllowMultiColumnSorting="True" CommandItemDisplay="Top"
DataKeyNames="ContainerID" EditMode="InPlace">
<CommandItemSettings AddNewRecordText="Tilfj ny container" RefreshText="Opdatr" />
<Columns>
<telerik:GridEditCommandColumn CancelText="Annullr" InsertText="Indst" UpdateText="Opdatr"
EditText="Redigr">
</telerik:GridEditCommandColumn>
<telerik:GridBoundColumn DataField="ContainerID" DataType="System.Int32" HeaderText="ContainerID"
ReadOnly="True" SortExpression="ContainerID" UniqueName="ContainerID" Visible="False">
</telerik:GridBoundColumn>
<telerik:GridTemplateColumn DataField="ContainerIDParent" DataType="System.Int32"
HeaderText="Forldre" SortExpression="ContainerIDParent" UniqueName="ContainerIDParent"
Visible="True">
<EditItemTemplate>
<table cellpadding="0" cellspacing="0">
<tr>
<td>
<img id="rcbContainerIDParentEditImage" src='<%= ImageController.Instance.ImagePathTreeViewRaw %><%# Eval("mapviewer_Container1.mapviewer_Icon.Icon")%>'
alt="" width="16px" height="16px" />
</td>
<td align="left">
<telerik:RadComboBox ID="rcbContainerIDParent" runat="server" Skin="Office2007" MarkFirstMatch="True"
HighlightTemplatedItems="True" DropDownWidth="500px" Height="200px" DataSourceID="LinqDataSource7"
DataTextField="Name" Width="204px" DataValueField="ContainerID"
OnClientSelectedIndexChanged="rcbContainerIDParentSelectedIndexChanged" SelectedValue='<%# Bind("mapviewer_Container1.ContainerID") %>'>
<CollapseAnimation Duration="200" Type="OutQuint" />
<HeaderTemplate>
<table cellpadding="0" cellspacing="0" style="width: 290px;">
<tr>
<td style="width: 30px;">
Id
</td>
<td style="width: 60px">
Billede
</td>
<td style="width: 200px;">
Navn
</td>
</tr>
</table>
</HeaderTemplate>
<ItemTemplate>
<table cellpadding="0" cellspacing="0" style="width: 290px;">
<tr>
<td style="width: 30px;">
<%# Eval("ContainerID")%>
</td>
<td style="width: 60px;">
<img src='<%= ImageController.Instance.ImagePathTreeViewRaw %><%# Eval("mapviewer_Icon.Icon")%>'
alt="" width="16px" height="16px" />
</td>
<td style="width: 200px;">
<%# Eval("Name")%>
</td>
</tr>
</table>
</ItemTemplate>
</telerik:RadComboBox>
</td>
</tr>
</table>
</EditItemTemplate>
<ItemTemplate>
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td style="border: 0;">
<asp:Image ID="rcbIkonEditImageContainer" ImageUrl='<%# ImageController.Instance.ImagePathTreeViewForGridView((string)Eval("mapviewer_container1.mapviewer_Icon.Icon"))%>'
runat="server" Width="16px" Height="16px" />
</td>
<td style="border: 0;">
<asp:Label ID="ContainerIDLabel" runat="server" Text='<%# Eval("mapviewer_container1.Name") %>'></asp:Label>
</td>
</tr>
</table>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridBoundColumn DataField="Name" HeaderText="Navn" SortExpression="Name"
UniqueName="Name">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Level" DataType="System.Int32" HeaderText="Level"
SortExpression="Level" UniqueName="Level" Visible="False">
</telerik:GridBoundColumn>
<telerik:GridTemplateColumn DataField="IconID" DataType="System.Int32" HeaderText="Ikon"
SortExpression="IconID" UniqueName="IconID" Visible="True">
<EditItemTemplate>
<table cellpadding="0" cellspacing="0">
<tr>
<td>
<img id="rcbIkonEditImage" src='<%= ImageController.Instance.ImagePathTreeViewRaw %><%# Eval("mapviewer_Icon.Icon")%>'
alt="" width="16px" height="16px" />
</td>
<td align="left">
<telerik:RadComboBox ID="rcbIkon" runat="server" Skin="Office2007" MarkFirstMatch="True"
HighlightTemplatedItems="True" DropDownWidth="500px" Height="200px" DataSourceID="LinqDataSource1"
DataTextField="Icon" Width="204px" DataValueField="IconID"
OnClientSelectedIndexChanged="rcbIkonSelectedIndexChanged" SelectedValue='<%# Bind("mapviewer_Icon.IconID") %>'>
<CollapseAnimation Duration="200" Type="OutQuint" />
<HeaderTemplate>
<table cellpadding="0" cellspacing="0" style="width: 190px;">
<tr>
<td style="width: 30px;">
Id
</td>
<td style="width: 60px;">
Billede
</td>
<td style="width: 100px">
Filnavn
</td>
</tr>
</table>
</HeaderTemplate>
<ItemTemplate>
<table cellpadding="0" cellspacing="0" style="width: 190px;">
<tr>
<td style="width: 30px;">
<%# Eval("IconID")%>
</td>
<td style="width: 60px;">
<img src='<%= ImageController.Instance.ImagePathTreeViewRaw %><%# Eval("Icon")%>'
alt="" width="16px" height="16px" />
</td>
<td style="width: 100px;">
<%# Eval("Icon")%>
</td>
</tr>
</table>
</ItemTemplate>
</telerik:RadComboBox>
</td>
</tr>
</table>
</EditItemTemplate>
<ItemTemplate>
<img src='<%= ImageController.Instance.ImagePathTreeViewRaw %><%# Eval("mapviewer_Icon.Icon")%>'
alt="" width="16px" height="16px" />
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridCheckBoxColumn DataField="Enabled" DataType="System.Boolean" HeaderText="Aktiv"
SortExpression="Enabled" UniqueName="Enabled">
</telerik:GridCheckBoxColumn>
<telerik:GridButtonColumn UniqueName="DeleteColumn" Text="Fjern" CommandName="Delete" />
</Columns>
<EditFormSettings>
<EditColumn UniqueName="EditCommandColumn1">
</EditColumn>
</EditFormSettings>
</MasterTableView>
<ClientSettings>
<Selecting AllowRowSelect="True" />
</ClientSettings>
</telerik:RadGrid>
protected
void RadGridContainers_ItemCommand(object source, GridCommandEventArgs e)
{
if (e.CommandName == RadGrid.InitInsertCommandName)
{
e.Canceled =
true;
System.Collections.Specialized.ListDictionary newValues = new System.Collections.Specialized.ListDictionary();
layerDataClassesDataContext =
new LayerDataClassesDataContext();
newValues[
"mapviewer_Container1.mapviewer_Icon.Icon"] = layerDataClassesDataContext.mapviewer_Icons.First(i => i.IconID.Equals(6));
newValues[
"mapviewer_Container1"] = layerDataClassesDataContext.mapviewer_Containers.First(c => c.ContainerIDParent.Equals(null));
newValues[
"mapviewer_Icon.Icon"] = layerDataClassesDataContext.mapviewer_Icons.First(i => i.IconID.Equals(6)).Icon;
newValues[
"mapviewer_Icon"] = layerDataClassesDataContext.mapviewer_Icons.First(i => i.IconID.Equals(6));
e.Item.OwnerTableView.InsertItem(newValues);
//layerDataClassesDataContext = new LayerDataClassesDataContext();
//mapviewer_Container container = new mapviewer_Container();
//container.mapviewer_Container1 = layerDataClassesDataContext.mapviewer_Containers.First(c => c.ContainerIDParent.Equals(null));
//container.mapviewer_Icon = layerDataClassesDataContext.mapviewer_Icons.First(i => i.IconID.Equals(6));
//e.Item.OwnerTableView.InsertItem(container);
}
}