更新时间:2023-10-02 09:54:10
的FindControl
将工作是即创建这些控件后,才将数据绑定到 FormView控件
。所以,你需要使用的 FormView控件
相应的事件这样的 ItemCreated 或数据绑定
。例如,
FindControl
will work only after those controls are created i.e when data is bound to the FormView
. So you need to use appropriate event on FormView
such ItemCreated or DataBound
. For example,
protected void fvMediaIntro_ItemCreated(Object sender, EventArgs e)
{
var control = fvMediaIntro.Row.FindControl("iNeedToFindThis") as HtmlAnchor;
}
假设,你在的Page_Load
绑定或使用标记,你也可以使用 prerender
父页/控制事件安全办的FindControl
。
Assuming, you are binding in page_load
or using mark-up, you can also use prerender
event of parent page/control safely to do FindControl
.