您始终可以使用该NamingContainer
属性来获取您的DataListItem
. 然后您可以使用FindControl
来获取对您的RadioButtonList
.
例如,假设在DataList
回传的控件中有另一个控件,如DropDownList
. 如果要在事件处理程序中查找RadioButtonList
from :SelectedIndexChanged
protected void DropDownList1_SelectedIndexChanged(Object sender, EventArgs e)
{
DropDownList ddl = (DropDownList) sender;
DataListItem dli = (DataListItem) ddl.NamingContainer;
RadioButtonList rblfilteritem = (RadioButtonList)dli.FindControl("rblfilteritem");
}
如果DropDownList
相反,您可以通过propertyDataList
枚举所有内容:DataListItems
Items
foreach(DataListItem dli in DataList1.Items)
{
RadioButtonList rblfilteritem = (RadioButtonList)dli.FindControl("rblfilteritem");
}