Edit Row and New Row

2 posts, 1 answers
  1. Eng.Bassel Samman
    Eng.Bassel Samman avatar
    25 posts
    Member since:
    Oct 2008

    Posted 28 Oct 2010 Link to this post

    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.

     

     

     

  2. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 28 Oct 2010 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top