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

Only items with IsInEditMode set to true can be updated

9 Answers 638 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Curt
Top achievements
Rank 1
Curt asked on 28 Mar 2008, 05:55 PM
I know that I must be missing something simple but I can't figure it out.  I have just changed all of my grids from the RadControls to the Prometheus controls.  In doing so (something I did or didn't do) broke.  When ever I try to use the CommandItemTemplate Update Button I get an error:

Only items with IsInEditMode set to true can be updated

Here is my commandItemTemplate:
<CommandItemTemplate> 
                        <asp:LinkButton ID="btnUpdateEdited" runat="server" CommandName="UpdateEdited" Visible='<%# RadGrid1.EditIndexes.Count > 0 %>'
                            <img style="border:0px" alt="" src="~/Skins/DWDS/Grid/Update.gif" runat="server" /> Update Activity 
                        </asp:LinkButton> 

As far as I know it is the same as the Prometheus examples.  If I use the update button from the EditFormsSettings it works fine.

Here is the Grid:

<telerik:RadGrid ID="RadGrid1" Skin="DWDS" EnableEmbeddedSkins="false" ImagesPath="~/Skins/DWDS/Grid/" runat="server" Width="100%" PageSize="14"  
                AllowAutomaticDeletes="true" AllowAutomaticInserts="True" AllowAutomaticUpdates="True" 
                AllowPaging="True" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" ShowStatusBar="true" AllowSorting="true" ShowFooter="true" AllowFilteringByColumn="true" > 
                <PagerStyle Mode="NextPrevNumericAndAdvanced" /> 
                <ExportSettings FileName="DeepWellData File Export" /> 
                <MasterTableView CommandItemDisplay="Top" CurrentResetPageIndexAction="SetPageIndexToFirst" ShowHeadersWhenNoRecords="true" DataKeyNames="Activity_ID" DataSourceID="SqlDataSource1" Width="100%" AutoGenerateColumns="false" EditMode="EditForms"
                    <CommandItemTemplate> 
                        <asp:LinkButton ID="btnUpdateEdited" runat="server" CommandName="UpdateEdited" Visible='<%# RadGrid1.EditIndexes.Count > 0 %>'
                            <img style="border:0px" alt="" src="~/Skins/DWDS/Grid/Update.gif" runat="server" /> Update Activity 
                        </asp:LinkButton> 
                        &nbsp; 
                        <asp:LinkButton ID="btnCancel" runat="server" CommandName="CancelAll" Visible='<%# RadGrid1.EditIndexes.Count > 0 || RadGrid1.MasterTableView.IsItemInserted %>'
                            <img style="border:0px" alt="" src="~/Skins/DWDS/Grid/Cancel.gif" runat="server" /> Cancel editing 
                        </asp:LinkButton> 
                        &nbsp; 
                        <asp:LinkButton ID="LinkButton2" runat="server" CommandName="InitInsert" Visible='<%# !RadGrid1.MasterTableView.IsItemInserted %>'
                            <img style="border:0px" alt="" src="~/Skins/DWDS/Grid/AddRecord.gif" runat="server" /> Add new Activity</asp:LinkButton> 
                        <asp:LinkButton ID="LinkButton3" runat="server" CommandName="PerformInsert" Visible='<%# RadGrid1.MasterTableView.IsItemInserted %>'
                         <img style="border:0px" alt="" src="~/Skins/DWDS/Grid/Insert.gif" runat="server" /> Add this Activity</asp:LinkButton> 
                        &nbsp;&nbsp;&nbsp; 
                        <asp:LinkButton ID="LinkButton4" runat="server" CommandName="RebindGrid"
                            <img style="border:0px" alt="" src="~/Skins/DWDS/Grid/Refresh.gif"  runat="server" /> Refresh Activity list 
                        </asp:LinkButton> 
                        &nbsp;&nbsp;&nbsp; 
                        <asp:Label ID="lblCategoryEdit" Visible="false" OnDataBinding="DisableCategoryEdit" runat="server"
                            <telerik:RadWindowManager ID="RadWindowManager2" runat="server" Height="500px" Width="480px" Modal="true"
                                <Windows> 
                                    <telerik:RadWindow OpenerElementID="aRegion" Width="480px" Height="450px" NavigateUrl="~/Projects/CaseFiles/AddRecord/Category.aspx" ID="RadWindow1" runat="server" /> 
                                </Windows> 
                            </telerik:RadWindowManager> 
                            <id="aRegion" style="cursor: pointer;"
                                <img src="~/Skins/DWDS/Grid/Edit.gif" runat="server" border="0" alt="Edit Categories" />Add/Edit Categories</a> </asp:Label> 
                        <br /> 
                        &nbsp; 
                    </CommandItemTemplate> 
                    <Columns> 
                        <telerik:GridEditCommandColumn ButtonType="ImageButton" EditImageUrl="~\Skins\DWDS\Grid\Edit.gif"  
                            UniqueName="EditColumn"
                            <HeaderStyle Width="25px" /> 
                            <ItemStyle HorizontalAlign="Center" Width="25px" /> 
                        </telerik:GridEditCommandColumn> 
                        <telerik:GridButtonColumn ConfirmText="Delete this activity?" ButtonType="ImageButton" ImageUrl="~\Skins\DWDS\Grid\Delete.gif" CommandName="Delete" Text="Delete" UniqueName="DeleteColumn"
                            <HeaderStyle Width="25px" /> 
                            <ItemStyle HorizontalAlign="Center" Width="25px" /> 
                        </telerik:GridButtonColumn> 
                        <telerik:GridBoundColumn DataField="Activity_ID" HeaderText="ID" ReadOnly="True" SortExpression="Name" UniqueName="Activity_ID" Visible="False" /> 
                        <telerik:GridBoundColumn DataField="Name" HeaderText="Activity Name" ColumnEditorID="GridTextBoxColumnEditor1" SortExpression="Name" UniqueName="name" /> 
                        <telerik:GridBoundColumn DataField="PName" HeaderText="Partner" ReadOnly="True" Display="true" SortExpression="PName" UniqueName="PName" /> 
                        <telerik:GridBoundColumn DataField="Category_Name" HeaderText="Category" ReadOnly="True" Display="true" SortExpression="Category_Name" UniqueName="Category_Name" /> 
                        <telerik:GridDropDownColumn DataField="Partner_ID" ColumnEditorID="GridDropDownListColumnEditor1" DataSourceID="SqlDataSource2" HeaderText="Partner" ListTextField="Name" ListValueField="Partner_ID" 
                            UniqueName="pid" Display="false" /> 
                        <telerik:GridDropDownColumn DataField="Category_ID" ColumnEditorID="GridDropDownListColumnEditor2" DataSourceID="SqlDataSource3" HeaderText="Category" ListTextField="Name" ListValueField="Category_ID" 
                            UniqueName="cid" Display="false" /> 
                        <telerik:GridDropDownColumn DataField="Goal_Number" ColumnEditorID="GridDropDownListColumnEditor3" DataSourceID="SqlDataSource7" Visible="false" HeaderText="Goal #" ListTextField="Goal" 
                            ListValueField="Goal" UniqueName="Goal_number" /> 
                        <telerik:GridNumericColumn DataField="Completion_Hours" Visible="false" HeaderText="Completion Hours (in Minutes)" ColumnEditorID="GridNumericColumnEditor1" SortExpression="Completion_Hours" 
                            UniqueName="Completion_Hours" /> 
                        <telerik:GridTemplateColumn HeaderText="Details" AllowFiltering="false" DataField="Activity_ID" UniqueName="viewActivity"
                            <ItemTemplate> 
                                <div style="text-align: center"
                                    <asp:ImageButton ID="showItem" OnClick="showActivityDetails_Click" runat="server" ImageUrl="~/Images/Icons/magnifier.gif" CommandName="viewingActivity" CommandArgument='<%# Eval("Activity_ID") %>' /> 
                                </div> 
                            </ItemTemplate> 
                            <FooterTemplate> 
                                <div style="font-size: 11px; color: #5e7ca7; padding-top: 2px"
                                    Export to:<br /> 
                                    <asp:ImageButton ID="btnExcel" runat="server" ImageUrl="~/Images/Icons/excel.gif" AlternateText="Export to excel" OnClick="btnExcel_Click" />&nbsp;&nbsp; 
                                    <asp:ImageButton ID="btnWord" runat="server" ImageUrl="~/Images/Icons/word.gif" AlternateText="Export to word" OnClick="btnWord_Click" /> 
                                </div> 
                            </FooterTemplate> 
                        </telerik:GridTemplateColumn> 
                        <telerik:GridHTMLEditorColumn Visible="false" DataField="Notes" ColumnEditorID="GridHTMLEditorColumnEditor1" HeaderText="Notes" SortExpression="Notes" UniqueName="Notes" /> 
                        <telerik:GridBoundColumn Visible="false" DataField="Partner_ID" UniqueName="Partner_ID" ReadOnly="true" /> 
                        <telerik:GridBoundColumn DataField="PName" Visible="false" UniqueName="PName2" ReadOnly="true" /> 
                    </Columns> 
                    <EditFormSettings CaptionDataField="Name" CaptionFormatString="Edit properties of Activity: {0}" ColumnNumber="1"
                        <FormTableItemStyle Wrap="False" Width="400px"></FormTableItemStyle> 
                        <FormCaptionStyle CssClass="EditFormHeader"></FormCaptionStyle> 
                        <FormMainTableStyle GridLines="Horizontal" CellSpacing="10" CellPadding="10" BackColor="White" /> 
                        <FormTableStyle CellSpacing="10" CellPadding="10" CssClass="module" Height="150px" BackColor="White" /> 
                        <FormTableAlternatingItemStyle Wrap="False"></FormTableAlternatingItemStyle> 
                        <FormStyle Width="10%"></FormStyle> 
                        <EditColumn ButtonType="ImageButton" UpdateImageUrl="~\Skins\DWDS\Grid\Update.gif" EditImageUrl="~\Skins\DWDS\Grid\Edit.gif" InsertImageUrl="~\Skins\DWDS\Grid\Insert.gif" CancelImageUrl="~\Skins\DWDS\Grid\Cancel.gif" 
                            InsertText="Insert Activity" UpdateText="Update record" UniqueName="EditCommandColumn1" CancelText="Cancel edit"
                        </EditColumn> 
                        <FormTableButtonRowStyle HorizontalAlign="Right" CssClass="EditFormButtonRow"></FormTableButtonRowStyle> 
                    </EditFormSettings> 
                    <ExpandCollapseColumn Visible="False"
                        <HeaderStyle Width="19px" /> 
                    </ExpandCollapseColumn> 
                    <RowIndicatorColumn Visible="False"
                        <HeaderStyle Width="20px" /> 
                    </RowIndicatorColumn> 
                </MasterTableView> 
            </telerik:RadGrid> 

Can someone point out what I am doing wrong?

Thanks

9 Answers, 1 is accepted

Sort by
0
Konstantin Petkov
Telerik team
answered on 31 Mar 2008, 12:44 PM
Hi,

I'm afraid you may have hit an issue we've recently addressed. Please, download the latest Prometheus "Futures" build we have uploaded a week ago and let us know if that resolves the error on your side as well.

All the best,
Konstantin Petkov
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Curt
Top achievements
Rank 1
answered on 31 Mar 2008, 02:48 PM
I have downloaded and installed the most recent build.  I am running 2007.3.1425.20.  The pages are still behaving the same way.  Is this the most recent futures build?

0
Curt
Top achievements
Rank 1
answered on 31 Mar 2008, 07:46 PM
My mistake.  I found the Futures build and it seems to have taken care of the problem.

Thanks

-Brent
0
Pushkar
Top achievements
Rank 2
answered on 27 Jan 2009, 11:07 PM
I am using latest Rad Control. After coming in edit mode in grid. How can I come with privious mode. I am using grid.MasterTableView.ClearEditItems() on Update commond handling. I get error "Only items with IsInEditMode set to true can be updated"

Protected

Sub RadGrid1_ItemCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid1.ItemCommand

 


If e.CommandName="Update" then
    

    grid.MasterTableView.ClearEditItems()

     

Me.RadGrid1.DataSource = CType(ViewState("PrioritySetList"), IEnumerable)

 

    RadGrid1.Rebind()

End IF

Suggest me.

0
Iana Tsolova
Telerik team
answered on 28 Jan 2009, 08:58 AM
Hello pushkar,

Try modifying your code as shown below and see if it works this way:

Protected Sub RadGrid1_ItemCommand(ByVal source As ObjectByVal e As GridCommandEventArgs) Handles RadGrid1.ItemCommand      
   If e.CommandName="Update" then     
     e.Canceled = True      
     grid.MasterTableView.ClearEditItems()     
     Me.RadGrid1.DataSource = CType(ViewState("PrioritySetList"), IEnumerable)      
     RadGrid1.Rebind()     
   End IF    

Let me know if any issues arise.

Greetings,
Iana
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Pushkar
Top achievements
Rank 2
answered on 28 Jan 2009, 03:37 PM

Thanks for the Quick response & solution. Now it’s working.

0
Ahmed Adly
Top achievements
Rank 2
answered on 15 Mar 2009, 08:49 PM
Thanks Alot
Great Job
0
Nik
Top achievements
Rank 1
answered on 24 Sep 2010, 11:37 PM
grdLidEffectiveDateRanges.MasterTableView.ClearEditItems();
e.Canceled = true;


Above code is working fine with Grid RadGrid1_UpdateCommand but not with grdLidEffectiveDateRanges_InsertCommand

Can you help me out what is the method call to clear the row or content after adding a new record in the radgrid.

Thanks,
Nikunj Patel

0
Iana Tsolova
Telerik team
answered on 27 Sep 2010, 01:06 PM
Hello Nikunj,

Have you tried setting:

grdLidEffectiveDateRanges.MasterTableView.IsItemInserted = false;

All the best,
Iana
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
Curt
Top achievements
Rank 1
Answers by
Konstantin Petkov
Telerik team
Curt
Top achievements
Rank 1
Pushkar
Top achievements
Rank 2
Iana Tsolova
Telerik team
Ahmed Adly
Top achievements
Rank 2
Nik
Top achievements
Rank 1
Share this question
or