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

    <asp:Repeater ID="rpt1" runat="server" onitemdatabound="rpt1_ItemDataBound">
          
               <ItemTemplate>
               <asp:Label ID="lblzyc" runat="server" Text='<%#Eval("id") %>' Visible="false"></asp:Label>
               <h1 onClick="javascript:ShowMenu(this,'NO0')"><%#Eval("name") %></h1>
                 <span id="NO0" class="no">
                            <asp:Repeater ID="rpt2" runat="server"  onitemdatabound="rpt2_ItemDataBound">
                              
                                     <ItemTemplate>
                                     
                                         <asp:Label ID="lblzyc1" runat="server" Text='<%#Eval("id") %>' Visible="false"></asp:Label>
        
           <h2 onClick="javascript:ShowMenu(this,'NO00')"></h2>
      <div  style="  margin-top:-15px; margin-left:20px"> <a href='product.aspx?id=<%#Eval("id") %>'><%#Eval("name") %></a></div>
     
    </table>
            
             <ul id="NO00" class="no">
                                                  <asp:Repeater ID="rpt3" runat="server">
                                                   
                                                     <ItemTemplate>
                                                     
                                                      
              <li><a href='product.aspx?pid=<%#Eval("id") %>'><%#Eval("name") %></a></li> 
            
          
                                                        </ItemTemplate>
                                                   
                                                  </asp:Repeater>
                                                 </ul>
                                         
                                     </ItemTemplate>
                              
                            </asp:Repeater>
                         </span>
               </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);
            rpt1.DataSource = dt;
            rpt1.DataBind();
        }
        protected void rpt1_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                Repeater dataList = (Repeater)e.Item.FindControl("rpt2");
                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();
                }
            }
        }
        protected void rpt2_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                Repeater dataList = (Repeater)e.Item.FindControl("rpt3");
                Label lbl = (Label)e.Item.FindControl("lblzyc1");

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

  • 相关阅读:
    Openstack API 开发 快速入门
    virtualBox虚拟机到vmware虚拟机转换
    使用Blogilo 发布博客到cnblogs
    Openstack Troubleshooting
    hdoj 1051 Wooden Sticks(上升子序列个数问题)
    sdut 2430 pillars (dp)
    hdoj 1058 Humble Numbers(dp)
    uva 10815 Andy's First Dictionary(快排、字符串)
    sdut 2317 Homogeneous squares
    hdoj 1025 Constructing Roads In JGShining's Kingdom(最长上升子序列+二分)
  • 原文地址:https://www.cnblogs.com/zhang9418hn/p/2038082.html
Copyright © 2011-2022 走看看