DEVMBM DEVMBM - 1 year ago 137
ASP.NET (C#) Question

How to find control in CommandItemTemplate for RadGrid

I'm using RadGrid from Telerik with three LinkButton controls in CommandItem , and i want to hide or show them using switch statement at code behind.

<LinkButton runat="server" ID="approveAllLink" Text="Approve All" >
<LinkButton runat="server" ID="approveLink" Text="Approve" >
<LinkButton runat="server" ID="rejectLink" Text="Reject" >

Is there anyway solve this case?

Answer Source

What about this?

GridItem cmdItem = RadGrid1.MasterTableView.GetItems(GridItemType.CommandItem)[0]; 
LinkButton approveAllLink = cmdItem.FindControl("approveAllLink") as LinkButton; 
LinkButton approveLink = cmdItem.FindControl("approveLink") as LinkButton; 
LinkButton rejectLink= cmdItem.FindControl("rejectLink") as LinkButton; 

// Your switch logic here
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download