日期:2014-05-17 浏览次数:20575 次
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
namespace WebApplication1
{
public partial class WebForm3 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
CategoryNodeBind();
}
}
private void CategoryNodeBind()
{
//string sqlCommand = "SELECT * FROM DBO.Category WHERE ID=PARENTID";
DataTable parentData = createdb();//GetCategories(sqlCommand);
for (int i = 0; i < parentData.Rows.Count; i++)
{
TreeNode parentNode = new TreeNode();
parentNode.Text = parentData.Rows[i]["Name"].ToString();
parentNode.Value = parentData.Rows[i]["Id"].ToString();
//parentNode.NavigateUrl = parentData.Rows[i]["CatalogEditUrl"].ToString();
this.TreeView1.Nodes.Add(parentNode);
SubCategoryNodeBind(parentNode);
}
}
private void SubCategoryNodeBind(TreeNode parentNode)
{
//string sqlCommand = "SELECT * FROM DBO.CATEGORY WHERE PARENTID='" + parentNode.Value + "'";
DataTable childData = createsubdb();//GetCategories(sqlCommand);
&