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

[Solved] Edit Item in RadGrid stays in EditMode

2 Answers 173 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Peter
Top achievements
Rank 1
Peter asked on 22 Jun 2009, 08:27 AM

Hey!

I have a RadGrid that performs a CallBack on Update and Insert. The Code is executed correctly and the Item is updated/inserted in my Collection but on the Client the RadGridItem stays in EditMode. I tried setting item.Edit = "false" at the end of my Insert/Update Method but this did not work and threw an exception.

I'm confused because I thought the default behaviour was for the Item to close after editing. Am I missing something in my RadGrid configuration?

<telerik:RadGrid ID="gridVariables" runat="server" GridLines="None" AllowPaging="True" 
                            AllowSorting="true" CssClass="evaluation_grid" AllowMultiRowEdit="false" 
                            meta:resourcekey="gridVariables" 
                            onneeddatasource="gridVariables_NeedDataSource"   
                            Skin="<%# RadSkin %>" 
                            onupdatecommand="gridVariables_UpdateCommand" 
                            OnItemDataBound="gridVariables_ItemDataBound" 
                            ondeletecommand="gridVariables_DeleteCommand" 
                            oninsertcommand="gridVariables_InsertCommand" 
                            oncancelcommand="gridVariables_CancelCommand" 
                            AllowAutomaticUpdates="true" AllowAutomaticInserts="true" AllowAutomaticDeletes="true" 
                            PageSize="10" > 
                        <PagerStyle Mode="NextPrevAndNumeric" /> 
                        <ValidationSettings EnableValidation="false" /> 
                        <MasterTableView AutoGenerateColumns="false" EditMode="InPlace" TableLayout="Fixed" DataKeyNames="Id" ClientDataKeyNames="Id, Shortname" CommandItemDisplay="Top">  
                            <Columns> 
                                <telerik:GridBoundColumn UniqueName="Id"  DataField="Id" Visible="false">  
                                </telerik:GridBoundColumn> 
                                <telerik:GridBoundColumn UniqueName="ShortnameColumn"  DataField="Shortname"   
                                        meta:resourcekey="gbcShortname">  
                                        <HeaderStyle Width="70px"/>  
                                </telerik:GridBoundColumn> 
                                <telerik:GridTemplateColumn UniqueName="NameColumn"    
                                        meta:resourcekey="gbcName">  
                                    <ItemTemplate> 
                                        <p> 
                                            <%# Eval("Name")%> 
                                        </p> 
                                    </ItemTemplate> 
                                    <EditItemTemplate> 
                                        <asp:TextBox ID="txtName" Width="90%" Enabled="false" runat="server" Text='<%# Bind("Name") %>' /> 
                                    </EditItemTemplate> 
                                </telerik:GridTemplateColumn> 
                                <telerik:GridBoundColumn UniqueName="DescriptionColumn"  DataField="Description"   
                                        meta:resourcekey="gbcDescription">  
                                </telerik:GridBoundColumn> 
                                <telerik:GridBoundColumn UniqueName="UnitColumn" DataField="Unit"   
                                        meta:resourcekey="gbcUnit">  
                                        <HeaderStyle Width="70px"/>  
                                </telerik:GridBoundColumn> 
                                <telerik:GridTemplateColumn UniqueName="ChangeAttributeColumn">  
                                    <HeaderStyle Width="30px"/>  
                                    <ItemTemplate> 
                                        <asp:ImageButton ID="btnChangeAttribute" runat="server" BorderWidth="1" CommandArgument='<%# Eval("Shortname") %>' ImageUrl="~/Img/change.gif" meta:resourcekey="btnChangeAttribute" OnPreRender="btnChangeAttribute_PreRender" /> 
                                    </ItemTemplate> 
                                    <EditItemTemplate> 
                                          
                                    </EditItemTemplate> 
                                </telerik:GridTemplateColumn> 
                                <telerik:GridEditCommandColumn CancelImageUrl="~/Img/Cancel_red.gif"   
                                EditImageUrl="~/Img/Edit.gif" 
                                UniqueName="EditColumn"   
                                UpdateImageUrl="~/Img/Update.gif"   
                                ButtonType="ImageButton" 
                                meta:resourcekey="vrEditColumn">  
                                <HeaderStyle Width="50px" /> 
                                </telerik:GridEditCommandColumn> 
                                <telerik:GridButtonColumn UniqueName="DeleteColumn" CommandName="Delete" ButtonType="ImageButton">  
                                    <HeaderStyle Width="30px"/>  
                                </telerik:GridButtonColumn> 
                            </Columns> 
                            <CommandItemTemplate> 
                                <div style="padding:10px 0px;">  
                                    <asp:ImageButton Text="Neu" meta:resourcekey="newValueColumn" 
                                        ID="btnNew" runat="server" CommandName="InitInsert" ImageAlign="Left" ImageUrl="~/Img/New.gif" 
                                        CausesValidation="false" OnPreRender="btnNew_PreRender" 
                                        Visible='<%# !gridVariables.MasterTableView.IsItemInserted %>' /> 
                                    <asp:LinkButton ID="btnNewVariable" CommandName="InitInsert" OnPreRender="btnNewVariable_PreRender" Visible='<%# !gridVariables.MasterTableView.IsItemInserted %>' CausesValidation="false" runat="server" Height="18px" meta:resourcekey="newValueColumn" /> 
                                </div> 
                            </CommandItemTemplate> 
                        </MasterTableView> 
                        <ClientSettings>    
                            <ClientEvents OnRowDblClick="rowDoubleClick" />    
                            <Selecting AllowRowSelect="True"></Selecting> 
                        </ClientSettings> 
                    </telerik:RadGrid> 

2 Answers, 1 is accepted

Sort by
0
Accepted
Daniel
Telerik team
answered on 22 Jun 2009, 08:46 AM
Hello Peter,

I recommend you disable the automatic operations as it seems that you are updating your database manually.
... AllowAutomaticUpdates="false" AllowAutomaticInserts="false" AllowAutomaticDeletes="false" ... 

Hope this helps.

Best regards,
Daniel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Peter
Top achievements
Rank 1
answered on 22 Jun 2009, 08:54 AM
Yes! That was it. Thank you very much.

I can't believe I didn't catch that, it was a left-over from my initial setting.
Tags
Grid
Asked by
Peter
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Peter
Top achievements
Rank 1
Share this question
or