<wijmo:C1Tabs ID="C1Tab1" runat="server" ><%--OnSelectedChanged="" AutoPostBack="true" --%>
<Pages><wijmo:C1TabPage id="C1TabPage0" runat="server" ><wijmo:C1TreeView id="tabstree0" AllowTriState="false" runat="server"></wijmo:C1TreeView></wijmo:C1TabPage>
</Pages>
</wijmo:C1Tabs>
string str= "SELECT [a],[b] FROM [表名] ";
DataTable dtOil = DbHelper.DAL.ExecuteDataSet(str).Tables[0];
tree1(dtOil, "");
public void tree1(DataTable dtOil, string name)
{
string role = "select u.DisplayName from (select ur.UserID from (select RoleID from roles where RoleName=‘厂家‘ ) as r left join userroles ur on r.RoleID=ur.RoleID) as us left join users u on u.UserID=us.UserID where u.DisplayName like ‘%" + name + "%‘";
DataTable dtrole = DbHelper.DAL.DataTable(role);
C1Tab1.Pages.Clear();
for (int i = 0; i < dtrole.Rows.Count; i++)
{
//tab绑定
C1.Web.Wijmo.Controls.C1Tabs.C1TabPage ctab = new C1.Web.Wijmo.Controls.C1Tabs.C1TabPage();
ctab.ID = "C1TabPage" + i + "";
ctab.Text = dtrole.Rows[i][0].ToString();
C1TreeView c1 = new C1TreeView();
c1.ID = "tabstree" + i.ToString();
ctab.Controls.Add(c1);
C1Tab1.Pages.Add(ctab);
}
for (int i = 0; i < dtrole.Rows.Count; i++)
{
数据绑定
if (i == 0)
{
treeValues = "";
}
else
{
treeValues += "&";
}
C1TreeView c1 = (C1TreeView)C1Tab1.Pages[i].Controls[0];
c1.ShowCheckBoxes = true;
c1.ShowExpandCollapse = true;
string strchangjia = "SELECT * from (SELECT [a],[b] FROM [表名] where [treeType] = ‘1‘ and 品牌 like ‘%[0-9]%‘ group by [a],[b]) as jiu where jiu.alike ‘%" + dtrole.Rows[i][0].ToString().Replace(" ", "") + "%‘";
DataTable dchangjia = GJPDbHelper.DAL.DataTable(strchangjia);
BindTreeOil2(dchangjia, c1);
count++;
}
}
private C1TreeView BindTreeOil2(DataTable dtSource, C1TreeView c)
{
c.Nodes.Clear();
string topNodeStr = "";
string twoNodeStr = "";
C1TreeViewNode curNode = new C1TreeViewNode(); ;
//DataRow[] rows = dtSource.Select(string.Format("ParentID={0}", parentID));
foreach (System.Data.DataRow c1row in dtSource.Rows)
{
if (topNodeStr != Convert.ToString(c1row[0]))
{
C1TreeViewNode newNode = new C1TreeViewNode();
newNode.Value = Convert.ToString(c1row[0]);
newNode.Text = Convert.ToString(c1row[0]);
c.Nodes.Add(newNode);
topNodeStr = Convert.ToString(c1row[0]);
curNode = newNode;
}
else
{
C1TreeViewNode newNode = new C1TreeViewNode();
newNode.Value = Convert.ToString(c1row[1]);
newNode.Text = Convert.ToString(c1row[1]);
//string str = "select 产品 from [AIRB_MMTREE] where [类型] =‘" + c1row[1].ToString() + "‘";
//DataTable dt = GJPDbHelper.DAL.DataTable(str);
//for (int i = 0; i < dt.Rows.Count; i++)
//{
// C1TreeViewNode newNode1 = new C1TreeViewNode();
// newNode1.Value = Convert.ToString(dt.Rows[i][0]);
// newNode1.Text = Convert.ToString(dt.Rows[i][0]);
// newNode.Nodes.Add(newNode1);
//}
//if (twoNodeStr != Convert.ToString(c1row[1]))
//{
// C1TreeViewNode newNode1 = new C1TreeViewNode();
// newNode1.Value = Convert.ToString(c1row[1]);
// newNode1.Text = Convert.ToString(c1row[1]);
// newNode.Nodes.Add(newNode1);
// twoNodeStr = Convert.ToString(c1row[1]);
// newNode = newNode1;
//}
//else
//{
// C1TreeViewNode newNode1 = new C1TreeViewNode();
// newNode1.Value = Convert.ToString(c1row[2]);
// newNode1.Text = Convert.ToString(c1row[2]);
// newNode.Nodes.Add(newNode1);
//}
curNode.Nodes.Add(newNode);
}
}
return c;
}