So I have Rad Grid that contains data and I have in above the `Add New Button`. I want when user has permission to add to make it enable if he doses not have then its disable I search for hours for a solution and all I come is this code:

```
Dim cmditem As GridCommandItem = CType(gvDefCountry.MasterTableView.GetItems(GridItemType.CommandItem)(0), GridCommandItem)
Dim ctrl As System.Web.UI.WebControls.Button = CType(cmditem.FindControl("AddNewRecordButton"), System.Web.UI.WebControls.Button)
ctrl.Enabled = False

```

But every time I run the code, I'm getting this error:

> 
> "Index was outside the bounds of the array"
> 
> 
> 

The view looks like:

![enter image description here](https://i.stack.imgur.com/BXuNz.png)