using ..;
namespace WebApp
{
public partial class _Default : System.Web.UI.Page
{
TreeNode node;
protected void Page_Load(object sender, EventArgs e)
{
BindTree();
}
private void BindTree()
{
string cmdText = "SELECT AreaID,Name FROM Area WHERE substring(AreaID,3,4)='0000'";
using (SqlDataReader dr = SqlHelper.ExcuteReader(ConfigurationManager.ConnectionStrings["SqlConn"].ConnectionString, cmdText, null))
{
while (dr.Read())
{
node = new TreeNode();
node.Text = dr.GetString(1);
node.Value = dr.GetString(0);
node.NavigateUrl = "page.html?id=" + dr.GetString(0);
node.Target = "_blank";
TreeView1.Nodes.Add(node);
GetChilds(dr.GetString(0));
}
}
}
private void GetChilds(string parentid)
{
string cmdText = "SELECT AreaID,Name FROM Area WHERE substring(AreaID,1,2)='" + parentid.Substring(0, 2) + "' AND substring(AreaID,5,2)='00'";
using (SqlDataReader dr = SqlHelper.ExcuteReader(ConfigurationManager.ConnectionStrings["SqlConn"].ConnectionString, cmdText, null))
{
while (dr.Read())
{
TreeNode cnode = new TreeNode();
cnode.Text = dr.GetString(1);
cnode.NavigateUrl = "subpage.html?id="+dr.GetString(0);
cnode.Target = "_blank";
node.Expanded = false;
node.ChildNodes.Add(cnode);
}
}
}
protected void TreeView1_SelectedNodeChanged(object sender, EventArgs e)
{
TreeView1.SelectedNode.Expanded = true;
}
}
}
namespace WebApp
{
public partial class _Default : System.Web.UI.Page
{
TreeNode node;
protected void Page_Load(object sender, EventArgs e)
{
BindTree();
}
private void BindTree()
{
string cmdText = "SELECT AreaID,Name FROM Area WHERE substring(AreaID,3,4)='0000'";
using (SqlDataReader dr = SqlHelper.ExcuteReader(ConfigurationManager.ConnectionStrings["SqlConn"].ConnectionString, cmdText, null))
{
while (dr.Read())
{
node = new TreeNode();
node.Text = dr.GetString(1);
node.Value = dr.GetString(0);
node.NavigateUrl = "page.html?id=" + dr.GetString(0);
node.Target = "_blank";
TreeView1.Nodes.Add(node);
GetChilds(dr.GetString(0));
}
}
}
private void GetChilds(string parentid)
{
string cmdText = "SELECT AreaID,Name FROM Area WHERE substring(AreaID,1,2)='" + parentid.Substring(0, 2) + "' AND substring(AreaID,5,2)='00'";
using (SqlDataReader dr = SqlHelper.ExcuteReader(ConfigurationManager.ConnectionStrings["SqlConn"].ConnectionString, cmdText, null))
{
while (dr.Read())
{
TreeNode cnode = new TreeNode();
cnode.Text = dr.GetString(1);
cnode.NavigateUrl = "subpage.html?id="+dr.GetString(0);
cnode.Target = "_blank";
node.Expanded = false;
node.ChildNodes.Add(cnode);
}
}
}
protected void TreeView1_SelectedNodeChanged(object sender, EventArgs e)
{
TreeView1.SelectedNode.Expanded = true;
}
}
}