<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;

最佳答案

您需要使用ItemDataBound事件,然后在其中检查页脚。

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) {
                   ...
        }
    }
}

10-08 08:48