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

ClearEditItems() doesn't work after adding new record!

3 Answers 115 Views
Grid
This is a migrated thread and some comments may be shown as answers.
canfield
Top achievements
Rank 1
canfield asked on 13 Jan 2010, 09:02 AM
Hi,

When I try to add new record using telerik add new record command, the edit form cannot be closed.
If anyone have ever encountered this issue, please do share. Thanks.

Please find below the aspx and codebehind:

 

                    <telerik:RadGrid ID="RadGrid1" ShowStatusBar="true" Height="420px" EnableAJAX="true" 
                        runat="server" AutoGenerateColumns="False" AllowSorting="true" AllowMultiRowSelection="False" 
                        AllowPaging="true" GridLines="None" ShowFooter="true"   
                        AllowFilteringByColumn="false" EnableDrag="false" 
                        EnableHeaderContextMenu="false" TableLayout="auto"   
                        AllowAutomaticDeletes="True" AllowAutomaticInserts="True" 
                        AllowAutomaticUpdates="True" PageSize="10"   
                        OnNeedDataSource="RadGrid1_NeedDataSource"   
                        OnItemDataBound="RadGrid1_ItemDataBound" 
                        OnUpdateCommand="RadGrid1_UpdateCommand"   
                        OnInsertCommand="RadGrid1_InsertCommand"   
                        OnDeleteCommand="RadGrid1_DeleteCommand"   
                        onitemcommand="RadGrid1_ItemCommand" 
                        > 
 
        protected void RadGrid1_InsertCommand(object source, GridCommandEventArgs e)  
        {  
            // Perform insert  
 
            RadGrid1.MasterTableView.ClearEditItems();  
        } 

 

 


Regards,
canfield

3 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 13 Jan 2010, 09:37 AM
Hello Canfield,

When you are performing Insert or any other data operation manually, you should set the AllowAutomaticInserts, AllowAutomaticUpdates,etc., properties of the RadGrid to false, so that the edit form closes automatically. So try setting the AllowAutomaticInserts to False. If that does not help, try the following code:
c#:
protected void RadGrid1_InsertCommand(object source, GridCommandEventArgs e)   
  {   
     // Perform insert   
  
     RadGrid1.MasterTableView.IsItemInserted = false
     RadGrid1.Rebind();   
  } 

Thanks
Princy.
0
canfield
Top achievements
Rank 1
answered on 13 Jan 2010, 10:36 AM

After setting the AllowAutomaticInserts to False, the edit form close automatically after insert and update command.

Many Thanks Princy.

0
MVP
Top achievements
Rank 1
answered on 02 Dec 2013, 05:52 AM
Thank you so much Princy...Was searching for the solution from long time...setting AllowAutomaticInserts = False worked for me
Tags
Grid
Asked by
canfield
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
canfield
Top achievements
Rank 1
MVP
Top achievements
Rank 1
Share this question
or