在绑定树形控件时,能在添加节点时,在前面添加一个checkbox选择框吗?
public partial class Customer_CustomerTreeViwe : System.Web.UI.Page
{
    PMSDatabaseContextContainer pms = new PMSDatabaseContextContainer();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack) 
        {
           
            //BindTreeView();
            TreeNode node = new TreeNode("南充市商业银行成都分行");
            this.TreeView1.Nodes.Add(node);
            BindTree(new Guid("64B0C5DE-98A6-4836-A197-900AB340717B"), node,"null");
        }
    }    public List<CustomerCompany> getNodeByid(Guid cid,string s)
    {        List<CustomerCompany> list = new List<CustomerCompany>();
        GridView g = new GridView();
        if (s == "null")
        {
            g.DataSource = from c in pms.CustomerCompanys where c.ParentId == null select c;
            g.DataBind();
        }
        else
        {
            g.DataSource = from c in pms.CustomerCompanys where c.ParentId == (System.Nullable<Guid>)cid select c;
            //var t = from p in pms.CustomerCompanys where p.ParentId != null select p;
            //g.DataSource = t; 
            g.DataBind();
        }
        for (int i = 0; i < g.Rows.Count; i++)
        {
            CustomerCompany cust = new CustomerCompany();
            cust.CustomerCompnayId = new Guid(g.Rows[i].Cells[0].Text);
            cust.DisplayName = g.Rows[i].Cells[1].Text;
            cust.Address = g.Rows[i].Cells[2].Text;
            //cust.ParentId = g.Rows[i].Cells[8].Text;
            list.Add(cust);
        }
        return list;
    }
    public void BindTree(Guid cid, TreeNode node,string s)
    {
        List<CustomerCompany> list = getNodeByid(cid,s);
        for (int i = 0; i < list.Count; i++)
        {
            TreeNode no = new TreeNode();
            no.Value = list[i].CustomerCompnayId.ToString();
            no.Text = list[i].DisplayName.ToString();
            node.ChildNodes.Add(no);            List<CustomerCompany> list2 = getNodeByid(new Guid(no.Value.ToString()),"sd");
            if (list2.Count > 0)
            {
                BindTree(new Guid(no.Value.ToString()), no,"sx");
            }
        }
    }

解决方案 »

  1.   

    可以,ASP.NET 2.0 以上就支持:http://www.google.com.hk/#hl=zh-CN&source=hp&q=asp.net+checkbox+treeview&oq=asp.net+checkbox+treeview&aq=f&aqi=g1&aql=&gs_sm=e&gs_upl=235l5922l0l6344l25l23l0l14l14l0l281l1967l0.3.6l9l0&fp=fc147b2b16a2fe57&biw=792&bih=466
      

  2.   

    在TreeView的属性中的CheckBoxes设为ture
      

  3.   

    TreeView+CheckBoxes
      

  4.   

    服务器控件TreeView  自带这个属性
      

  5.   

    在TreeView的属性中的CheckBoxes设为ture
      

  6.   

    在TreeView的属性中的CheckBoxes设为ture