如何在转发器控件中获取asp控件(_lblCouncils)的客户端ID?
<ItemTemplate>
<div id="NotificationDiv">
<asp:Label ID="_lblRoleType" Text='<%#Eval("RoleType")%>' runat="server"></asp:Label>
<asp:Label ID="_lblCouncils" Text='<%#Eval("CouncilData")%>' runat="server" onclick="Name(this)"></asp:Label>
</div>
</ItemTemplate>
答案 0 :(得分:2)
您必须处理OnRowDataBound(如果容器控件是GridView)或ItemDataBound事件(如果容器控件是Repeater),则找到控件:
<强> C#:强>
Labeb lbl = (Label)e.Item.FindControl("_lblRoleType");
<强> VB:强>
Dim lbl as Label = CType(e.Item.FindControl("_lblRoleType"),Label)