views:

185

answers:

2

Hi All:

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.

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

Is there anyway solve this case?

+1  A: 

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
Claudio Redi
A: 

Make sure you have the CommandItemDisplay property of the MasterTableView set to a value different than None. Otherwise the command item array which is returned from the GetItems method will be empty.

Dick Lampard