I'm getting "Insert item is available only when grid is in insert mode." when I call GetInsertItem() for the PerformInsert command in the ItemCommand event. Is there something obvious I'm missing? Thanks.
<telerik:RadGrid ID="grid" runat="server" OnNeedDataSource="grid_NeedDataSource" OnItemCommand="grid_ItemCommand" OnInsertCommand="grid_InsertCommand"> <MasterTableView CommandItemDisplay="Top" ClientDataKeyNames="id" DataKeyNames="id" AutoGenerateColumns="false" EditMode="EditForms"> <CommandItemTemplate> <asp:LinkButton ID="add" runat="server" Text="Add new Record" CommandName="InitInsert"></asp:LinkButton> <asp:LinkButton ID="btnPerformInsert" runat="server" Text="Add new Record" CommandName="PerformInsert" Visible="true"></asp:LinkButton> </CommandItemTemplate> <Columns> <telerik:GridEditCommandColumn ButtonType="ImageButton" HeaderStyle-Width="10%" /> <telerik:GridButtonColumn CommandName="Delete" UniqueName="DeleteColumn" ButtonType="ImageButton" HeaderStyle-Width="10%" />... </Columns> <EditFormSettings EditFormType="Template"> <FormTemplate> .... <asp:Button ID="btnUpdate" Text="Update" runat="server" CommandName="Update" Visible='<%# !(Container.DataItem is Telerik.Web.UI.GridInsertionObject) %>' /> <asp:Button ID="btnInsert" Text="Insert" runat="server" CommandName="PerformInsert" Visible='<%# Container.DataItem is Telerik.Web.UI.GridInsertionObject %>' /> <asp:Button ID="btnCancel" Text="Cancel" runat="server" CausesValidation="False" CommandName="Cancel" /> </div> </div> </FormTemplate> </EditFormSettings>protected void grid_ItemCommand(object sender, GridCommandEventArgs e) { switch(e.CommandName) { case RadGrid.PerformInsertCommandName:
GridEditFormInsertItem insertedItem = (GridEditFormInsertItem)e.Item.OwnerTableView.GetInsertItem();