Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/282.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 从中继器的模板获取控件_C# - Fatal编程技术网

C# 从中继器的模板获取控件

C# 从中继器的模板获取控件,c#,C#,您需要使用ItemDataBound事件并在其中检查页脚 DropDownList ddlChangeUser = siteMapAsBulletedList.Items[0].FindControl("ddlChangeUser") as DropDownList; 谢谢你的回答,但是没有其他可能从FooterTemplate获取DropDownList吗?@senzacionale-没有,据我所知没有。这种方法有什么问题吗?我需要在if(ddlChangeUser!=null){中获取一

您需要使用ItemDataBound事件并在其中检查页脚

 DropDownList ddlChangeUser = siteMapAsBulletedList.Items[0].FindControl("ddlChangeUser") as DropDownList;

谢谢你的回答,但是没有其他可能从FooterTemplate获取DropDownList吗?@senzacionale-没有,据我所知没有。这种方法有什么问题吗?我需要在if(ddlChangeUser!=null){中获取一些ID,但我无法获取它then@senzacionale-获取什么ID?为什么不能获取?@senzacionale抱歉,我看不出问题所在。如果{}block-post您获取的错误,您可以在其中包含任何代码,我将尝试引导您完成。
 DropDownList ddlChangeUser = siteMapAsBulletedList.Items[0].FindControl("ddlChangeUser") as DropDownList;
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) {
                   ...
        }
    }
}