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

RadGrid - UserControl - turn off edit mode

2 Answers 540 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ben
Top achievements
Rank 1
Ben asked on 24 Mar 2011, 09:36 AM
I am using a radGrid with UserControl to handle editing and inserts.

I am binding the grid at runtime, similar to the example on http://demos.telerik.com/aspnet-ajax/grid/examples/dataediting/usercontroleditform/defaultvb.aspx

After executing the insert command, I would like the grid to return to default mode (i.e. leave insert mode), but have been unable to do this.  I am using the UpdateCommand - code as below.  The item is successfully added to the database, but I get a jscript error

"Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerServerErrorException: Insert item is available only when grid is in insert mode."

Basically, I am looking for the ASP.Net gridview equivalent of edititemindex = -1.  Are you able to assist.

Thanks
Ben


Private Sub RadGrid1_UpdateCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid1.UpdateCommand

    Dim editedItem As GridEditableItem = CType(e.Item, GridEditableItem)

 

 

 

    Dim userControl As UserControl = CType(e.Item.FindControl(GridEditFormItem.EditFormUserControlID), UserControl)

 

        strID =

CType(userControl.FindControl("txtID"), TextBox).Text    

 

        DataComponent.SaveAsset(strID)

        RadGrid1.MasterTableView.IsItemInserted = False

 

 

 

 

        Me.RadGrid1.Rebind()

 

 

 

    

 

 

 

End Sub

 


2 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 24 Mar 2011, 10:49 AM
Hello Ben,

I guess the edit form is not closing after update operation because you have set AllowAutomaticUpdates property of RadGrid to true. If so set it as false and see if its solves the issue.

Also the following code will help you to close all the editforms opened in the grid.

CS:

        RadGrid1.EditIndexes.Clear();

        RadGrid1.Rebind();



Thanks,
Princy.
0
Ben
Top achievements
Rank 1
answered on 24 Mar 2011, 03:04 PM
Princy,

Thanks for your prompt response, that has worked perfectly.

Thanks,
Ben
Tags
Grid
Asked by
Ben
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Ben
Top achievements
Rank 1
Share this question
or