在DataList控件访问子控件的两种方法
方法一:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
DataList1.DataBind();
for(int i=0;i <DataList1.Items.Count;i++)
{
((PlaceHolder)DataList1.Items[i].FindControl( "myPostAdmin" )).Visible = false;
}
}
}
方法二:
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType==ListItemType.AlternatingItem)
{
(PlaceHolder)e.Item.FindControl( "myPostAdmin" )).Visible = false;
}