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

Disable Add New when Editing

3 Answers 72 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jonathan Hamilton
Top achievements
Rank 1
Jonathan Hamilton asked on 27 Aug 2008, 08:41 PM
I'd like to disable the Add New Command Button when the user clicks on the Edit icon for an existing record in the Grid.  Please also note that I am using RadAjaxLoadingPanel to update/insert/add records.

Please let me know if this is possible.

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 28 Aug 2008, 04:12 AM
Hello Jonathan,

The required scenario can be obtained as shown in the code below.
cs:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
       if (e.Item.IsInEditMode)       
        { 
          foreach (GridCommandItem item in RadGrid1.MasterTableView.GetItems(GridItemType.CommandItem)) 
           { 
            Button btn1 = (Button)item.FindControl("AddNewRecordButton"); 
            btn1.Enabled = false
            // To disable the LinkButton
            LinkButton lnkbtn1 = (LinkButton)item.FindControl("InitInsertButton"); 
            lnkbtn1.Enabled = false;  
           } 
        } 

Princy.
0
Steve Newbery
Top achievements
Rank 1
answered on 28 Aug 2008, 11:27 AM
Princy, thanks for this, it works but only on the Add New link in the top command bar - how would that be adapted to disable the link in the bottom command bar as well?

Thanks, Steve
0
Shinu
Top achievements
Rank 2
answered on 28 Aug 2008, 12:35 PM
Hi Steve,

One another suggestion will be set the Display of the CommandItem to None in edit mode.

CS:
 protected void RadGrid2_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if (e.Item.IsInEditMode) 
        { 
            RadGrid2.MasterTableView.CommandItemDisplay = GridCommandItemDisplay.None; 
        } 
   } 


Thanks
Shinu.
Tags
Grid
Asked by
Jonathan Hamilton
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Steve Newbery
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Share this question
or