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

Edit Row and New Row

1 Answer 69 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Eng.Bassel Samman
Top achievements
Rank 2
Eng.Bassel Samman asked on 28 Oct 2010, 10:15 AM
Dears,
I have a Radgrid with EditMode="EditForms"
I want to prevent user from adding new record and editing another one simultaneously, I managed to check if grid has an Edit Items by using

grd.EditItems.Count. But I did not manage to check if grid has new Insert row when user try to click on GridEditCommandColumn to edit another row.

 

 

 

1 Answer, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 28 Oct 2010, 10:25 AM
Hello Bassel,

The following code snippet shows how to cancel one operation when performing other.

C#:
protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)
    {
       if (e.CommandName == RadGrid.EditCommandName)
        {
            if (RadGrid1.MasterTableView.IsItemInserted)
            {
                e.Canceled = true;
            }
        }
       if (e.CommandName == RadGrid.InitInsertCommandName)
       {
           if (RadGrid1.EditItems.Count > 0)
           {
               e.Canceled = true;
           }
       }
     }

Or you can try the following code to hide the insert form when clicking Edit Button and vice versa.

C#:
protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) 
    
        if (e.CommandName == RadGrid.EditCommandName) 
        
            RadGrid1.MasterTableView.IsItemInserted = false
        
        if (e.CommandName == RadGrid.InitInsertCommandName) 
        
            RadGrid1.MasterTableView.ClearEditItems(); 
        
    }

Thanks,
Princy.
Tags
Grid
Asked by
Eng.Bassel Samman
Top achievements
Rank 2
Answers by
Princy
Top achievements
Rank 2
Share this question
or