我有一个名为“UserControl_Attachments”的用户控件。
<%@ Register TagPrefix="UserControl_Attachments" TagName="Attachments" Src="/UserControls/UserControl_Attachments.ascx" %>
<UserControl_Attachments:Attachments ID="Attachments_Bulletin" runat="server" />
在用户控件中,我有一个 Telerik:RadListView,在“ItemTemplate”中我有一个带有 ID="UC_DeleteAttachment_Button" 的 Telerik:RadButton。根据后面代码中的用户登录,我想隐藏按钮。
<telerik:RadListView runat="server" ID="UC_CurrentAttachments" AllowPaging="true" PageSize="40" OnNeedDataSource="UC_CurrentAttachments_NeedDataSource">
<LayoutTemplate>
<div style="max-width: 800px">
<asp:Panel ID="itemPlaceholder" runat="server">
<table>
</table>
</asp:Panel>
</div>
</LayoutTemplate>
<ItemTemplate>
<tr>
<td>
<a href="<%# Eval("AttachmentPath") %>" target="_blank">
<img src="<%# Eval("ImagePath") %>" width="<%# Eval("DisplayWidth") %>" height="<%# Eval("DisplayHeight") %>" />
</a>
</td>
<td>
<asp:Label runat="server" ID="Label_AttachmentName" Text='<%# Eval("DisplayName") %>' Font-Size="10px" />
</td>
<td>
<telerik:RadButton ID="UC_DeleteAttachment_Button" Width="25" runat="server" OnClick="UC_DeleteAttachment_Click" OnClientClicking="UC_Attachment_DeleteConfirm">
<Icon PrimaryIconCssClass="rbRemove"></Icon>
</telerik:RadButton>
</td>
</tr>
<asp:HiddenField ID="HiddenField_AttachmentPath" runat="server" Value='<%# Eval("AttachmentPath") %>' />
</ItemTemplate>
</telerik:RadListView>
这是我背后的代码:
var CurrentAttachment_UC = (RadListView)Attachments_Bulletin.FindControl("UC_CurrentAttachments");
var CurrentAttachmentDeleteButton = (RadButton)CurrentAttachment_UC.FindControl("UC_DeleteAttachment_Button");
if (CurrentAttachmentDeleteButton != null)
CurrentAttachmentDeleteButton.Visible = false;
我已经尝试了几件事,但仍然找不到控件。它始终为空。无论如何我可以隐藏按钮吗?提前致谢。