<FooterTemplate>
<tr>
<td class="menu">
<a href="/Contact.aspx">Pomoč in podpora</a>
</td>
</tr>
<tr>
<td>
<asp:DropDownList ID="ddlChangeUser" runat="server" CssClass="childrenSelectType" AutoPostBack="True" Visible="false" OnSelectedIndexChanged="ddlChangeUser_SelectedIndexChanged">
</asp:DropDownList>
</td>
</tr>
如何从转发器的FooterTemplate获取ddlChangeUser控件。
这不行,因为它不在ItmeTemplate中。
DropDownList ddlChangeUser = siteMapAsBulletedList.Items[0].FindControl("ddlChangeUser") as DropDownList;
答案 0 :(得分:3)
您需要使用ItemDataBound事件并在其中检查Footer。
siteMapAsBulletedList.ItemDataBound += new RepeaterItemEventHandler(siteMapAsBulletedList_ItemDataBound);
...
void siteMapAsBulletedList_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Footer)
{
DropDownList ddlChangeUser = (DropDownList)e.Item.FindControl("ddlChangeUser");
if (ddlChangeUser != null) {
...
}
}
}