zoukankan      html  css  js  c++  java
  • 在DataList控件访问子控件的方法

    如果一个DataList空间中有一个PlaceHolder子控件,用下面的方法访问:

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

    还有一个在ItemDataBound里面操作:

    if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType==ListItemType.AlternatingItem)
            {
                (PlaceHolder)e.Item.FindControl( "myPostAdmin" )).Visible  =  false; 
            }

  • 相关阅读:
    bzoj3224
    [洛谷日报第62期]Splay简易教程 (转载)
    bzoj1588
    codeforces467C
    codeforces616B
    codeforces379C
    codeforces545C
    codeforces285C
    codeforces659C
    快读代码level.2
  • 原文地址:https://www.cnblogs.com/zhangchenliang/p/835773.html
Copyright © 2011-2022 走看看