在绑定树形控件时,能在添加节点时,在前面添加一个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");
}
}
}
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");
}
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货