using Microsoft.Web.UI.WebControls;//添加控件的引用
private void GetTreeView()//程序开始
{
try
{
string strSql = "SELECT DISTINCT Menu_id,Menu_name from docmodulemanager
where Menu_level = 1 and sn in
("+All.Substring(0,All.Length-1).ToString()+")";
OracleDataAdapter
objAdapter = new OracleDataAdapter(strSql,objConn);
DataSet ds = new DataSet();
ds.Clear ();
objAdapter.Fill(ds,"temp");
DataTable dt = ds.Tables["temp"];
TreeView1.Nodes.Clear();
//建立根节点,遍历。
foreach(DataRow dr in dt.Rows)
{
TreeNode Root = new TreeNode();
Root.Text = dr["Menu_name"].ToString();
TreeView1.Nodes.Add(Root);//建立根节点
string str = "SELECT Menu_name,menu_addr,sn from docmodulemanager
where upper_id = '" + dr["Menu_id"].ToString() +
"' and sn in ("+menu_sn.Substring(0,menu_sn.Length-1).ToString()+")"
+"order by menu_id,child_id";
OracleDataAdapter objAdapterNode = new OracleDataAdapter(str,objConn);
DataSet dsNode = new DataSet();
dsNode.Clear ();
objAdapterNode.Fill(dsNode,"tempNode");
DataTable dtNode = dsNode.Tables["tempNode"];
//建立子节点,遍历。
foreach(DataRow drNode in dtNode.Rows)
{
TreeNode Node = new TreeNode();
Node.Text = drNode["Menu_name"].ToString();
Node.Target = "mainbottom";
string Path = drNode["menu_addr"].ToString();
int menusn = Convert.ToInt32(drNode["sn"].ToString());
Node.NavigateUrl = "Transfer.aspx"+"?menu_addr="+ Path;
Root.Nodes.Add(Node);//建立子节点
}
}
}
catch
{
Response.Write(" alert('您没有可操作的菜单项,请与管理员联系!'); ");
}
finally
{
if (objConn.State.ToString().Equals ("Open")) objConn.Close();
}
}