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

Disable "Add New Record" button - only disable, not hide it

1 Answer 189 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Danilo
Top achievements
Rank 1
Danilo asked on 07 Jul 2015, 05:56 AM

Hello

 I'm trying to disable the "Add New Record" button in a Telerik RadGrid. I found many solutions to hide it, but what I want is that it's visible, but if the user clicks on it, it doesn't do anything. I found a way to disable the "InitInsertButton", but not the "AddNewRecordButton". Here you can see my e

 

GridCommandItem cmditem = (GridCommandItem)RadGrid1.MasterTableView.GetItems(GridItemType.CommandItem)[0];
Control ctrl = cmditem.FindControl("AddNewRecordButton");
ctrl.Visible = false;

LinkButton btn = (LinkButton)cmditem.FindControl("InitInsertButton");
btn.Enabled = false;

 

As you can see the "InitInsertButton" is disabled, but there is no property "Enabled" for System.Web.UI.Control so I don't know how to disable it as well.

Hope you can help me

Regards,
Danilo

1 Answer, 1 is accepted

Sort by
0
Danilo
Top achievements
Rank 1
answered on 07 Jul 2015, 11:42 AM

I found the solution for myself.

GridCommandItem cmditem = (GridCommandItem)RadGrid1.MasterTableView.GetItems(GridItemType.CommandItem)[0];
System.Web.UI.WebControls.Button ctrl = System.Web.UI.WebControls.Button)cmditem.FindControl("AddNewRecordButton");
 
ctrl.Enabled = false;

Tags
Grid
Asked by
Danilo
Top achievements
Rank 1
Answers by
Danilo
Top achievements
Rank 1
Share this question
or