c# 后台绑定treeview 单个tab

2021-02-10 18:15

阅读:587

标签:lag   框架   edit   portal   dal   port   dataset   value   --   



后台

 DataTable dtOil = GJPDbHelper.DAL.ExecuteDataSet("SELECT [品牌],[类型] FROM  [AIRB_MMTREE] where [treeType] = ‘1‘  group by [品牌],[类型]").Tables[0];
 
 BindTreeOil(dtOil);

        #region "Optional Interfaces"
 
        /// ----------------------------------------------------------------------------- 
        ///  
        /// Registers the module actions required for interfacing with the portal framework 
        ///  
        ///  
        ///  
        ///  
        ///  
        ///  
        /// ----------------------------------------------------------------------------- 
        public ModuleActionCollection ModuleActions
        {
            get
            {
                ModuleActionCollection Actions = new ModuleActionCollection();
                Actions.Add(GetNextActionID(), Localization.GetString(ModuleActionType.AddContent, this.LocalResourceFile),
                   ModuleActionType.AddContent, "", "add.gif", EditUrl(), false, DotNetNuke.Security.SecurityAccessLevel.Edit,
                    true, false);
                return Actions;
            }
        }
 
        #endregion
 
 
        /// 
        /// 将数据绑定到C1TreeView1
        /// 
        /// 传入两列数据
        private void BindTreeOil(DataTable dtSource)
        {
 
            C1TreeView1.Nodes.Clear();
 
            string topNodeStr = "";
 
            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]);
 
                    C1TreeView1.Nodes.Add(newNode);
                    topNodeStr = Convert.ToString(c1row[0]);
                    curNode = newNode;
 
                    C1TreeViewNode newsubNode = new C1TreeViewNode();
                    newsubNode.Value = Convert.ToString(c1row[1]);
                    newsubNode.Text = Convert.ToString(c1row[1]);
 
                    curNode.Nodes.Add(newsubNode);
                }
                else
                {
                    C1TreeViewNode newNode = new C1TreeViewNode();
                    newNode.Value = Convert.ToString(c1row[1]);
                    newNode.Text = Convert.ToString(c1row[1]);
 
                    curNode.Nodes.Add(newNode);
 
                }
            }
        }
 
 
        /// 
        /// 建立所选项目的目录框架
        /// 
        /// 
        /// 
        protected DataTable checkItemTableOil(C1TreeView ctrv)
        {
            InsusJsUtility js = new InsusJsUtility();
            Boolean itemCountFlag = false;
            string parentText = "";
            int boolCount = 0;
            DataTable infoTable = new DataTable();
            infoTable = GJPDbHelper.DAL.ExecuteDataSet("SELECT ‘‘ as pinpai,‘‘ as leixing FROM [AIRB_MMTREE] where [treeType] = ‘999‘ ").Tables[0];
 
            foreach (C1TreeViewNode csnode in ctrv.Nodes)
            {
                //csnode.CheckState = C1TreeViewNodeCheckState.Indeterminate;
                if (csnode.CheckState == C1TreeViewNodeCheckState.Checked)
                {
                    if (boolCount > 3)
                    {
                        js.JsAlert("选择油品已大于4个");
                        break;
                    }
                    additemInfoRow(infoTable, csnode.Text, "");
                    boolCount++;
                }
                else if (csnode.CheckState == C1TreeViewNodeCheckState.Indeterminate)
                {
                    foreach (C1TreeViewNode subcsnode in csnode.Nodes)
                    {
                        if (subcsnode.CheckState == C1TreeViewNodeCheckState.Checked)
                        {
                            if (boolCount > 3)
                            {
                                js.JsAlert("选择油品已大于4个");
                                break;
                            }
                            additemInfoRow(infoTable, csnode.Text, subcsnode.Text);
                            boolCount++;
                        }
                    }
                }
            }
            return infoTable;
        }
 
        /// 
        /// 
        /// 快速设置新的结构行
        /// 
        /// 
        /// 
        /// 
        protected void additemInfoRow(DataTable dt, string level1, string level2)
        {
            System.Data.DataRow row;
            row = dt.NewRow();
            // Then add the new row to the collection.
            row[0] = level1;
            row[1] = level2;
            dt.Rows.Add(row);
        }
        //树状图中被选项显示到C1GridView1中
        protected void ButtonToTable_Click(object sender, EventArgs e)
        {
            // 返回目录
            DataTable dt = new DataTable();
            InsusJsUtility js = new InsusJsUtility();
            dt = checkItemTableOil(C1TreeView1);
            int dtCount = dt.Rows.Count;
 
            if (dtCount == 0)
            {
                js.JsAlert("未选择油品!");
            }
            else
            {
                C1GridView1.DataSource = dt;
                C1GridView1.DataBind();
 
                ButtonToDsr.Visible = true;
            }
 
 
        }

c# 后台绑定treeview 单个tab

标签:lag   框架   edit   portal   dal   port   dataset   value   --   

原文地址:https://www.cnblogs.com/otsf/p/8520961.html


评论


亲,登录后才可以留言!