<%@ Page Language="C#" AutoEventWireup="true" CodeFile="webturnpage.aspx.cs" Inherits="webturnpage" %>
<%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>
<!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>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
<asp:GridView ID="GridView1" runat="server">
</asp:GridView>
<webdiyer:AspNetPager ID="AspNetPager1" runat="server">
</webdiyer:AspNetPager>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:ImageButton ID="ImageButton1" runat="server" OnClick="ImageButton1_Click" />
<asp:TreeView ID="TreeView1" runat="server">
<HoverNodeStyle BackColor="#FFFFC0" BorderColor="Lime" />
</asp:TreeView>
</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 webturnpage : System.Web.UI.Page
{
DataSet ds=new DataSet();
protected void Page_Load(object sender, EventArgs e)
{
Bind_TreeView();
}
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
}
private void Tree_Infor(int ParentID, TreeNodeCollection pNode)//treeview树型目录
{
DataRow[] rows = ds.Tables[0].Select("Class_Pid= ' " + ParentID + " ' ");
foreach (DataRow row in rows)
{
TreeNode Node = new TreeNode();
Node.Text = row["Class_Name"].ToString();
Node.Value = row["Class_ID"].ToString();
pNode.Add(Node);
Node.Expand();
Tree_Infor(Convert.ToInt32(row[0]), Node.ChildNodes);
}
}
void Bind_TreeView()
{
string sql="select Class_ID,Class_Name,Class_Pid from TC_Class order by Class_ID ";
string strconn = "Data Source=SEE-CLN-059\\PMSERVER;Initial Catalog=test;uid=sa;pwd=;";
Conn conn = new Conn(strconn);
ds = conn.GetSet(sql);
TreeNodeCollection Node = new TreeNodeCollection();
TreeNode TN = new TreeNode();
TN.Text = "根目录 ";
TN.Value = "0 ";
Node = this.TreeView1.Nodes;
Node.Add(TN);
Tree_Infor(0, TN.ChildNodes);
}
}