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

Disable add new record button

1 Answer 297 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Janaki
Top achievements
Rank 1
Janaki asked on 28 Sep 2012, 03:21 AM
Hi all,

In my grid, I don't want the user to add records while editing. Is there a way to disable the add new record button in edit mode?
Thanks in advance.


1 Answer, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 28 Sep 2012, 03:31 AM
Hi,

Please try the following code snippet to disable add new record while in edit mode.

C#:
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
    if ((e.Item is GridEditableItem) && (e.Item.IsInEditMode))
    {
        foreach (GridCommandItem cmdItm in RadGrid1.MasterTableView.GetItems(GridItemType.CommandItem))
        {
            LinkButton Addbtn = (LinkButton)cmdItm.FindControl("InitInsertButton");
            Addbtn.Enabled = false;
            Button btn = (Button)cmdItm.FindControl("AddNewRecordButton");
            btn.Enabled = false;
                
        }
    
}

Thanks,
Shinu.
Tags
Grid
Asked by
Janaki
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or