惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
T
Threatpost
Latest news
Latest news
N
News | PayPal Newsroom
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Help Net Security
Help Net Security
D
Darknet – Hacking Tools, Hacker News & Cyber Security
AI
AI
Simon Willison's Weblog
Simon Willison's Weblog
TaoSecurity Blog
TaoSecurity Blog
The Last Watchdog
The Last Watchdog
L
LINUX DO - 热门话题
Google DeepMind News
Google DeepMind News
T
Threat Research - Cisco Blogs
O
OpenAI News
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
The Exploit Database - CXSecurity.com
NISL@THU
NISL@THU
Application and Cybersecurity Blog
Application and Cybersecurity Blog
S
Securelist
小众软件
小众软件
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Martin Fowler
Martin Fowler
S
SegmentFault 最新的问题
Cisco Talos Blog
Cisco Talos Blog
云风的 BLOG
云风的 BLOG
AWS News Blog
AWS News Blog
GbyAI
GbyAI
N
News and Events Feed by Topic
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
美团技术团队
Engineering at Meta
Engineering at Meta
A
About on SuperTechFans
博客园 - 三生石上(FineUI控件)
S
Schneier on Security
博客园 - 聂微东
V2EX - 技术
V2EX - 技术
T
Troy Hunt's Blog
SecWiki News
SecWiki News
S
Secure Thoughts
B
Blog RSS Feed
Hugging Face - Blog
Hugging Face - Blog
WordPress大学
WordPress大学
腾讯CDC
H
Heimdal Security Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Apple Machine Learning Research
Apple Machine Learning Research
月光博客
月光博客
www.infosecurity-magazine.com
www.infosecurity-magazine.com
P
Privacy International News Feed

博客园 - 心有灵犀

android java se development kit not found 送给博客园所有热爱欧洲杯的朋友 Access通用操作数据类 - 心有灵犀 - 博客园 博客园中IBATIS学习资料 转个:[翻译]了解ASP.NET底层架构系列文章(包括Word下载) (转)强烈推荐:240多个jQuery插件 LINQ 学习资料 oracle 读取表结构和注释,生成数据库结构文档 oracle9i中导出含有lob字段的表的方法 oracle误删除的恢复方法 (转)ORACLE UPDATE 语句语法与性能分析的一点看法 简单修改了下梅老大的日期控件,加了个清空功能 简单封装了下基本的AJAX实现 一个正在用的javascript日期控件 .net导出excel无表格线解决办法(转载) 2007年5月到年底学习重点 巧用MSN协议命令 一个验证日期格式的超强正则表达式 .NET委托:一个C#睡前故事
treeview选择操作(checkbox)
心有灵犀 · 2007-03-12 · via 博客园 - 心有灵犀

//--选择操作 最好是用checkbox直观..
//--treeview绑定例子
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;


public partial class _Default : System.Web.UI.Page
{
    private string connstring = ConfigurationManager.ConnectionStrings["ConnStr"].ToString();

    private bool isHaveCheckBox = false;
    private bool isExpanded = false;
    private DataTable dtTree = null;
    protected void Page_Load(object sender, EventArgs e)
    {
        //Response.Write("tttttttttt");
        if (!IsPostBack)
        {
            AreaTree.Nodes.Add(getRootAreaTreeNode(false, false));
        }       

    }

    /// 
<summary>
    /// 获取包含全部子节点的根节点数据
    /// 
</summary>   
    /// 
<param name="haveCheckBox">节点是否产生CheckBox</param>
    /// 
<param name="expanded">节点是否展开</param>    
    /// 
<returns></returns>
    public TreeNode getRootAreaTreeNode(bool haveCheckBox, bool expanded)
    {
        //drPeng.HS.BR.AreaTree brTree = new drPeng.HS.BR.AreaTree();

        string rootID = "0001";//brTree.getRootAreaTreeID();
        string rootName = "中国";//brTree.getRootAreaTreeName();
        //ds = brTree.getAllAreaTree();

        isHaveCheckBox = haveCheckBox;
        isExpanded = expanded;

        #region populate root node
        TreeNode rootNode = new TreeNode();
        rootNode.Text = rootName;
        rootNode.Value = rootID;
        //rootNode. = rootName;
        // rootNode.NodeData = "0001";
        
        rootNode.Expanded = true;
        // rootNode.CheckBox = isHaveCheckBox;
        #endregion

        DataSet dsTree = SqlHelper.ExecuteDataset(connstring, CommandType.Text, "select * from TB_Area");
        dtTree = dsTree.Tables[0];
        this.populateAreaTree(rootID, rootNode);

        return rootNode;
    }

    private void populateAreaTree(string parentID, TreeNode pNode)
    {        

        DataRow[] dRows = dtTree.Select("ParentAreaCode='" + parentID +"'");
       
        if (dRows.Length > 0)
        {
            TreeNode Node = null;
            foreach (DataRow drow in dRows)
            {
                Node = new TreeNode();
                Node.Text = drow["AreaName"].ToString();
                Node.Value = drow["AreaCode"].ToString();
                //Node.DataItem = Node.Text + "|" + Node.Value;
                Node.Expanded = isExpanded;
                pNode.ChildNodes.Add(Node);
                populateAreaTree(Node.Value, Node);     //递归 
            }            
        }
    }
}

 posted on 2007-03-12 13:47  心有灵犀  阅读(592)  评论(0)    收藏  举报

刷新页面返回顶部