2.cs代码
public class VerticalMenu : System.Web.UI.Page
{
protected DataRow[] father;
protected DataRow[] first;
private void Page_Load(object sender, System.EventArgs e)
{
// 模拟QQ菜单
}
public static string ConnectionString=System.Configuration .ConfigurationSettings .AppSettings["ConnectionString"];
GetDataSet#region GetDataSet
public static DataSet GetDataSet(string sql)
{
SqlDataAdapter sda =new SqlDataAdapter(sql,ConnectionString);
DataSet ds=new DataSet();
sda.Fill(ds);
return ds;
}
#endregion
protected string LoadVerticalMenu()
{
string sqlFather="select * from PowerSetting";
DataSet dsFather=GetDataSet(sqlFather);
father=dsFather.Tables[0].Select("IsBoot=0","IsBoot");
string menu="";
foreach(DataRow drfather in father)
{
menu+="var t;";
menu+="t=outlookbar.addtitle('"+drfather["Description"]+"');";
first=dsFather.Tables[0].Select("ParentID='"+Convert.ToInt32(drfather["ParentID"])+"' and IsBoot=1","IsBoot");
foreach(DataRow drfirst in first)
{
menu+="outlookbar.additem('"+drfirst["Description"]+"',t,'"+drfirst["Url"]+"');";
}
}
return menu;
}
Web Form Designer generated code#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/**//**//**//// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
3.数据库脚本
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[PowerSetting]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[PowerSetting]
GO
CREATE TABLE [dbo].[PowerSetting] (
[PowerSettingID] [int] IDENTITY (1, 1) NOT NULL , --id
[ParentID] [int] NOT NULL , --父节点id
[Description] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL , --菜单描述内容
[Icon] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL , --要显示图标
[Url] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL , --url
[Target] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL , --_self,_blank等
[CreateByID] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL , --创建人id
[CreateON] [datetime] NULL , --创建日期
[IsEnabled] [bit] NULL , --是否可用
[IsBoot] [int] NULL --是不是根节点;1是其他不是
) ON [PRIMARY]
GO










