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; using System.Text; using Dal; public partial class UC_LeftUc : System.Web.UI.UserControl { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Page is PageEx) { string topMenuId = Convert.ToString((Page as PageEx).TopMenuId); if (topMenuId != "0") //不是顶级菜单 { StringBuilder sbLeftMenus = new StringBuilder(); string strFirsh = "
{0}
"; string strSecond = "
{1}
"; string strThree = "
  • {1}
  • "; DataSet dsAllMenus = MenusDal.Select(); //(Page as PageEx).RoleId if (SqlHelper.HasRow(dsAllMenus)) { //一级菜单 DataRow[] dsFirsts = dsAllMenus.Tables[0].Select("menuid=" + topMenuId); if (dsFirsts != null && dsFirsts.Length == 1) { //一级 Model.Menus menusFirst = new Model.Menus(dsFirsts[0]); sbLeftMenus.Append(string.Format(strFirsh, menusFirst.Text)); #region 二级 int iSecond = 0; DataRow[] drSeconds = dsAllMenus.Tables[0].Select("upmenuid=" + topMenuId); foreach (DataRow drSecond in drSeconds) { Model.Menus menusSecond = new Model.Menus(drSecond); sbLeftMenus.Append(string.Format(strSecond,iSecond++, menusSecond.Text)); #region 三级 sbLeftMenus.Append(""); #endregion } #endregion } } ltLeftMenu.Text = sbLeftMenus.ToString(); } } } } }