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

2 posts, 0 answers
  1. Danilo
    Danilo avatar
    47 posts
    Member since:
    Sep 2012

    Posted 07 Jul 2015 Link to this post

    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

  2. Danilo
    Danilo avatar
    47 posts
    Member since:
    Sep 2012

    Posted 07 Jul 2015 in reply to Danilo Link to this post

    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;

Back to Top