左侧动态管理菜单的实现(Repeater中嵌套使用Repeater)

 

       <style type="text/css">

body{margin:10px;padding:10px;}

body,h2,div,span,li{font-size:12px;}

.title01,.title02 {color:#fff;font-weight:bold;}

#DoorP{border:12px solid #2d9cc8;width:171px;padding:4px;background:#fff;}

h2{text-align:center;margin:0px;padding:0px;line-height:22px;}

.title01{width:100%;height:25px;background:#00ccff;cursor:pointer;}

.title02{width:100%;height:25px;background:#99cc00;cursor:pointer;}

.content{background:#eee;border-bottom:2px solid #fff;overflow:hidden;color:#666;padding-left:4px;padding-right:4px;line-height:18px;}

.content a:link,.content a:visited{color:#666666;text-decoration:none;}

.content a:hover{color:#FF6600;text-decoration:underline;}

</style>

    <title></title>

</head>

<body>

<form id="form1" runat="server">

    <div class="div_Main">

    <div class="div_MLeft">

        <div class="div_MLeft_top">

        <table cellpadding="0" cellspacing="0" width="100%">

        <tr>

            <td style="font-size:16px">主¡Â功|能¨¹选?项?</td>

            <td >

                <img src="../Inc/images/BtnImages/ZGNXX.png" width="25px" height="25px" alt="" />

            </td>

        </tr>

        </table>            

        </div>

        <%-- <div class="div_MLeft_line"></div>

            <div class="div_MLeft_space"></div>

        --%>   

        <div id="DoorP" >

            <asp:Repeater ID="RepeaterParent" runat="server" onitemdatabound="RepeaterParent_ItemDataBound">

            <ItemTemplate>

                <h2>

                    <td ><img src="../<%#Eval("Prgs_Image")%>" width="23px" height="23px" alt="" ></td>

                    <td ><%#Eval("Prgs_Name")%></td>

                    </a>

                </h2>

                <div class="content" >

                        <asp:Repeater ID="RepeaterChild" runat="server">

                        <ItemTemplate>

                            <table align="center" οnmοuseοver="this.style.backgroundImage='url(../inc/images/M_L_ChangeB.gif)'"

                            οnmοuseοut="this.style.backgroundImage=''"  οnclick="window.location.href='<%#Eval("Prgs_Tag")%><%#Eval("Prgs_Id")%>.aspx'">

                                <tr>

                                    <td ><img src="../<%#Eval("Prgs_Image")%>" width="23px" height="23px" alt="" ></td>

                                    <td ><%#Eval("Prgs_Name")%></td>

                                    </a>

                                </tr>

                            </table><%----%>

                        </ItemTemplate>

                        </asp:Repeater>

                    </div>  

            </ItemTemplate>

            </asp:Repeater>

        </div>

    </div>

    </div>

    <script type="text/javascript">

        var onum = 0; // 设¦¨¨置?初?始º?打䨰开a的Ì?层?序¨°号?

        var closeState = new Array();

        var ch = new Array();

        function $(id) {

            if (document.getElementById(id))

            {return document.getElementById(id); }

            else

            { alert("没?有®D找¨°到Ì?!") }

        }

        function $tag(id, tagName) { return $(id).getElementsByTagName(tagName) }

        var Ds = $tag("DoorP", "div");

        var Ts = $tag("DoorP", "h2");

        if (Ds.length != Ts.length) { alert("初?始º?化¡¥失º¡ì败㨹!"); }

        function showMe(Cid, Oid) {

            var h = parseInt(Ds[Cid].style.height); var h2 = parseInt(Ds[Oid].style.height); var dH = ch[Oid]; if (h > 0) {

                h = h - Math.ceil(h / 3); Ds

 

[Cid].style.height = h + "px";

            }; if (h2 < dH) { h2 = h2 + Math.ceil((dH - h2) / 3); Ds[Oid].style.height = h2 + "px"; }; if (h <= 0 && h2 >= dH) {

                clearTimeout(closeState[Cid]); return

 

                false;

            }; closeState[Cid] = setTimeout("showMe(" + Cid + "," + Oid + ")");

        }

        for (var i = 0; i < Ds.length; i++) {

            ch[i] = Ds[i].offsetHeight;

            if (i == onum) { Ds[i].style.height = ch[i] + "px"; Ts[i].className = "title01"; } else { Ds[i].style.height = "0px"; Ts[i].className = "title02"; }

            Ts[i].value = i;

            Ts[i].onclick = function () {

                if (onum == this.value) { return false; };

                Ts[onum].className = "title02";

                Ts[this.value].className = "title01";

                for (var i = 0; i < closeState.length; i++) { clearTimeout(closeState[i]); }

                showMe(onum, this.value);

                onum = this.value;

            }

        }

</script>

</form>

</body>

</html>

 

 

 

.cs文件

 

       protected void Page_Load(object sender, EventArgs e)

        {

            BindPrgs();

        }

 

        public void BindPrgs()

        {

            DataSet ds = bll.GetPrgsList(" prgs_value=0 ");

            if (ds.Tables[0].Rows.Count > 0)

            {

                RepeaterParent.DataSource = ds;

                RepeaterParent.DataBind();

            }

            else

            {

                JScript.Alert("你?没?有®D权¨¡§限T,请?联¢a系¦Ì管¨¹理¤¨ª员¡À!ê?");

            }

        }

 

        protected void RepeaterParent_ItemDataBound(object sender, RepeaterItemEventArgs e)

        {

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

            {

                Repeater rep = e.Item.FindControl("RepeaterChild") as Repeater;//找¨°到Ì?里¤?层?的Ì?repeater对?象¨®

                DataRowView rowv = (DataRowView)e.Item.DataItem;//找¨°到Ì?分¤?类¤¨¤Repeater关?联¢a的Ì?数ºy据Y项?

                string Prgs_Name = rowv["Prgs_Name"].ToString(); //获?取¨?填¬?充?子Á¨®类¤¨¤的Ì?id

                DataSet ds = bll.GetPrgsList(" prgs_value=0 ");

                int Pid = 0;

                foreach (DataRow dr in ds.Tables[0].Rows)

                {

                    if (dr["Prgs_Name"].ToString().Equals(Prgs_Name))

                    {

                        Pid = Convert.ToInt32(dr["Prgs_Id"]);

                        break;

                    }

                }

                rep.DataSource = bll.GetPrgsList("Pid="+Pid);

                rep.DataBind();

            }

 

        }

 

运行效果:

                   

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值