zoukankan      html  css  js  c++  java
  • asp.net二级嵌套repeater

    <asp:Repeater id="dlFileType"  runat="server" onitemdatabound="dlFileType_ItemDataBound1">
    <ItemTemplate>
     <asp:Label ID="lblzyc" runat="server" Text='<%#Eval("id") %>' Visible="false"></asp:Label>
      <li class="level1"><a  href="#"><%#Eval("name") %></a>
        
             <ul class="level2">
                
    <asp:Repeater id="dlFileList" runat="server" >
    <ItemTemplate>

                <li><a href='product.aspx?id=<%#Eval("id") %>'><%#Eval("name") %> </a></li>
              
            
          
    </ItemTemplate>
    </asp:Repeater>
     </ul>
          </li>
    </ItemTemplate>
    </asp:Repeater>

     protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                DataBind();
            }
        }
        private void DataBind()
        {
            string sql = "select * from tclass where rootid=0";
            DataTable dt = lisichuang.myDataAdapter(sql);
            dlFileType.DataSource = dt;
            dlFileType.DataBind();
        }

        protected void dlFileType_ItemDataBound1(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                Repeater dataList = (Repeater)e.Item.FindControl("dlFileList");
                Label lbl = (Label)e.Item.FindControl("lblzyc");

                int mainID = Convert.ToInt32(lbl.Text);
                //this.Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('" + mainID.ToString() + "!')</script>");
                if (mainID > 0)
                {
                    //string sql = "select * from  article";
                    string sql = "select  * from tclass where rootid=" + mainID + "  order by id asc";
                    DataTable dt = lisichuang.myDataAdapter(sql);
                    dataList.DataSource = dt;
                    dataList.DataBind();
                }
            }
        }

  • 相关阅读:
    hive on hbase
    django多表操作
    django单表操作
    django模板
    django路由初识
    python 相关模块安装 国内镜像地址
    django初识
    Python中属性和描述符的简单使用
    pip安装包(python安装gevent(win))
    jQuery 事件方法
  • 原文地址:https://www.cnblogs.com/zhang9418hn/p/2038080.html
Copyright © 2011-2022 走看看