zoukankan      html  css  js  c++  java
  • 左列動態添加菜單Repeater

    前台代碼:

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="left.aspx.cs" Inherits="insider_left" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>无标题页</title>
        <STYLE type="text/css">
                    .ttl { CURSOR: hand; COLOR: #ffffff; PADDING-TOP: 4px }
                    A:active{COLOR: #000000;TEXT-DECORATION: none}
                    A:hover{COLOR: #000000;TEXT-DECORATION: none}
                    A:link{COLOR: #000000;TEXT-DECORATION: none}
                    A:visited{COLOR: #000000;TEXT-DECORATION: none}
                    TD {
                 FONT-SIZE: 12px; FONT-FAMILY: "Verdana", "Arial", "细明体", "sans-serif"
                    }
       </STYLE>
       <SCRIPT language="JavaScript">
             function showHide(obj){
              var oStyle = obj.parentElement.parentElement.parentElement.rows[1].style;
              oStyle.display == "none" ? oStyle.display = "block" : oStyle.display = "none";
             }
       </SCRIPT>
    </head>
    <body style=" margin-left :0; margin-top :0;">
        <form id="form1" runat="server">
        <div>
        <asp:Repeater ID="LeftMenu" runat="server" OnItemDataBound="LeftMenu_ItemDataBound">
      <ItemTemplate>
            <TABLE cellSpacing="0" cellPadding="0" width="159" align="center" border="0">
              <TR>
               <TD width="23"><IMG height="25" src="image/Menu/box_topleft.gif" width="23"></TD>
               <TD class="ttl" onclick="javascript:showHide(this);" width="129" background="image/Menu/box_topbg.gif"><%# Eval("M_CName")%></TD>
               <TD width="7"><IMG height="25" src="image/Menu/box_topright.gif" width="7"></TD>
              </TR>
              <TR style="DISPLAY: none">
               <TD background='image/Menu/box_bg.gif' colSpan='3'>
                

                 <TABLE width='100%'>
                     <TBODY>
                     <asp:Repeater ID="LeftMenu_Sub" Runat="server" >
                     <ItemTemplate>
                   <TR>
                   <TD><IMG height='7' hspace='5' src='image/Menu/arrow.gif' width='5' align='absMiddle'>
                    <asp:HyperLink ID ="Hyperlink1" Runat ="server" Target ="mainFrame" NavigateUrl='<%# Eval("M_Directory")%>'>
                     <%# Eval("M_CName")%>
                    </asp:HyperLink>
                   </TD>
                  </TR>
                  </ItemTemplate>
                  </asp:Repeater>
                              </TBODY>
                             </TABLE>

                        </TD>
                   </TR>
                <TR>
                <TD colSpan="3"><IMG height='10' src='image/Menu/box_bottom.gif' width='159'></TD>
                </TR>
             </TABLE> 
            </ItemTemplate>
    </asp:Repeater> 
            </div>
        </form>
    </body>
    </html>
     

    後台代碼:

    using System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;

    public partial class insider_left : System.Web.UI.Page
    {
        publicADO ADO = new publicADO();
        protected void Page_Load(object sender, EventArgs e)
        {
            BindMenu();
        }
        private void BindMenu()
        {
            string vsql = "select * from sys_Module where M_Parent=1 order by [order]";
            DataSet myds = ADO.Cds(vsql);
            LeftMenu.DataSource = myds.Tables[0];
            LeftMenu.DataBind();
            
        }
        protected void LeftMenu_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            DataRowView rows = (DataRowView)e.Item.DataItem;
       //     DataView rows = (DataView)e.Item.DataItem;
            int ModuleID = Convert.ToInt32(rows["ModuleID"]);
            string Vsql = "select * from sys_Module where M_Parent=2 and M_PageCode="+ModuleID+" order by [order]";
            Repeater LeftSub = (Repeater)e.Item.FindControl("LeftMenu_Sub");
            DataTable mytb = ADO.Cds(Vsql).Tables [0];
            if (mytb.Rows.Count != 0)
            {
                LeftSub.DataSource = mytb;
                LeftSub.DataBind();
            }

         /*   sys_ModuleTable s_Mt = (sys_ModuleTable)e.Item.DataItem;

            QueryParam qp = new QueryParam();
            qp.Orderfld = " M_OrderLevel ";
            qp.OrderType = 0;
            qp.Where = string.Format("Where M_Close=0 and M_ParentID ={0}", s_Mt.ModuleID);
            int RecordCount = 0;
            ArrayList lst = BusinessFacade.sys_ModuleList(qp, out RecordCount);
            BusinessFacade.Remove_MenuNoPermission(lst);
            if (lst.Count > 0)
            {
                Repeater LeftSubID = (Repeater)e.Item.FindControl("LeftMenu_Sub");
                LeftSubID.DataSource = lst;
                LeftSubID.DataBind();
            }
            else
            {
                e.Item.Visible = false;
            }
          */

        }
    }

  • 相关阅读:
    OPENGL ES2.0如何不使用glActiveTexture而显示多个图片
    OpenGL帧缓存对象(FBO:Frame Buffer Object)
    EGLImage与纹理
    Android下Opengl ES实现单屏幕双眼显示
    comet4j开发指南
    tmp
    Ubuntu16.04下编译android6.0源码
    ubuntu下配置安装conky
    Qt编程之QImage类小结
    Linux学习,在线版
  • 原文地址:https://www.cnblogs.com/accumulater/p/7000653.html
Copyright © 2011-2022 走看看