• 在后台CS文件里面,隐藏和显示Repeater里面控件


    <asp:Repeater ID="Repeater1" runat="server">
    <ItemTemplate>
    <asp:Panel ID="p1" runat="server">
    <a href='a.aspx?Id=<%# Eval("id") %>'>编辑</a>
    </asp:Panel>
    </ItemTemplate>
    </asp:Repeater>

    protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
    // e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item
    // used to include <ItemTemplate> and <AlternatingItemTemplate>

    if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
    {
    Panel panel1 = (Panel)e.Item.FindControl("p1");
    if (flag == true)
    panel1.Visible = true;
    else
    panel1.Visible = false;
    }
    }
    
    


    other methods:

    
    
    for(int i=0;i<Repeater1.Items.Count;i++)
    {
    Panel pl= Repeater1.Items[i].FindControl("p1") as Panel;
    if(....)
    {
    pl.Visible=false;
    }
    }
    
    

     

    
    
    foreach(RepeaterItem item in Repeater1.Items)
    {
    Panel pl= (Panel)item.FindControl("p1");
    // 你的代码
    }
    
    
  • 相关阅读:
    C#中值类型和引用类型
    C#XML
    矩阵操作2
    scala安装
    Linux拷贝U盘文件(命令行)
    通过电脑,模拟点击手机屏幕 /手机自动点击,刷金币?
    python类
    矩阵操作
    数据预处理函数
    train_test_split数据切分
  • 原文地址:https://www.cnblogs.com/yuloe2012/p/3143871.html
Copyright © 2020-2023  润新知