private Service svc = Service.GetInstance();
DataSet allRegion;
protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack){
InitPage();
}
}
private void InitPage() {
string lang = "sc";
allRegion = svc.GetAllRegion(lang);
AddNode(0, null);
}
private void AddNode(int fid, TreeNode fatherNode) {
DataRow[] rows = allRegion.Tables[0].Select("fid=" + fid);
foreach(DataRow row in rows){
TreeNode node = new TreeNode(row["name"].ToString(), row["id"].ToString());
node.Expanded = false;
if (fatherNode == null)
{
trvRegion.Nodes.Add(node);
}
else {
fatherNode.ChildNodes.Add(node);
}
AddNode(int.Parse(row["id"].ToString()), node);
}
}