treeview控件的使用 你用一个TAG字段来表示数据的层次关系就可以了啊 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 参见此文http://blog.csdn.net/knight94/archive/2006/05/01/704281.aspxHttp://blog.csdn.net/knight94/archive/2006/03/24/637699.aspx protected void Page_Load(object sender, EventArgs e) { TreeView tv = new TreeView(); TreeNode tn = new TreeNode(); tn.Text = "选择局所"; tn.NavigateUrl = "1.htm"; tn.Target = "right"; TreeNodeInit(0, tn); tv.Nodes.Add(tn); TreeView1.Nodes.Add(tn); } #region 递归生成书结点 private void TreeNodeInit(int upID, System.Web.UI.WebControls.TreeNode tNode) { SqlConnection SqlConn = new SqlConnection(); SqlConn.ConnectionString = "Data Source=ip地址;Initial Catalog=***;Persist Security Info=True;User ID=***;password=***;Max Pool Size=512"; SqlConn.Open(); SqlCommand SqlCom = new SqlCommand(); SqlCom.Connection = SqlConn; SqlCom.CommandText = "select ibranchno,ibranchname,iupbranchno from jifen.dbo.t_branch where iupbranchno = " + upID + " and IsEnable = 0"; SqlDataAdapter SqlDaA = new SqlDataAdapter(); SqlDaA.SelectCommand = SqlCom; DataSet ds = new DataSet(); SqlDaA.Fill(ds); //if (ds.Tables[0].Rows.Count < 1) //{ // TreeNode tNodeTmp = new TreeNode(); // tNodeTmp.Text = "生成树失败"; // tNode.ChildNodes.Add(tNodeTmp); // return; //} foreach (System.Data.DataRow myRow in ds.Tables[0].Rows) { TreeNode tNodeTmp = new TreeNode(); tNodeTmp.Text = myRow["ibranchname"].ToString(); tNodeTmp.Value = myRow["ibranchno"].ToString(); tNodeTmp.NavigateUrl = "operbranch.aspx?ibranchno=" + myRow["ibranchno"].ToString().Trim() + ""; tNodeTmp.Target = "right"; tNode.ChildNodes.Add(tNodeTmp); TreeNodeInit(int.Parse(myRow["ibranchno"].ToString().Trim()), tNodeTmp); } } #endregion 串口无故被关闭 C# DirectSound 录音(录制一个输出设备播放的音乐) DataGridView无法自由选择行 如何将一个字符串模拟成一个磁盘文件使用。因为一个函数的参数需要一个磁盘文本文件名称,而上面存放的数据我已经在文本框中放置好了 如何手动绑定ReportViewer值 datagridview 数据量问题(winform窗体)就这么多分了,全给了。 如何动态更新DLL 通过变量的值查找数据库 如何查找一个后缀为txt的文件呢? 菜鸟问题:关于网页的访问控制问题,散分100,来着有份! 请教一个面向对象的 数据库访问层的设计问题 跪求用C#得到局域网中在线的机器名和IP
http://blog.csdn.net/knight94/archive/2006/05/01/704281.aspx
Http://blog.csdn.net/knight94/archive/2006/03/24/637699.aspx
{
TreeView tv = new TreeView();
TreeNode tn = new TreeNode();
tn.Text = "选择局所";
tn.NavigateUrl = "1.htm";
tn.Target = "right";
TreeNodeInit(0, tn);
tv.Nodes.Add(tn);
TreeView1.Nodes.Add(tn);
}
#region 递归生成书结点
private void TreeNodeInit(int upID, System.Web.UI.WebControls.TreeNode tNode)
{
SqlConnection SqlConn = new SqlConnection();
SqlConn.ConnectionString = "Data Source=ip地址;Initial Catalog=***;Persist Security Info=True;User ID=***;password=***;Max Pool Size=512";
SqlConn.Open();
SqlCommand SqlCom = new SqlCommand();
SqlCom.Connection = SqlConn;
SqlCom.CommandText = "select ibranchno,ibranchname,iupbranchno from jifen.dbo.t_branch where iupbranchno = " + upID + " and IsEnable = 0";
SqlDataAdapter SqlDaA = new SqlDataAdapter();
SqlDaA.SelectCommand = SqlCom;
DataSet ds = new DataSet();
SqlDaA.Fill(ds);
//if (ds.Tables[0].Rows.Count < 1)
//{
// TreeNode tNodeTmp = new TreeNode();
// tNodeTmp.Text = "生成树失败";
// tNode.ChildNodes.Add(tNodeTmp);
// return;
//}
foreach (System.Data.DataRow myRow in ds.Tables[0].Rows)
{
TreeNode tNodeTmp = new TreeNode();
tNodeTmp.Text = myRow["ibranchname"].ToString();
tNodeTmp.Value = myRow["ibranchno"].ToString();
tNodeTmp.NavigateUrl = "operbranch.aspx?ibranchno=" + myRow["ibranchno"].ToString().Trim() + "";
tNodeTmp.Target = "right";
tNode.ChildNodes.Add(tNodeTmp);
TreeNodeInit(int.Parse(myRow["ibranchno"].ToString().Trim()), tNodeTmp);
}
}
#endregion