asp.net TreeView 的使用
protected void CreateNode()
{
DataTable d = new DataTable();
using (SqlConnection sql = new SqlConnection(ConnectionString))
{
SqlCommand sq = new SqlCommand("select [name] as 表名,[type] from [sysobjects]", sql);
SqlDataAdapter sda = new SqlDataAdapter();
sda.SelectCommand = sq;
sda.Fill(d);
}
DataRow[] dr = d.Select("[type] = 'u'", "表名");
if (dr.Length > 0)
{
foreach (DataRow drr in dr)
{
TreeNode tn = new TreeNode();
tn.Value = drr["表名"].ToString();
tn.Text = drr["表名"].ToString();
tn.Expanded = false;
tn.SelectAction = TreeNodeSelectAction.Expand;
TreeView1.Nodes.Add(tn);
CreateChild(tn, dts);
}
}
else
{
TreeNode t = new TreeNode();
t.Value = "空";
t.Text = "空";
t.Expanded = false;
t.SelectAction = TreeNodeSelectAction.Expand;
TreeView1.Nodes.Add(t);
}
}
protected void CreateChild(TreeNode tnn, DataTable dtt)
{
DataRow[] dr = dtt.Select("表名='" + tnn.Value + "'", "表名");
if (dr.Length > 0)
{
foreach (DataRow drw in dr)
{
TreeNode ts = new TreeNode();
ts.Value = drw["列名"].ToString();
ts.Text = drw["列名"].ToString() + "(" + drw["型別"].ToString() + "," + drw["長度"].ToString() + ")";
ts.SelectAction = TreeNodeSelectAction.Expand;
//ts.Expanded = false;
tnn.ChildNodes.Add(ts);
CreateChild(ts, dtt);
}
}
}
protected DataTable CreateTable()
{
DataTable d = new DataTable();
using (SqlConnection sql = new SqlConnection(ConnectionString))
{
SqlCommand sq = new SqlCommand("select a.[name] as 表名 ,b.name as 列名,type_name(b.system_type_id)as 型別,b.max_length as 長度 from [sysobjects] a ,sys.columns b where a.[type] = 'u' and object_id=object_id(a.[name])", sql);
SqlDataAdapter sda = new SqlDataAdapter();
sda.SelectCommand = sq;
sda.Fill(d);
}
return d;
}
相關文章
- asp.net TreeView動態新增ASP.NETView
- 資料庫驅動的asp.net treeview資料庫ASP.NETView
- Asp.net利用Treeview實現樹形列表ASP.NETView
- TreeView的基本使用 1205View
- delphi中Treeview的使用介紹View
- 控制元件treeview的使用 (轉)控制元件View
- ACCESS TreeView控制元件的使用View控制元件
- Delphi中的TreeViewView
- VS2005入門之treeview的使用View
- 【jackyrong 】asp.net 2.0中TREEVIEW中動態增加結點ASP.NETView
- KendoUI系列:TreeViewUIView
- WPF TreeView BringIntoViewBehaviorView
- YUI TreeView搞明白了UIView
- TreeView樹狀結構View
- 禁止TreeView自動PostbackView
- jQuery 樹形控制元件 TreeView 的 BugjQuery控制元件View
- WPF TreeView SelectedItemChanged called twiceView
- 【小山】ASP.NET2.0 TreeViewASP.NETView
- C# List構造TreeViewC#View
- TreeView學習筆記 (轉)View筆記
- WPF TreeView級聯複選View
- WPF TreeView IsExpanded 繫結不上的問題View
- tkinter treeview 背景色 問題.View
- Object TreeView簡要說明 (轉)ObjectView
- PB下使用TreeView控制元件實現多級分類檢索View控制元件
- C#中遍歷TreeView的兩個常用方法C#View
- ASP.NET 使用AjaxASP.NET
- Asp.net 使用FluentSchedulerASP.NET
- PB TreeView 屬性,事件詳解(轉)View事件
- TreeView遞迴繫結地區列表View遞迴
- TreeView.cs source code in C# .NETViewC#
- 聊聊asp.net中Web Api的使用ASP.NETWebAPI
- asp.net 角色身份驗證的使用ASP.NET
- asp.net輸出快取的使用ASP.NET快取
- ASP.NET 2.0中XSLT的使用ASP.NET
- 基於jquery-treeview的動態選單實現jQueryView
- TreeView 的派生類: TreeViewEx 實現 NodeShowToolTip、NodeDoubleClick 事件 (轉)View事件
- ASP.NET Core ----ASP.NET Core中使用Code FirstASP.NET