Ejemplo n.º 1
0
        /// <summary>
        /// 用一个foreach的函数填入相关信息
        /// </summary>
        /// <returns></returns>
        public override System.Web.UI.Control Build()
        {
            base.Build();
            ASPxPanel       panel = new ASPxPanel();
            ASPxCheckBox    checkbox;
            ASPxHiddenField CBhiddenfield    = new ASPxHiddenField();
            ASPxHiddenField CBhiddenfieldc   = new ASPxHiddenField();
            ASPxHiddenField CBhiddenfieldall = new ASPxHiddenField();

            CBhiddenfield.ClientInstanceName = "CBhiddenfield";
            CBhiddenfield.Clear();
            CBhiddenfieldc.ClientInstanceName = "CBhiddenfieldc";
            CBhiddenfieldc.Clear();
            CBhiddenfieldall.ClientInstanceName = "CBhiddenfieldall";
            CBhiddenfieldall.Clear();
            //先添加隐藏控件
            panel.Controls.Add(CBhiddenfield);
            panel.Controls.Add(CBhiddenfieldc);
            panel.Controls.Add(CBhiddenfieldall);
            string        selected     = ModuleField.CurrentValue == null ? ModuleField.DefaultValue == null ? null : ModuleField.DefaultValue.ToString() : ModuleField.CurrentValue.ToString();
            List <string> selectedlist = new List <string>();

            if (selected != null)
            {
                string[] selectedarray = selected.Split(';');
                selectedlist = selectedarray.ToList <string>();
            }
            List <DictionaryItem> itemslist = new List <DictionaryItem>();

            using (TestDBEntities entity = new TestDBEntities())
            {
                itemslist = entity.DictionaryItem.Where(oo => oo.DictionaryItemCode.StartsWith(ModuleField.CodeCat) && oo.DictionaryItemCode.Length == 7).ToList();
            }
            foreach (DictionaryItem item in itemslist)
            {
                checkbox       = new ASPxCheckBox();
                checkbox.Text  = item.DictionaryItemName;
                checkbox.Value = item.DictionaryItemValue;
                CBhiddenfieldall.Add(item.DictionaryItemName, item.DictionaryItemValue);
                checkbox.ClientSideEvents.CheckedChanged = "function (s,e) {CBchange(s,e);}";
                if (selected != null)
                {
                    foreach (string defaultchecked in selectedlist)
                    {
                        if (item.DictionaryItemName == defaultchecked)
                        {
                            checkbox.Checked = true;
                            CBhiddenfield.Add(item.DictionaryItemName, "");
                            CBhiddenfield.Add(item.DictionaryItemValue, "");
                        }
                    }
                }
                panel.Controls.Add(checkbox);
            }
            //排列方式

            return(panel);
        }
        public override System.Web.UI.Control Build()
        {
            base.Build();
            ASPxDropDownEdit ddedit   = new ASPxDropDownEdit();
            ASPxHiddenField  hfddedit = new ASPxHiddenField();
            ASPxPanel        panel    = new ASPxPanel();

            ddedit.Width  = ModuleField.Width;
            ddedit.Height = ModuleField.Height;
            ddedit.ValidationSettings.RequiredField.IsRequired = ModuleField.IsRequired;
            ddedit.ValidationSettings.RequiredField.ErrorText  = ModuleField.ErrorText;
            ddedit.ReadOnly                     = true;
            ddedit.Text                         = ModuleField.CurrentValue == null ? ModuleField.DefaultValue == null ? null : ModuleField.DefaultValue.ToString() : ModuleField.CurrentValue.ToString();
            ddedit.ClientInstanceName           = "dropdown";
            ddedit.DropDownWindowTemplate       = new MyTemplate(ModuleField.CodeCat, hfddedit);
            ddedit.ClientSideEvents.TextChanged = "SynchronizeListBoxValues";
            ddedit.ClientSideEvents.DropDown    = "SynchronizeListBoxValues";
            //ddedit.Enabled 可用来做只读

            //hf
            hfddedit.ClientInstanceName = "hfddedit";
            hfddedit.Clear();
            if (ModuleField.CurrentCode != null)
            {
                List <string> codelist = ModuleField.CurrentCode.ToString().Split(';').ToList();
                foreach (string code in codelist)
                {
                    hfddedit.Add(code, "");
                }
            }
            panel.Controls.Add(ddedit);
            panel.Controls.Add(hfddedit);
            return(panel);
        }
Ejemplo n.º 3
0
        public override System.Web.UI.Control Build()
        {
            base.Build();
            ASPxPanel           panel     = new ASPxPanel();
            ASPxRadioButtonList radioList = new ASPxRadioButtonList();

            radioList.ClientInstanceName = "radioList";
            //是否必填
            radioList.ValidationSettings.RequiredField.IsRequired = ModuleField.IsRequired;
            //选项为空的提示
            radioList.ValidationSettings.RequiredField.ErrorText = ModuleField.ErrorText;
            //排列方式
            radioList.RepeatDirection = RepeatDirection.Horizontal;
            //代码分类
            List <DictionaryItem> itemslist = new List <DictionaryItem>();

            using (TestDBEntities entity = new TestDBEntities())
            {
                itemslist = entity.DictionaryItem.Where(oo => oo.DictionaryItemCode.StartsWith(ModuleField.CodeCat) && oo.DictionaryItemCode.Length == 7).ToList();
            }
            foreach (DictionaryItem item in itemslist)
            {
                radioList.Items.Add(item.DictionaryItemName, item.DictionaryItemValue);
            }
            //默认值与当前值
            string selected = ModuleField.CurrentValue == null ? ModuleField.DefaultValue == null ? null : ModuleField.DefaultValue.ToString() : ModuleField.CurrentValue.ToString();

            if (selected != null)
            {
                radioList.Items.FindByText(selected).Selected = true;
            }
            //为RBlist添加改变事件
            radioList.ClientSideEvents.SelectedIndexChanged = "function (s,e){RBchange(s);}";
            //添加一个隐藏控件
            ASPxHiddenField RBhiddenfield = new ASPxHiddenField();

            RBhiddenfield.ClientInstanceName = "RBhiddenfield";
            RBhiddenfield.Clear();
            //写入值
            if (selected != null)
            {
                RBhiddenfield.Add(radioList.Items.FindByText(selected).Text, radioList.Items.FindByText(selected).Value);
            }
            panel.Controls.Add(radioList);
            panel.Controls.Add(RBhiddenfield);
            return(panel);
        }