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

Reference CommandItemTemplate button in code behind?

1 Answer 211 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dan
Top achievements
Rank 2
Dan asked on 23 Dec 2011, 05:38 PM
I have a Grid defined in the aspx file with a couple of CommandItemTemplate buttons as shown below.
Is there a way to reference one of the buttons in the OnGridPrerender in order to suppress its display?

Thanks.
Dan
<CommandItemTemplate>
         <asp:Button ID="btnAddCall" CommandName="AddCall" runat="server" Text="Add Call" />
         <asp:Button ID="btnBack" CommandName="Back" runat="server" Text="Back" />
</CommandItemTemplate>

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 26 Dec 2011, 05:21 AM
Hello Dan,

Try the following code.
C#:
protected void RadGrid1_PreRender(object sender, EventArgs e)
{
 GridCommandItem cmd = (GridCommandItem)RadGrid1.MasterTableView.GetItems(GridItemType.CommandItem)[0];
 cmd.Visible = false;
}

-Shinu.
Tags
Grid
Asked by
Dan
Top achievements
Rank 2
Answers by
Shinu
Top achievements
Rank 2
Share this question
or