zoukankan      html  css  js  c++  java
  • 获取repeater控件模版列中的控件

    直接用repeater.Findcontrol是获取不到子控件的,因为子空间实际是在ItemTemplate中的,翻译一个评论:
    if(Roles.IsUserInRole("admin"))
    {
    Button delete = (Button)rptNotering.Items[0].FindControl("btnDelete");
    delete.Visible = true;
    Button edit = (Button)rptNotering.Items[0].FindControl("btnEdit");
    edit.Visible = true;
    }

    Inside a repeater are 0-many Items. .Items[x] is where x is the index of the specific itemtemplate instance.
    If your repeater returns 10 rows of data, then your repeater returns an instance of ItemTemplate 10 times
    and places each instance in the Items[] collection.

    Your findcontrol method is not looking inside the ItemTemplate.
    Hope this helps :-)


    大体意思是
    :在repeater中有0项,Items[x] 才是制定模版列的实例,如果你的repeater有10行数据,那么你的repeater返回10次ItemTemplate 的实例,每个实例都是在item的集合众的。

    所以我在事件中作了,效果还是可以,只不过这样的循环感觉不是很好,还有注意你要在repeater数据邦定后再来做如上操作,否则没效果的。。。。

  • 相关阅读:
    4A安全体系
    Linux 安装 Nginx
    Linux 安装 Mysql
    Web容器对比
    Nginx 学习记录
    SO_REUSEADDR选项的平台差异(对于TCP)
    centos下搭建yum服务器
    IOCP 下行为投递的关键点
    网络包解包错误 与 标准io(linux)
    关闭ssh的dns反向解析
  • 原文地址:https://www.cnblogs.com/Longkin/p/1200238.html
Copyright © 2011-2022 走看看