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

IsInEditMode not working

2 Answers 340 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dan
Top achievements
Rank 1
Dan asked on 08 Aug 2008, 02:21 PM
Good day,

I'm using the ASP.NET ajax grid version 2008.1.619.35.  I'm trying to test if a row item within the grid has been set to editmode.  I tried checking the IsInEditMode row property on the row item.  The IsInEditMode property kept returning a false even though I know the row was indeed in edit mode.

protected void RadGrid1_EditCommand(object source, GridCommandEventArgs e)  
{  
 
      //Is it a GridDataItem  
      if (e.Item is GridDataItem)  
       {  
           //Get the instance of the right type  
           GridDataItem dataBoundItem = e.Item as GridDataItem;  
           if (dataBoundItem.OwnerTableView.Name == "OrderHeader")  
           {  
               if (Convert.ToInt16(dataBoundItem["OrderStatusID"].Text) == 1)  
               {  
                   if (e.Item.IsInEditMode)  
                   {  
                        Debug.Write("Edit Mode!);      
                   }  
               }  
            }  
        }  
 } 

Now I did manage to find a work around using the same code as above with the following change

if (e.Item.Edit)  
{  
     
   Debug.Write("Edit Mode!");  
 

I want to confirm if there is a bug with the property IsInEditMode.

2 Answers, 1 is accepted

Sort by
0
Konstantin Petkov
Telerik team
answered on 11 Aug 2008, 07:11 AM
Hi Twalker,

To determine whether the item is in edit mode, you can use the e.Item is GridEditableItem condition. You will find that explained in details in In place editing and Edit forms help articles. The IsInEditMode property can be used along with the previous condition as shown there.

I hope this helps!

Sincerely yours,
Konstantin Petkov
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Accepted
Shinu
Top achievements
Rank 2
answered on 11 Aug 2008, 09:52 AM
Hi Twalker,

You can try the following code snippet to see whether the Grid is in edit mode or not.

CS:
  protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e) 
    { 
      //condition for Edit mode 
        if ((e.Item is GridEditableItem) && (e.Item.IsInEditMode)) 
        { 
            GridEditableItem edititem = (GridEditableItem)e.Item; 
           //........ 
            
        } 
     //condition for Insert Mode 
        if ((e.Item is GridEditFormInsertItem) && (e.Item.OwnerTableView.IsItemInserted)) 
        { 
            GridEditFormInsertItem insertitem = (GridEditFormInsertItem)e.Item; 
            //......... 
        } 
    } 


Thanks
Shinu.
Tags
Grid
Asked by
Dan
Top achievements
Rank 1
Answers by
Konstantin Petkov
Telerik team
Shinu
Top achievements
Rank 2
Share this question
or