Why does my gridview insert 2 records on insert. Its not just the insert, I was testing the control values by writing to a literalControl, and this showed twice.
I'm using a data class to fill and form template editing.
Any Ideas. here is my grid code: (I actually have a nested grid but I've taken that portion out to save space - could that be the problem?
Andy
<telerik:RadGrid
ID="rgRisk"
runat="server"
GridLines="None"
AutoGenerateColumns="False"
ShowStatusBar="True"
Skin="Expert"
EnableEmbeddedSkins="False"
OnDetailTableDataBind="rgRisk_DetailTableDataBind"
OnNeedDataSource="rgRisk_NeedDataSource"
OnUpdateCommand="rgRisk_UpdateCommand"
OnInsertCommand="rgRisk_InsertCommand"
OnDeleteCommand="rgRisk_DeleteCommand" >
<MasterTableView GridLines="Horizontal" CommandItemDisplay="Top" DataKeyNames="Risk_Area_ID" Width="100%" NoMasterRecordsText="No Risk Areas" NoDetailRecordsText="No Risks Identified" >
<Columns>
<telerik:GridEditCommandColumn CancelImageUrl="../App_Themes/Expert/Grid/Cancel.gif" EditImageUrl="../App_Themes/Expert/Grid/Edit.gif" InsertImageUrl="../App_Themes/Expert/Grid/Update.gif" UpdateImageUrl="../App_Themes/Expert/Grid/Update.gif" ButtonType="ImageButton"><HeaderStyle Width="15px" /><ItemStyle Width="15px" /></telerik:GridEditCommandColumn>
<telerik:GridBoundColumn DataField="Risk_Area" EmptyDataText="&nbsp;" HeaderText="Risk Area" ></telerik:GridBoundColumn>
<telerik:GridExpandColumn><HeaderStyle Width="10px" /><ItemStyle Width="10px" /></telerik:GridExpandColumn>
<telerik:GridButtonColumn ButtonType="ImageButton" CommandName="Delete" Text="Delete" ImageUrl="../App_Themes/Expert/Grid/delete.gif" UniqueName="column"><HeaderStyle Width="10px" /><ItemStyle Width="10px" /></telerik:GridButtonColumn>
</Columns>
<EditFormSettings EditFormType="Template">
<EditColumn UniqueName="EditCommandColumn1"> </EditColumn>
<EditColumn CancelImageUrl="../App_Themes/Expert/Grid/Cancel.gif" EditImageUrl="../App_Themes/Expert/Grid/Edit.gif" InsertImageUrl="../App_Themes/Expert/Grid/Update.gif" UpdateImageUrl="../App_Themes/Expert/Grid/Update.gif" ButtonType="ImageButton" ></EditColumn>
<FormTemplate>
<div>
<label class="gridlabel">Risk Area / Room:</label><telerik:RadTextBox ID="txtRiskArea" runat="server" Width="300px" Text='<%# Eval( "Risk_Area" ) %>' CssClass="gridtext"></telerik:RadTextBox>
</div>
<div>
<asp:Button ID="btnUpdate" cssclass="gridbtn" Text='<%#iif(TryCast(Container, GridItem).OwnerTableView.IsItemInserted, "Insert","Update") %>' runat="server" CommandName='<%# iif(TryCast(Container, GridItem).OwnerTableView.IsItemInserted, "PerformInsert", "Update" )%>'></asp:Button>
<asp:Button ID="btnCancel" runat="server" Text="Cancel" CausesValidation="False" cssclass="gridbtn" CommandName="Cancel"/>
</div>
</FormTemplate>
</EditFormSettings>
<CommandItemSettings AddNewRecordText="Add new area" /><RowIndicatorColumn><HeaderStyle Width="20px" /></RowIndicatorColumn>
</MasterTableView>
<FilterMenu EnableEmbeddedSkins="False" EnableTheming="True" Skin="Expert"><CollapseAnimation Duration="200" Type="OutQuint" /></FilterMenu>
</telerik:RadGrid>