首页 > 学院 > 开发设计 > 正文

TreeView简单使用

2019-11-10 19:25:51
字体:
来源:转载
供稿:网友
PRotected void Page_Load(object sender, EventArgs e) { TreeNode node = new TreeNode(); node.Text = "分类设置"; node.Value = "-1"; for (int i = 0; i < 10; i++) { TreeNode childnode = new TreeNode(); childnode.Text = "第" + (i + 1) + "类"; childnode.Value = ""+(i + 1); node.ChildNodes.Add(childnode); } TreeView1.Nodes.Clear(); TreeView1.Nodes.Add(node); } /// <summary> /// 选定节点后触发 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void TreeView1_SelectedNodeChanged(object sender, EventArgs e) { string str = TreeView1.SelectedNode.Value; }<form id="form1" runat="server"> <div> <asp:TreeView ID="TreeView1" runat="server" OnSelectedNodeChanged="TreeView1_SelectedNodeChanged"></asp:TreeView> </div> </form>
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表