本文源代码下载:http://files.cnblogs.com/sufei/WebSite2.rar
首先大家要下载安装Telerik.RadControls.for.ASP.NET.AJAX.v2008.Q1.SP2.Retail-SSG(RadControls)
下载地址:http://down.tech.sina.com.cn/content/38955.html
有破解决版的,
下面是关键代码
[C#] 纯文本查看 复制代码 using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using UISBLL;
public partial class Default2 : System.Web.UI.Page
{
DataTable BT, ST;
TreeServices objTreeServices = new TreeServices();
/// <summary>
/// 生成树
/// </summary>
/// <returns>返回一个字符串</returns>
int i = 0;
public void MenuLoad()
{
//查大分类表
BT = objTreeServices.SelectAllBig_Class(Convert.ToInt32(Session["Users_QX"].ToString().Trim()))[0];
//查小分类表
ST = objTreeServices.SelectAllSmall_Class(Convert.ToInt32(Session["Users_QX"].ToString().Trim()))[0];
DataRow[] drs = BT.Select("");
foreach (DataRow r in drs)
{
RadMenu1.Items.Add(new Telerik.Web.UI.RadMenuItem(r["BigClass_Name"].ToString()));
RadMenu1.Items.PostBack = false;
CreateNode(r["BigClass_ID"].ToString());
i++;
}
}
/// <summary>
/// 添加子
/// </summary>
/// <param name="parentid">根的ID</param>
/// <returns></returns>
private void CreateNode(string parentid)
{
//填充树枝的内容
int j = 0;
DataRow[] drsr = ST.Select("BigClass_ID = " + parentid);
foreach (DataRow rw in drsr)
{
[i] RadMenu1.Items.Items.Add(new Telerik.Web.UI.RadMenuItem( rw["SmallClass_Name"].ToString()));
RadMenu1.Items.Items [j].NavigateUrl = rw["Path"].ToString().Trim();
j++;
}
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
//传入权限的ID在这里直接写了一个
Session["Users_QX"] = "5";
MenuLoad();
}
}
}
数据库设计
|