三级嵌套

<div class="menu">

         <asp:Repeater id="dlFileType"  runat="server" 

                  onitemdatabound="dlFileType_ItemDataBound1" 

                  >

<ItemTemplate>

 <asp:Label ID="lblzyc1" runat="server" Text='<%#Eval("id") %>' Visible="false"></asp:Label>

  <li class="level1">

 

     <table id="car" class="color" width="100%" border="0" style="border-bottom: 1px solid #e7e7e7; border-collapse:collapse; background-color:#ACC397">

  <tr>

 

    <td width="99%" style="color:#ffffff; font-size:13px"> <span  class="module_up_down" style=" cursor:pointer"   ><img src="down.gif" alt="" /></span> <%#Eval("name")%></td>

    

  </tr>

</table>

         <ul class="level2">

             

<asp:Repeater id="dlFileList" runat="server" onitemcommand="dlFileList_ItemCommand"   onitemdatabound="dlFileList_ItemDataBound" >

<ItemTemplate>

           

           

         <table class="color"  width="100%" style="border-bottom: 1px solid #e7e7e7; border-collapse:collapse">

  <tr>

  

    <td width="85%"><asp:Label ID="lblzyc" runat="server" Text='<%#Eval("id") %>' Visible="false"></asp:Label>   <%#Eval("name")%></td>

    <td width="15%">

         <%#GetSubString1(Eval("id").ToString()) %>

    

     

     </td>

  </tr>

</table>

      <asp:Repeater id="dlFileList1" runat="server" >

<ItemTemplate>

           

           

         <table class="color"  width="100%" style="border-bottom: 1px solid #e7e7e7; border-collapse:collapse; ">

  <tr>

  

    <td width="85%"><asp:Label ID="lblzyc" runat="server" Text='<%#Eval("id") %>' Visible="false"></asp:Label>     <%#Eval("name")%></td>

    <td width="15%">

    <%#GetSubString(Eval("id").ToString()) %>

       

    

     

     </td>

  </tr>

</table>

      

</ItemTemplate>

</asp:Repeater>

</ItemTemplate>

</asp:Repeater>

 </ul>

      </li>

</ItemTemplate>

</asp:Repeater>

</div>

 <style>

    

  .level1

  {

   width:100%;

   float:left;

   display:inline;

  

  

   }

  #car

  {

   width:100%;

   line-height:25px;

  

  

   }

  

  .level2 

  {

   width:100%;

  float:left;

  

   }

   .level2 table

  {

   width:100%;

   line-height:25px;

  

   text-align:left;

   }

    </style>

private void DataBind()

    {

        string sql = "select * from tclass where rootid=0";

        DataTable dt = mingliu.myDataAdapter(sql);

        dlFileType.DataSource = dt;

        dlFileType.DataBind();

        pg.Text = FenYe.GetPageNum(dt, dlFileType, 8);

    }

    private void DataBind(int type)

    {

        string sql = "select * from tclass where rootid=0 and  id="+type+"";

        DataTable dt = mingliu.myDataAdapter(sql);

        dlFileType.DataSource = dt;

        dlFileType.DataBind();

        pg.Text = FenYe.GetPageNum(dt, dlFileType, 8);

    }

    public string GetSubString1(string str)

    {

        string ul = "";

        string sql = "select * from tcontent where type=" + Convert.ToInt32(str) + "";

        DataTable dt = mingliu.myDataAdapter(sql);

        if (dt.Rows.Count > 0)

        {

            int id = Convert.ToInt32(dt.Rows[0]["id"].ToString());

            if (id != 16)

            {

                ul += " <a href=\"ShortEdit.aspx?id=" + id + "\">修改</a> <a href=\"citymanage.aspx?id=" + id + "\">管理图片</a>";

            }

        }

        return ul;

    }

    public string GetSubString(string str)

    {

        string ul = "";

        string sql = "select * from tcontent where type=" + Convert.ToInt32(str) + "";

        DataTable dt = mingliu.myDataAdapter(sql);

        if (dt.Rows.Count > 0)

        {

            

                int id = Convert.ToInt32(dt.Rows[0]["id"].ToString());

                ul += " <a href=\"ShortEdit.aspx?id="+id+"\">修改</a> <a href=\"citymanage.aspx?id="+id+"\">管理图片</a>";

           

        }

        return ul;

    }

    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("lblzyc1");

            int mainID = Convert.ToInt32(lbl.Text);

            //this.Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('" + mainID.ToString() + "!')</script>");

            if (mainID > 0)

            {  string sql="";

                //string sql = "select * from  article";

               // if(typ.Length>0)

                //{

           // sql = "select tcontent.id,tclass.name,tcontent.type from tcontent,tclass where rootid=" + mainID + " and tclass.id=tcontent.type  order by tcontent.id asc";

               // }

               // else{

                //sql = "select tcontent.id,tclass.name,tcontent.type  from tcontent,tclass where rootid=" + mainID + "  order by tcontent.id asc";

               // }

         

            sql = "select  * from tclass where rootid=" + mainID + "  order by id asc";

          

                DataTable dt = mingliu.myDataAdapter(sql);

                dataList.DataSource = dt;

                dataList.DataBind();

            }

        }

    }

    protected void dlFileList_ItemDataBound(object sender, RepeaterItemEventArgs e)

    {

        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)

        {

            Repeater dataList = (Repeater)e.Item.FindControl("dlFileList1");

            Label lbl = (Label)e.Item.FindControl("lblzyc");

            if (lbl.Text.Length > 0)

            {

                int mainID = Convert.ToInt32(lbl.Text);

                //this.Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('" + mainID.ToString() + "!')</script>");

                if (mainID > 0)

                {

                    string sql = "";

                    //string sql = "select * from  article";

                    // if(typ.Length>0)

                    //{

                    //sql = "select tcontent.id,tclass.name,tcontent.type from tcontent,tclass where rootid=" + Convert.ToInt32(typ) + " and tclass.id=tcontent.type  order by tcontent.id asc";

                    // }

                    // else{

                    //sql = "select tcontent.id,tclass.name,tcontent.type from tcontent,tclass where rootid=" + mainID + " and tclass.id=tcontent.type  order by tcontent.id asc";

                    // }

                    sql = "select  * from tclass where rootid=" + mainID + "  order by id asc";

                    DataTable dt = mingliu.myDataAdapter(sql);

                    dataList.DataSource = dt;

                    dataList.DataBind();

                }

            }

        }

    }

    protected void dlFileList_ItemCommand(object source, RepeaterCommandEventArgs e)

    {

        if (e.CommandName == "Delete")

        {

            int id = Convert.ToInt32(e.CommandArgument);

            string sql = "delete from tclass where id=" + id + "";

            mingliu.myCommand(sql);

            this.Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('删除成功!')</script>");

            DataBind();

        }

    }

    

转载于:https://www.cnblogs.com/zhang9418hn/archive/2011/09/27/2193283.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值