举个栗子
[C#] 纯文本查看 复制代码 private void BindProductNode()
{
TreeNode root = new TreeNode("Product Phone", "Product Phone", "", "#", "");
root.Expanded = true;
tvAcc.Nodes.Add(root);
DataTable dtPlat = new DataTable();
dtPlat = reportBLL.GetPlatformList();// Data Source from db
DataTable dtPhone = new DataTable();//sub's title data source
for (int i = 0; i < dtPlat.Rows.Count; i++)
{
string platName = dtPlat.Rows[i]["Platform"].ToString();
string accID = dtPlat.Rows[i]["Platform"].ToString();
TreeNode tree1 = new TreeNode(platName, accID, "", "", "");
tree1.Expanded = false;
root.ChildNodes.Add(tree1);
dtPhone = reportBLL.GetPhoneList(platName);//eg."eDream6", get sub title's data source.
for (int j = 0; j < dtPhone.Rows.Count; j++)
{
string phone = dtPhone.Rows[j]["Product"].ToString();
TreeNode treeOverview = new TreeNode(phone, accID, "", "#.aspx?platform=" + platName + "&product=" + phone, "_blank");
tree1.ChildNodes.Add(treeOverview);
}
}
}
|