Наследование: ListControl, IRepeatInfoUser, INamingContainer, IPostBackDataHandler
Пример #1
0
 public static void ChkListFill(ref CheckBoxList chkl, object list)
 {
     chkl.DataTextField = listDefaultDataTextField;
     chkl.DataValueField = listDefaultDataValueField;
     chkl.DataSource = list;
     chkl.DataBind();
 }
Пример #2
0
 public void setCheckBoxList(CheckBoxList chl, DataSet ds, string display, string value)
 {
     chl.DataSource = ds;
     chl.DataTextField = display;
     chl.DataValueField = value;
     chl.DataBind();
 }
Пример #3
0
 /// <summary>
 /// Add Style in CheckBoxes Color Collection.
 /// </summary>
 public static void AddColorInColorCollections(CheckBoxList ColorchkBxs)
 {
     for (int i = 0; i < ColorchkBxs.Items.Count; i++)
     {
         ColorchkBxs.Items[i].Attributes.Add("style", "color:" + ColorchkBxs.Items[i].Text + ";");
     }
 }
Пример #4
0
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="entity">泛型实体</param>
        /// <returns></returns>
        public bool UpdateEntity(Owen.Model.Model_Distributor entity, CheckBoxList cbl)
        {
            bool b = false;
            using (TransactionScope tranScope = new TransactionScope())
            {
                if (entity == null || entity.DistributorID == 0) tranScope.Dispose();

                new BLL_DistributorRelation().DeleteEntity(string.Format(" DistributorID = {0} ", entity.DistributorID)); 
                foreach (ListItem li in cbl.Items)
                {
                    int hosId = Convert.ToInt32(li.Value);
                    if (li.Selected == true)
                    {
                        Owen.Model.Model_DistributorRelation mDistributorRelation = new Owen.Model.Model_DistributorRelation();
                        mDistributorRelation.DistributorID = entity.DistributorID;
                        mDistributorRelation.HospitalID = hosId;
                        new BLL_DistributorRelation().AddEntity(mDistributorRelation);
                    }
                }
                dataFactory.DistributorDal.UpdateEntity(entity);
                tranScope.Complete();
                b = true;
            }
            return b;
        }
        private void BindList()
        {
            if (siteSettings == null) { siteSettings = CacheHelper.GetCurrentSiteSettings(); }
            //why is this null here, its declared
            if (chkAllowedRoles == null)
            {
                chkAllowedRoles = new CheckBoxList();
                if (this.Controls.Count == 0) { this.Controls.Add(chkAllowedRoles); }
            }

            chkAllowedRoles.Items.Clear();

            ListItem allItem = new ListItem();
            allItem.Text = Resource.RolesAllUsersRole;
            allItem.Value = "All Users";
            chkAllowedRoles.Items.Add(allItem);

            using (IDataReader reader = Role.GetSiteRoles(siteSettings.SiteId))
            {
                while (reader.Read())
                {
                    ListItem listItem = new ListItem();
                    listItem.Text = reader["DisplayName"].ToString();
                    listItem.Value = reader["RoleName"].ToString();

                    if ((selectedRoles.LastIndexOf(listItem.Value + ";") > -1))
                    {
                        listItem.Selected = true;
                    }

                    chkAllowedRoles.Items.Add(listItem);

                }
            }
        }
Пример #6
0
 public McmsWebQuestion(string strId, bool bRequired, string strRequiredText, string strQuestion, string strControlBase, RepeatDirection rdLayout, string[] strResponses)
     : base(strId, "mcms", bRequired, strRequiredText, strQuestion)
 {
     this.m_listBox = new ListBox();
     this.m_checkBoxList = new CheckBoxList();
     this.m_listControl = null;
     if (strControlBase == "checkbox")
     {
         this.m_checkBoxList.RepeatDirection = rdLayout;
         this.m_listControl = this.m_checkBoxList;
     }
     else
     {
         this.m_listBox.SelectionMode = ListSelectionMode.Multiple;
         this.m_listControl = this.m_listBox;
     }
     foreach (string text in strResponses)
     {
         this.m_listControl.Items.Add(new ListItem(text));
     }
     this.m_listControl.ID = "lst_" + strId;
     this.Controls.Add(this.m_listControl);
     if (bRequired)
     {
         ListControlValidator child = new ListControlValidator();
         child.EnableClientScript = false;
         child.Text = strRequiredText;
         child.Display = ValidatorDisplay.Dynamic;
         child.ControlToValidate = this.m_listControl.ID;
         this.Controls.Add(child);
     }
     this.Controls.Add(new LiteralControl("</p>"));
 }
Пример #7
0
 /// <summary>
 /// 添加
 /// </summary>
 public bool Insert(Model_Resource resourceModel, CheckBoxList cbl)
 {
     bool b = false;
     using (TransactionScope tranScope = new TransactionScope())
     {
         int id = dataFactory.ResourceDal.AddEntity(resourceModel).ResourceID;
         if (id > 0)
         {
             //添加到资源权限表Privilege
             foreach (ListItem li in cbl.Items)
             {
                 if (li.Selected == true)
                 {
                     int operateId = Convert.ToInt32(li.Value);
                     Owen.Model.Model_Privilege mPrivilege = new Model_Privilege();
                     mPrivilege.OperateID = operateId;
                     mPrivilege.ResourceID = id;
                     mPrivilege.Remark = string.Empty;
                     new BLL_Privilege().AddEntity(mPrivilege);
                 }
             }
             tranScope.Complete();
             b = true;
         }
     }
     return b;
 }
Пример #8
0
        public MultipleSelectControl(MultipleSelect item, RepeatDirection direction)
        {
            this.item = item;

            l = new Label();
            l.Text = item.Title;
            l.CssClass = "label";
            l.AssociatedControlID = item.Name;
            this.Controls.Add(l);

            list = new CheckBoxList();
            list.RepeatDirection = direction;
            list.ID = item.Name;
            list.CssClass = "alternatives";
            list.DataSource = item.GetChildren();
            list.DataTextField = "Title";
            list.DataValueField = "ID";
            list.DataBind();
            this.Controls.Add(list);

            if (item.Required)
            {
                cv = new CustomValidator { Display = ValidatorDisplay.Dynamic, Text = "*" };
                cv.ErrorMessage = item.Title + " is required";
                cv.ServerValidate += (s, a) => a.IsValid = !string.IsNullOrEmpty(AnswerText);
                cv.ValidationGroup = "Form";
                this.Controls.Add(cv);
            }
        }
        /// <summary>
        /// Renders the goals.
        /// </summary>
        /// <param name="doc">The document.</param>
        private void RenderGoals(XDocument doc)
        {
            Assert.ArgumentNotNull((object)doc, "doc");

            List<string> selected = new List<string>();
            foreach (XElement element in doc.Descendants((XName)"event"))
                selected.Add(XElementExtensions.GetAttributeValue(element, "name"));

            CheckBoxList checkBoxList = new CheckBoxList() { ID = "GoalsCheckBoxList" };
            this.GoalsList.Controls.Add((System.Web.UI.Control)checkBoxList);

            System.Web.UI.Page page = TrackingFieldPageBase.GetPage();
            if (page == null || page.IsPostBack)
                return;

            GoalsPipelineArgs args = new GoalsPipelineArgs();
            args.RulesFolderID = SitecoreIDs.GoalsRulesFolderID;
            ID id = ShortID.DecodeID(Sitecore.Context.Request.QueryString["id"]);
            if (!id.IsNull)
                args.ContextItem = Sitecore.Context.ContentDatabase.GetItem(id);

            CorePipeline.Run("uiGetGoals", args);

            TrackingFieldPageBase.RenderCheckBoxList(checkBoxList, args.PageEvents.OrderBy(e => e.DisplayName), selected);
        }
        public void CargarPermisosCheckeados(CheckBoxList chklist, int id)
        {
            DataSet ds = new DataSet();
            ds = ListadoDePermisos();

            chklist.Items.Clear();

            if (ds.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    chklist.Items.Add(new ListItem(ds.Tables[0].Rows[i]["Permiso_desc"].ToString(), ds.Tables[0].Rows[i]["Permiso_id"].ToString()));

                }

                ds = new DataSet();
                ds = ListadoDePermisos(id);

                if (ds.Tables[0].Rows.Count > 0)
                {
                    for (int i = 0; i < chklist.Items.Count; i++)
                    {
                        for (int j = 0; j < ds.Tables[0].Rows.Count; j++)
                        {
                            if (chklist.Items[i].Value == ds.Tables[0].Rows[j]["PERMISO_ID"].ToString())
                            {
                                chklist.Items[i].Selected = true;
                            }
                        }
                    }
                }

            }
        }
Пример #11
0
        public string GetCheckBoxSelectValues(CheckBoxList control)
        {
            string strCheckBoxLibrary = "";

            if (control.SelectedIndex == -1)
            {
                //for (int i = 0; i < control.Items.Count; i++)
                //{
                //    if (control.Items[i].Text != "全选")
                //    {
                //        strCheckBoxLibrary += control.Items[i].Value + ",";
                //    }
                //}
                //return strCheckBoxLibrary.Trim(',');
                return "";
            }
            else
            {
                for (int i = 0; i < control.Items.Count; i++)
                {
                    if (control.Items[i].Text != "全选" && control.Items[i].Selected == true)
                    {
                        strCheckBoxLibrary += control.Items[i].Value + ",";
                    }
                }
                return strCheckBoxLibrary.Trim(',');
            }
        }
Пример #12
0
 public static String GetCheckedCheckBoxListItems(CheckBoxList checkBoxList)
 {
     lock (checkBoxList.Items.SyncRoot)
       {
     return checkBoxList.Items.Cast<ListItem>().Where(li => li.Selected).Select(li => li.Text).Join(";");
       }
 }
Пример #13
0
 public static string CheckListToStr(CheckBoxList Obj)
 {
     string text = "";
     int count = Obj.Items.Count;
     int arg_19_0 = 0;
     checked
     {
         int num = count - 1;
         int num2 = arg_19_0;
         bool flag;
         while (true)
         {
             int arg_5D_0 = num2;
             int num3 = num;
             if (arg_5D_0 > num3)
             {
                 break;
             }
             flag = Obj.Items[num2].Selected;
             if (flag)
             {
                 text = text + "," + Obj.Items[num2].Value;
             }
             num2++;
         }
         flag = (Operators.CompareString(text, "", false) != 0);
         if (flag)
         {
             text = Strings.Right(text, Strings.Len(text) - 1);
         }
         return text;
     }
 }
Пример #14
0
 public static void populate(CheckBoxList element, int id_equipe)
 {
     element.DataSource = controller().find_by_equipe(id_equipe);
     element.AppendDataBoundItems = true;
     element.DataTextField = "nome";
     element.DataValueField = "id";
     element.DataBind();
 }
Пример #15
0
 /// <summary>
 /// 根据提供的Id字符串,将列表中的项选中
 /// </summary>
 /// <param name="itemid">Id字符串,由,分隔</param>
 /// <param name="checkboxlist">CheckBoxList控件</param>
 public static void CheckItem(string itemid, CheckBoxList checkboxlist)
 {
     foreach (ListItem li in checkboxlist.Items)
     {
         if (itemid.IndexOf(li.Value) != -1)
             li.Selected = true;
     }
 }
Пример #16
0
 public void FillCheckBoxList(CheckBoxList chk, DataTable mydt, string textField, string valueFeild)
 {
     chk.DataSource = mydt;
     chk.DataValueField = valueFeild;
     chk.DataTextField = textField;
     chk.DataBind();
     chk.Items.Insert(0, new ListItem { Value = "0", Text = "All", Selected = false });
 }
Пример #17
0
 protected override Control AddEditor(Control container)
 {
     CheckBoxList cbl = new CheckBoxList();
     foreach (Items.Role role in Context.Current.Resolve<IWebSecurityManager>().GetRoles(container.Page.User))
         cbl.Items.Add(role.Name);
     container.Controls.Add(cbl);
     return cbl;
 }
Пример #18
0
 public static void populateCheckbox(CheckBoxList element)
 {
     element.DataSource = controller().index();
     element.AppendDataBoundItems = true;
     element.DataTextField = "nom_disc";
     element.DataValueField = "id";
     element.DataBind();
 }
Пример #19
0
 private static CheckBoxList GetCheckBoxList(string id, string keys, string values, string selectedValues)
 {
     CheckBoxList list = new CheckBoxList();
     list.ID = id;
     list.ClientIDMode = System.Web.UI.ClientIDMode.Static;
     list.RepeatDirection = RepeatDirection.Horizontal;
     Helper.AddListItems(list, keys, values, selectedValues);
     return list;
 }
Пример #20
0
        public static void controlbindcheckbox(Type tp, CheckBoxList ddl)
        {
            string[] names = Enum.GetNames(tp);
            int[] values = (int[])Enum.GetValues(tp);

            for (int i = 0; i < names.Length; i++)
            {
                ddl.Items.Add(new ListItem(names[i], values[i].ToString()));
            }
        }
Пример #21
0
 internal string getCheckBoxListValues(CheckBoxList list)
 {
     StringBuilder sb = new StringBuilder("");
     for (int i = 0; i < list.Items.Count; i++) {
         if (list.Items[i].Selected) {
             sb.AppendFormat(",{0}", list.Items[i].Value);
         }
     }
     return sb.ToString().TrimStart(',');
 }
Пример #22
0
        /// <summary>
        /// Creates the control(s) neccessary for prompting user for a new value
        /// </summary>
        /// <param name="configurationValues"></param>
        /// <returns>
        /// The control
        /// </returns>
        public override Control EditControl( Dictionary<string, ConfigurationValue> configurationValues )
        {
            CheckBoxList editControl = new CheckBoxList();

            if ( configurationValues != null && configurationValues.ContainsKey( "values" ) )
                foreach ( string value in configurationValues["values"].Value.Split( new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries ) )
                    editControl.Items.Add( new ListItem( value ) );

            return editControl;
        }
Пример #23
0
 /// <summary>
 /// Add the special roles found in SpecialPortalRoles
 /// </summary>
 /// <param name="listRoles">The list roles.</param>
 public static void populateSpecialRoles(ref CheckBoxList listRoles)
 {
     foreach (string s in Enum.GetNames(typeof (SpecialPortalRoles)))
     {
         SpecialPortalRoles desc = (SpecialPortalRoles) Enum.Parse(typeof (SpecialPortalRoles), s);
         string stringDesc = GetDescription(desc);
         listRoles.Items.Add(new ListItem
                                 (stringDesc, ((int) Enum.Parse(typeof (SpecialPortalRoles), s)).ToString()));
     }
 }
Пример #24
0
		protected override Control AddEditor(Control container)
		{
			CheckBoxList cbl = new CheckBoxList();
			foreach (string role in Roles.GetAllRoles())
			{
				cbl.Items.Add(role);
			}
			container.Controls.Add(cbl);
			return cbl;
		}
Пример #25
0
        public void FillCheckBoxList(ref CheckBoxList objchkList, string strQuery, string strTextField, string strValueField, string strOrderBy, string strQueryCondition = "")
        {
            dsCommon = new DataSet();
            dsCommon = CrystalConnection.CreateDatasetWithoutTransaction(strQuery + " " + strQueryCondition + " " + strOrderBy);

            objchkList.DataTextField = strTextField;
            objchkList.DataValueField = strValueField;
            objchkList.DataSource = dsCommon.Tables[0].DefaultView;
            objchkList.DataBind();
        }
        protected override Control AddEditor(Control container)
        {
            CheckBoxList checkBoxList = new CheckBoxList();
            checkBoxList.CssClass += " checkBoxList";
            checkBoxList.RepeatLayout = RepeatLayout.Flow;

            container.Controls.Add(checkBoxList);
            container.Controls.Add(new LiteralControl("<br style=\"clear:both\" />"));

            return checkBoxList;
        }
        private string GetSelectedCheckBoxListItems(CheckBoxList list)
        {
            var selected = "";
            foreach (ListItem i in list.Items)
            {
                if (i.Selected)
                    selected += i.Value + ",";
            }

            return selected.TrimEnd(new char[] { ',' });
        }
Пример #28
0
        public static ListItem GetCheckBoxListItem(CheckBoxList checkBoxList, string value)
        {
            if (string.IsNullOrEmpty(value))
            {
                return new ListItem("N/A", "-1");
            }

            ListItem item = checkBoxList.Items.FindByValue(value);
            if (item != null) return item;

            return new ListItem("N/A", "-1");
        }
Пример #29
0
  /// <summary>
  /// 返回CheckBoxList所选值的字符串(以$分割连接)
  /// </summary>
  /// <param name="CheckBoxList"></param>
 public static string GetCheckBoxListValue(CheckBoxList checkList)
 {
      string checkStr = string.Empty;
      for (int i = 0; i < checkList.Items.Count; i++)
      {
          if (checkList.Items[i].Selected == true)
          {
              checkStr += checkList.Items[i].Value + "$";
          }
      }
      return checkStr.TrimEnd('$');
 }
Пример #30
0
 public static int Ck_Tiene_Selected(CheckBoxList ck)
 {
     int j = 0;
     for (int i = 0; i < ck.Items.Count; i++)
     {
         if (ck.Items[i].Selected)
         {
             j++;
         }
     }
     return j;
 }
Пример #31
0
        protected void btnGroupUpdate_Click(object sender, EventArgs e)
        {
            // 在操作之前进行权限检查
            if (!CheckPower("CoreRolePowerEdit"))
            {
                CheckPowerFailWithAlert();
                return;
            }

            int roleId = GetSelectedDataKeyID(Grid1);

            if (roleId == -1)
            {
                return;
            }

            // 当前角色新的权限列表
            List <int> newPowerIDs = new List <int>();

            for (int i = 0; i < Grid2.Rows.Count; i++)
            {
                AspNet.CheckBoxList ddlPowers = (AspNet.CheckBoxList)Grid2.Rows[i].FindControl("ddlPowers");
                foreach (AspNet.ListItem item in ddlPowers.Items)
                {
                    if (item.Selected)
                    {
                        newPowerIDs.Add(Convert.ToInt32(item.Value));
                    }
                }
            }
            //先删除原来有的角色权限
            RolePowerModel.RoleID = roleId;
            RolePowerModel.OpType = DataOperationType.Delete;
            XASYU.BLL.DataBaseManager.op_SYS_ROLEPOWERS(userBean, RolePowerModel);
            //再添加新选的角色
            foreach (int ids in newPowerIDs)
            {
                RolePowerModel.RoleID  = roleId;
                RolePowerModel.PowerID = ids;
                RolePowerModel.OpType  = DataOperationType.Add;
                XASYU.BLL.DataBaseManager.op_SYS_ROLEPOWERS(userBean, RolePowerModel);
            }
            Alert.ShowInTop("当前角色的权限更新成功!");
        }
Пример #32
0
        private void ConfirmPermission_Click(object sender, Infragistics.WebUI.WebDataInput.ButtonEventArgs e)
        {
            if (Session["SelectedRoleID"] == null)
            {
                return;
            }

            int ID = Convert.ToInt32(Session["SelectedRoleID"]);

            //获取选择的行的IDting();
            mysm.UpdatePermission(SelectPermission, ID);
            //设置选择角色的权限
            SelectPermission = mysm.CheckedOption(ID, SelectPermission);

            //将用完的会话清空
            Session["SelectedRoleID"] = null;

            PermissionPanel.Visible = false;
        }
Пример #33
0
        /// <summary>
        /// 获取复选列表的值  用,号隔开
        /// </summary>
        /// <param name="cblControls"></param>
        /// <returns></returns>
        public static string GetCheckBoxListSelectValue(System.Web.UI.WebControls.CheckBoxList cblControls, string strParam)
        {
            StringBuilder sb    = new StringBuilder(16);
            ListItem      litem = null;

            for (int i = 0; i < cblControls.Items.Count; i++)
            {
                litem = cblControls.Items[i];
                if (litem.Selected)
                {
                    if (sb.Length > 0)
                    {
                        sb.Append(strParam);
                    }
                    sb.Append(litem.Value);
                }
            }
            return(sb.ToString());
        }
Пример #34
0
        protected void RebindModelDescriptions()
        {
            string country_owner = SessionHandler.MappingSelectedCountryOwner;
            string country_rent  = SessionHandler.MappingSelectedCountryRent;
            string start_date    = SessionHandler.MappingSelectedStartDate;

            System.Web.UI.WebControls.CheckBoxList checkBoxListModelDesc = (System.Web.UI.WebControls.CheckBoxList) this.ModelDescription.FindControl("CheckBoxListPopUp");
            checkBoxListModelDesc.DataTextField  = "ModelDescription";
            checkBoxListModelDesc.DataValueField = "ModelDescription";
            checkBoxListModelDesc.Items.Clear();
            checkBoxListModelDesc.DataSource = MappingsVehiclesLease.SelectModelsDescription(country_owner, country_rent, start_date);
            checkBoxListModelDesc.DataBind();
            foreach (ListItem item in checkBoxListModelDesc.Items)
            {
                item.Selected = false;
            }
            //Load the check box list settings
            this.ModelDescription.LoadCheckBoxList();
        }
Пример #35
0
 //CheckBoxList
 public void CheckBoxList_Bind(System.Web.UI.WebControls.CheckBoxList cklist, DataSet ds, int value, int text)
 {
     cklist.Items.Clear();//清空他的值
     if (ds == null)
     {
         return;
     }
     if (ds.Tables.Count == 0)
     {
         return;
     }
     for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
     {
         ListItem litem = new ListItem();
         litem.Text  = ds.Tables[0].Rows[i][text].ToString().Trim();
         litem.Value = ds.Tables[0].Rows[i][value].ToString().Trim();
         cklist.Items.Add(litem);
     }
 }
Пример #36
0
        protected int UpdateUserRoles(string racfid)
        {
            int result = -1;

            System.Web.UI.WebControls.CheckBoxList dropDownListRoles = (System.Web.UI.WebControls.CheckBoxList) this.MultiSelectDropDownListRoles.FindControl("ListBoxMultiSelect");
            string roleId         = null;
            string countryValue   = null;
            int    delimiterIndex = -1;

            //Delete Current roles for user
            Roles.DeleteUserRoles(racfid);

            // Insert roles for user
            foreach (var item in dropDownListRoles.Items.Cast <ListItem>().Where(d => d.Selected))
            {
                if (Convert.ToString(item.Value) == "1")
                {
                    //Administrator is selected
                    Users.UpdateUserRoles(racfid, 1, null);
                }
                else
                {
                    //Get role id and country from listbox
                    roleId         = Convert.ToString(item.Value);
                    delimiterIndex = roleId.IndexOf("|");
                    countryValue   = roleId.Remove(0, delimiterIndex + 1);
                    roleId         = roleId.Remove(delimiterIndex, roleId.Length - delimiterIndex);
                    //Update user roles
                    Users.UpdateUserRoles(racfid, Convert.ToInt32(roleId), countryValue);
                }
            }
            result = 0;

            //clear old cached roles and accessible countries
            string cacheKey = racfid + "Roles";

            MarsV2Cache.RemoveObjectFromCache(cacheKey);
            cacheKey = racfid + "Country";
            MarsV2Cache.RemoveObjectFromCache(cacheKey);

            return(result);
        }
        protected void Grid1_RowDataBound(object sender, ExtAspNet.GridRowEventArgs e)
        {
            AspNet.CheckBoxList cblHobby = (AspNet.CheckBoxList)Grid1.Rows[e.RowIndex].FindControl("cblHobby");

            DataRowView row = e.DataItem as DataRowView;

            string hobby = row["Hobby"].ToString() + ",";

            foreach (AspNet.ListItem item in cblHobby.Items)
            {
                if (hobby.Contains(item.Value + ","))
                {
                    item.Selected = true;
                }
                else
                {
                    item.Selected = false;
                }
            }
        }
Пример #38
0
        protected void btnGroupUpdate_Click(object sender, EventArgs e)
        {
            // 在操作之前进行权限检查
            if (!CheckPower("CoreRolePowerEdit"))
            {
                CheckPowerFailWithAlert();
                return;
            }

            int roleId = GetSelectedDataKeyID(Grid1);

            if (roleId == -1)
            {
                return;
            }

            // 当前角色新的权限列表
            List <int> newPowerIDs = new List <int>();

            for (int i = 0; i < Grid2.Rows.Count; i++)
            {
                AspNet.CheckBoxList ddlPowers = (AspNet.CheckBoxList)Grid2.Rows[i].FindControl("ddlPowers");
                foreach (AspNet.ListItem item in ddlPowers.Items)
                {
                    if (item.Selected)
                    {
                        newPowerIDs.Add(Convert.ToInt32(item.Value));
                    }
                }
            }


            Role role = DB.Roles.Include(r => r.Powers).Where(r => r.ID == roleId).FirstOrDefault();

            ReplaceEntities <Power>(role.Powers, newPowerIDs.ToArray());

            DB.SaveChanges();


            Alert.ShowInTop("当前角色的权限更新成功!");
        }
Пример #39
0
        public static void SetListValue(System.Web.UI.WebControls.CheckBoxList myListControl, object _Value)
        {
            int x = 0;

            myListControl.ClearSelection();
            if (myListControl.Items.Count == 1)
            {
                myListControl.SelectedIndex = 0;
            }
            else
            {
                foreach (ListItem _item in myListControl.Items)
                {
                    if (_Value.ToString().Substring(x, 1) == "1")
                    {
                        _item.Selected = true;
                    }
                    x++;
                }
            }
        }
Пример #40
0
 protected void btnGroupUpdate_Click(object sender, EventArgs e)
 {
     //更新权限
     if (!VerifyPurview(",SR-UPDATEMENU,"))
     {
         Alert.ShowInParent(CHECK_POWER_FAIL_ACTION_MESSAGE);
         return;
     }
     if (roleId > 0)
     {
         using (DataTable dt = new DataTable())
         {
             dt.Columns.Add("r_id", typeof(int));
             dt.Columns.Add("mpc_code", typeof(string));
             foreach (GridRow row in Grid2.Rows)
             {
                 AspNet.CheckBoxList cblPurviewCodes = (AspNet.CheckBoxList)Grid2.Rows[row.RowIndex].FindControl("cblPurviewCodes");
                 foreach (AspNet.ListItem item in cblPurviewCodes.Items)
                 {
                     if (item.Selected)
                     {
                         DataRow dr = dt.NewRow();
                         dr[0] = roleId;
                         dr[1] = item.Value;
                         dt.Rows.Add(dr);
                     }
                 }
             }
             int result = new PermBLL().BatchSave(dt, roleId);
             if (result > 0)
             {
                 Alert.ShowInParent("更新角色权限成功!", String.Empty, ActiveWindow.GetHideReference());
             }
             else
             {
                 Alert.ShowInParent("更新角色权限失败");
             }
         }
     }
 }
Пример #41
0
        /// <summary>
        /// 返回选中CheckBoxList的string[]数组
        /// </summary>
        /// <param name="chklst">CheckBoxList控件</param>
        /// <param name="textValue">返回Value</param>
        public static string GetSelectedList(System.Web.UI.WebControls.CheckBoxList chklst)
        {
            if (chklst.Items.Count == 0)
            {
                return(null);
            }
            string items = "";

            foreach (ListItem item in chklst.Items)
            {
                if (item.Selected)
                {
                    items += "," + item.Value;
                }
            }
            if (items == string.Empty)
            {
                return(null);
            }
            items = items.Substring(1);
            return(items);
        }
Пример #42
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            string        roleID          = hf_roleID.Value;
            List <string> permissionCodes = new List <string>();

            foreach (DataListItem item in DataListSysModule.Items)
            {
                System.Web.UI.WebControls.DataList dlChild = (DataList)item.FindControl("DataListChild");
                foreach (DataListItem dl in dlChild.Items)
                {
                    System.Web.UI.WebControls.CheckBoxList cbk = (CheckBoxList)dl.FindControl("Application_ID");
                    for (int i = 0; i < cbk.Items.Count; i++)
                    {
                        if (cbk.Items[i].Selected == true)
                        {
                            permissionCodes.Add(cbk.Items[i].Value);
                        }
                    }
                }
            }

            if (permissionCodes.Count > 0)
            {
                bool ok = BLL.Permission.AddRolePermission(roleID, permissionCodes);
                if (ok)
                {
                    Message.Success(this, "添加成功!", "null");
                }
                else
                {
                    Message.Alert(this, "添加失败!", "null");
                }
            }
            else
            {
                Message.Alert(this, "请选择菜单名称", "null");
                return;
            }
        }
Пример #43
0
        private void RolePermissionLoad(List <Model.Permission> list)
        {
            foreach (DataListItem item in DataListSysModule.Items)
            {
                System.Web.UI.WebControls.DataList dlChild = (DataList)item.FindControl("DataListChild");
                foreach (DataListItem dl in dlChild.Items)
                {
                    System.Web.UI.WebControls.CheckBoxList cbk = (CheckBoxList)dl.FindControl("Application_ID");
                    foreach (ListItem li in cbk.Items)
                    {
                        li.Selected = false;
                    }
                }
            }

            DataTable dt = new DataTable();

            foreach (var v in list)
            {
                foreach (var vv in v.Actions)
                {
                    foreach (DataListItem item in DataListSysModule.Items)
                    {
                        System.Web.UI.WebControls.DataList dlChild = (DataList)item.FindControl("DataListChild");
                        foreach (DataListItem dl in dlChild.Items)
                        {
                            System.Web.UI.WebControls.CheckBoxList cbk = (CheckBoxList)dl.FindControl("Application_ID");
                            for (int j = 0; j < cbk.Items.Count; j++)
                            {
                                if (cbk.Items[j].Value == vv.PermissionCode)
                                {
                                    cbk.Items[j].Selected = true;
                                }
                            }
                        }
                    }
                }
            }
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("<table style=\"width:350px;\"><tr><th>编号</th><th>姓名</th><th>用户输入的爱好</th></tr>");
            for (int i = 0, count = Grid1.Rows.Count; i < count; i++)
            {
                sb.Append("<tr>");
                object[] rowDataKeys = Grid1.DataKeys[i];
                sb.AppendFormat("<td>{0}</td>", rowDataKeys[0]);
                sb.AppendFormat("<td>{0}</td>", rowDataKeys[1]);

                GridRow             row      = Grid1.Rows[i];
                AspNet.CheckBoxList cblHobby = (AspNet.CheckBoxList)row.FindControl("cblHobby");
                sb.AppendFormat("<td>{0}</td>", GetHobbies(cblHobby));

                sb.Append("<tr>");
            }

            sb.Append("</table>");

            labResult.Text = sb.ToString();
        }
Пример #45
0
        public static void SetLists(System.Web.UI.WebControls.CheckBoxList myListControl, string operate, string userID, string Para1, string Para2, string Para3)
        {
            DataSet myData = myListReader(operate, userID, Para1, Para2, Para3);

            AssemblingList(myListControl, myData);
        }
Пример #46
0
 /// <summary>
 /// 获取复选列表的值  用,号隔开
 /// </summary>
 /// <param name="cblControls"></param>
 /// <returns></returns>
 public static string GetCheckBoxListSelectValue(System.Web.UI.WebControls.CheckBoxList cblControls)
 {
     return(GetCheckBoxListSelectValue(cblControls, ","));
 }
 private void RunDesignTimeTests()
 {
     try
     {
         this.Datagrid3.DataSource = WebControl_Style.m_dataSource;
         this.Datagrid4.DataSource = WebControl_Style.m_dataSource;
         this.Datalist3.DataSource = WebControl_Style.m_dataSource;
         this.Datalist4.DataSource = WebControl_Style.m_dataSource;
         this.Datagrid3.DataBind();
         this.Datagrid4.DataBind();
         this.Datalist3.DataBind();
         this.Datalist4.DataBind();
         GHTSubTest test1    = this.GHTSubTest24;
         WebControl control1 = this.Button2;
         this.AddAttributes(ref test1, ref control1);
         this.Button2      = (Button)control1;
         this.GHTSubTest24 = test1;
         test1             = this.GHTSubTest25;
         control1          = this.Checkbox2;
         this.AddAttributes(ref test1, ref control1);
         this.Checkbox2    = (CheckBox)control1;
         this.GHTSubTest25 = test1;
         test1             = this.GHTSubTest26;
         control1          = this.Hyperlink2;
         this.AddAttributes(ref test1, ref control1);
         this.Hyperlink2   = (HyperLink)control1;
         this.GHTSubTest26 = test1;
         test1             = this.GHTSubTest27;
         control1          = this.Image2;
         this.AddAttributes(ref test1, ref control1);
         this.Image2       = (Image)control1;
         this.GHTSubTest27 = test1;
         test1             = this.GHTSubTest28;
         control1          = this.Imagebutton2;
         this.AddAttributes(ref test1, ref control1);
         this.Imagebutton2 = (ImageButton)control1;
         this.GHTSubTest28 = test1;
         test1             = this.GHTSubTest29;
         control1          = this.Label2;
         this.AddAttributes(ref test1, ref control1);
         this.Label2       = (Label)control1;
         this.GHTSubTest29 = test1;
         test1             = this.GHTSubTest30;
         control1          = this.Linkbutton2;
         this.AddAttributes(ref test1, ref control1);
         this.Linkbutton2  = (LinkButton)control1;
         this.GHTSubTest30 = test1;
         test1             = this.GHTSubTest31;
         control1          = this.Panel2;
         this.AddAttributes(ref test1, ref control1);
         this.Panel2       = (Panel)control1;
         this.GHTSubTest31 = test1;
         test1             = this.GHTSubTest32;
         control1          = this.Radiobutton2;
         this.AddAttributes(ref test1, ref control1);
         this.Radiobutton2 = (RadioButton)control1;
         this.GHTSubTest32 = test1;
         test1             = this.GHTSubTest33;
         control1          = this.Textbox2;
         this.AddAttributes(ref test1, ref control1);
         this.Textbox2     = (TextBox)control1;
         this.GHTSubTest33 = test1;
         test1             = this.GHTSubTest34;
         control1          = this.Dropdownlist2;
         this.AddAttributes(ref test1, ref control1);
         this.Dropdownlist2 = (DropDownList)control1;
         this.GHTSubTest34  = test1;
         test1    = this.GHTSubTest35;
         control1 = this.Listbox2;
         this.AddAttributes(ref test1, ref control1);
         this.Listbox2     = (ListBox)control1;
         this.GHTSubTest35 = test1;
         test1             = this.GHTSubTest36;
         control1          = this.Radiobuttonlist2;
         this.AddAttributes(ref test1, ref control1);
         this.Radiobuttonlist2 = (RadioButtonList)control1;
         this.GHTSubTest36     = test1;
         test1    = this.GHTSubTest37;
         control1 = this.Checkboxlist2;
         this.AddAttributes(ref test1, ref control1);
         this.Checkboxlist2 = (CheckBoxList)control1;
         this.GHTSubTest37  = test1;
         test1    = this.GHTSubTest44;
         control1 = this.Datagrid3;
         this.AddAttributes(ref test1, ref control1);
         this.Datagrid3    = (DataGrid)control1;
         this.GHTSubTest44 = test1;
         test1             = this.GHTSubTest45;
         control1          = this.Datagrid4.Items[0];
         this.AddAttributes(ref test1, ref control1);
         this.GHTSubTest45 = test1;
         test1             = this.GHTSubTest46;
         control1          = this.Datalist3;
         this.AddAttributes(ref test1, ref control1);
         this.Datalist3    = (DataList)control1;
         this.GHTSubTest46 = test1;
         test1             = this.GHTSubTest47;
         control1          = this.Datalist4.Items[0];
         this.AddAttributes(ref test1, ref control1);
         this.GHTSubTest47 = test1;
         test1             = this.GHTSubTest48;
         control1          = this.Table4;
         this.AddAttributes(ref test1, ref control1);
         this.Table4       = (Table)control1;
         this.GHTSubTest48 = test1;
         test1             = this.GHTSubTest49;
         control1          = this.Table6;
         this.AddAttributes(ref test1, ref control1);
         this.Table6       = (Table)control1;
         this.GHTSubTest49 = test1;
         test1             = this.GHTSubTest50;
         control1          = this.Table7;
         this.AddAttributes(ref test1, ref control1);
         this.Table7       = (Table)control1;
         this.GHTSubTest50 = test1;
         test1             = this.GHTSubTest51;
         control1          = this.Table8;
         this.AddAttributes(ref test1, ref control1);
         this.Table8       = (Table)control1;
         this.GHTSubTest51 = test1;
     }
     catch (Exception exception2)
     {
         // ProjectData.SetProjectError(exception2);
         Exception exception1 = exception2;
         this.GHTSubTestBegin();
         this.GHTSubTestUnexpectedExceptionCaught(exception1);
         this.GHTSubTestEnd();
         // ProjectData.ClearProjectError();
     }
 }
Пример #48
0
 public static void SetLists(System.Web.UI.WebControls.CheckBoxList myListControl, DataSet myData)
 {
     AssemblingList(myListControl, myData);
 }
Пример #49
0
    public void ReadStateFromFile(Page AspNetPage, ControlCollection MyControlCollection)
    {
        //  intentamos leer el archivo que corresponde a la p�gina y usuario para rescatar el state
        if (((_UserName == "") || (_PageName == "")))
        {
            return;
        }
        string fileName = string.Concat(_PageName, "-", _UserName);
        string filePath = HttpContext.Current.Server.MapPath(("~/keepstatefiles/" + fileName));
        string contents = "";

        try
        {
            contents = File.ReadAllText(filePath);
        }
        catch (Exception ex)
        {
        }
        if ((contents == ""))
        {
            return;
        }
        string[] splitout = contents.Split('¦');
        foreach (string Split in splitout)
        {
            int nPosSignoIgual = Split.IndexOf("=");
            if ((nPosSignoIgual > 0))
            {
                string sNombreControl = Split.Substring(0, nPosSignoIgual);
                string sContenido     = Split.Substring((Split.Length + 1 - (Split.Length - nPosSignoIgual)));
                System.Web.UI.Control MyWebServerControl = FindControlRecursive(AspNetPage, sNombreControl);
                if ((MyWebServerControl == null))
                {
                    // TODO: Continue For... Warning!!! not translated
                    continue;
                }
                switch (MyWebServerControl.GetType().Name.ToString())
                {
                case "TextBox":
                    System.Web.UI.WebControls.TextBox MyWebControlTextBox =
                        (System.Web.UI.WebControls.TextBox)MyWebServerControl;
                    //  este caso es f�cil pues el text box solo contiene un valor (ListBox puede tener
                    //  mucho items seleccionados)
                    MyWebControlTextBox.Text = sContenido;
                    break;

                case "CheckBox":
                    System.Web.UI.WebControls.CheckBox MyWebControlCheckbox =
                        (System.Web.UI.WebControls.CheckBox)MyWebServerControl;
                    if ((sContenido == "1"))
                    {
                        MyWebControlCheckbox.Checked = true;
                    }
                    else
                    {
                        MyWebControlCheckbox.Checked = false;
                    }
                    break;

                case "RadioButton":
                    System.Web.UI.WebControls.RadioButton MyWebControlRadioButton =
                        (System.Web.UI.WebControls.RadioButton)MyWebServerControl;
                    if ((sContenido == "1"))
                    {
                        MyWebControlRadioButton.Checked = true;
                    }
                    else
                    {
                        MyWebControlRadioButton.Checked = false;
                    }
                    break;

                case "ListBox":
                {
                    System.Web.UI.WebControls.ListBox MyWebControlListBox =
                        (System.Web.UI.WebControls.ListBox)MyWebServerControl;
                    string[] sArrayOfStrings = sContenido.Split(';');
                    foreach (string MyString in sArrayOfStrings)
                    {
                        foreach (ListItem MyListItem in MyWebControlListBox.Items)
                        {
                            if ((MyListItem.Text == MyString))
                            {
                                MyListItem.Selected = true;
                            }
                        }
                    }
                    break;
                }

                case "CheckBoxList":
                {
                    System.Web.UI.WebControls.CheckBoxList MyWebControlCheckBoxList = (System.Web.UI.WebControls.CheckBoxList)MyWebServerControl;
                    string[] sArrayOfStrings = sContenido.Split(';');
                    foreach (string MyString in sArrayOfStrings)
                    {
                        foreach (ListItem MyListItem in MyWebControlCheckBoxList.Items)
                        {
                            if ((MyListItem.Text == MyString))
                            {
                                MyListItem.Selected = true;
                            }
                        }
                    }
                    break;
                }

                case "DropDownList":
                    System.Web.UI.WebControls.DropDownList MyWebControlDropDownList =
                        (System.Web.UI.WebControls.DropDownList)MyWebServerControl;
                    MyWebControlDropDownList.SelectedValue = sContenido;
                    break;
                }
            }
        }
    }
Пример #50
0
        protected void BuildTemplate(ref MailMessage Message, ref string Template, ControlCollection ControlCollection)
        {
            Template = string.Empty;
            foreach (Control ctrl in ControlCollection)
            {
                if ((ctrl.ID != null) && ctrl.ID.StartsWith(FieldPrefix))
                {
                    string key   = string.Empty;
                    string value = string.Empty;

                    Type ctrlType = ctrl.GetType();

                    if ((ctrlType == typeof(TextBox)) || ctrlType.IsSubclassOf(typeof(TextBox)))
                    {
                        System.Web.UI.WebControls.TextBox txt = (System.Web.UI.WebControls.TextBox)ctrl;
                        key   = txt.ID.Substring(FieldPrefix.Length, txt.ID.Length - FieldPrefix.Length);
                        value = txt.Text.Trim();
                    }
                    else if (ctrlType == typeof(HiddenField))
                    {
                        HiddenField hdn = (HiddenField)ctrl;
                        key   = hdn.ID.Substring(FieldPrefix.Length, hdn.ID.Length - FieldPrefix.Length);
                        value = hdn.Value;
                    }
                    else if (ctrlType == typeof(DropDownList))
                    {
                        DropDownList ddl = (DropDownList)ctrl;
                        key   = ddl.ID.Substring(FieldPrefix.Length, ddl.ID.Length - FieldPrefix.Length);
                        value = ddl.SelectedValue;
                    }
                    else if (ctrlType == typeof(RadioButtonList))
                    {
                        RadioButtonList rbl = (RadioButtonList)ctrl;
                        key   = rbl.ID.Substring(FieldPrefix.Length, rbl.ID.Length - FieldPrefix.Length);
                        value = rbl.SelectedValue;
                    }
                    else if ((ctrlType == typeof(CheckBoxList)) || ctrlType.IsSubclassOf(typeof(CheckBoxList)))
                    {
                        System.Web.UI.WebControls.CheckBoxList chk = (System.Web.UI.WebControls.CheckBoxList)ctrl;
                        key = chk.ID.Substring(FieldPrefix.Length, chk.ID.Length - FieldPrefix.Length);
                        foreach (ListItem item in chk.Items)
                        {
                            if (item.Selected)
                            {
                                if (!string.IsNullOrEmpty(value))
                                {
                                    value += ", ";
                                }
                                value += item.Value;
                            }
                        }
                    }
                    else if (ctrlType == typeof(CheckBox))
                    {
                        CheckBox chk = (CheckBox)ctrl;
                        if (UseTextForCheckbox)
                        {
                            key = chk.Text;
                        }
                        else
                        {
                            key = chk.ID.Substring(FieldPrefix.Length, chk.ID.Length - FieldPrefix.Length);
                        }
                        value = "Não";
                        if (chk.Checked)
                        {
                            value = "Sim";
                        }
                    }
                    else if (ctrlType == typeof(ListBox))
                    {
                        ListBox lsb = (ListBox)ctrl;
                        key = lsb.ID.Substring(FieldPrefix.Length, lsb.ID.Length - FieldPrefix.Length);
                        foreach (ListItem item in lsb.Items)
                        {
                            if (item.Selected)
                            {
                                if (!string.IsNullOrEmpty(value))
                                {
                                    value += ", ";
                                }
                                value += item.Value;
                            }
                        }
                    }
                    else if (ctrlType == typeof(FileUpload))
                    {
                        FileUpload fup = (FileUpload)ctrl;
                        if (fup.HasFile)
                        {
                            Message.Attachments.Add(new System.Net.Mail.Attachment(fup.PostedFile.InputStream, System.IO.Path.GetFileName(fup.PostedFile.FileName)));
                        }
                    }

                    if (!string.IsNullOrEmpty(key))
                    {
                        string prepKey = Text.Strings.RemoveAccentuation(key).Replace(" ", "").ToLower();
                        Message.TemplateValues.Add(prepKey, value);
                        Template += "<p><strong>" + key + ":</strong> [[[" + prepKey + "]]]</p>" + Environment.NewLine;
                    }
                }

                if (ctrl.HasControls())
                {
                    BuildTemplate(ref Message, ref Template, ctrl.Controls);
                }
            }
        }
Пример #51
0
    private void RecorrerControles1(ControlCollection MyControlCollection)
    {
        foreach (System.Web.UI.Control MyWebServerControl in MyControlCollection)
        {
            string typeOfControl = MyWebServerControl.GetType().Name.ToString();

            if (!MyWebServerControl.HasControls() || MyWebServerControl.GetType().Name.ToString() == "CheckBoxList")
            {
                string controlName = MyWebServerControl.GetType().Name.ToString();
                switch (controlName)
                {
                case "TextBox":
                    System.Web.UI.WebControls.TextBox MyWebControlTextBox =
                        (System.Web.UI.WebControls.TextBox)MyWebServerControl;
                    if ((MyWebControlTextBox.Text != ""))
                    {
                        _ControlValues_String.Append((MyWebControlTextBox.ID.ToString() + ("="
                                                                                           + (MyWebControlTextBox.Text + "¦"))));
                    }
                    break;

                case "CheckBox":
                    System.Web.UI.WebControls.CheckBox MyWebControlCheckbox =
                        (System.Web.UI.WebControls.CheckBox)MyWebServerControl;
                    if (MyWebControlCheckbox.Checked)
                    {
                        _ControlValues_String.Append((MyWebControlCheckbox.ID.ToString() + ("=" + (1 + "¦"))));
                    }
                    else
                    {
                        _ControlValues_String.Append((MyWebControlCheckbox.ID.ToString() + ("=" + (0 + "¦"))));
                    }
                    break;

                case "RadioButton":
                    System.Web.UI.WebControls.RadioButton MyWebControlRadioButton =
                        (System.Web.UI.WebControls.RadioButton)MyWebServerControl;
                    if (MyWebControlRadioButton.Checked)
                    {
                        _ControlValues_String.Append((MyWebControlRadioButton.ID.ToString() + ("=" + (1 + "¦"))));
                    }
                    else
                    {
                        _ControlValues_String.Append((MyWebControlRadioButton.ID.ToString() + ("=" + (0 + "¦"))));
                    }
                    break;

                case "ListBox":
                    System.Web.UI.WebControls.ListBox MyWebControlListBox =
                        (System.Web.UI.WebControls.ListBox)MyWebServerControl;
                    if ((MyWebControlListBox.SelectedIndex > -1))
                    {
                        bool bFirstItem = true;
                        foreach (int Index in MyWebControlListBox.GetSelectedIndices())
                        {
                            if (bFirstItem)
                            {
                                _ControlValues_String.Append((MyWebControlListBox.ID.ToString() + ("=" + MyWebControlListBox.Items[Index].Text)));
                                bFirstItem = false;
                            }
                            else
                            {
                                _ControlValues_String.Append((";" + MyWebControlListBox.Items[Index].Text));
                                bFirstItem = false;
                            }
                        }
                        if (!bFirstItem)
                        {
                            _ControlValues_String.Append("¦");
                        }
                    }
                    break;

                case "CheckBoxList":
                    System.Web.UI.WebControls.CheckBoxList MyWebControlCheckBoxList =
                        (System.Web.UI.WebControls.CheckBoxList)MyWebServerControl;
                    if ((MyWebControlCheckBoxList.SelectedIndex > -1))
                    {
                        bool bFirstItem = true;

                        for (int i = 0; i < MyWebControlCheckBoxList.Items.Count; i++)
                        {
                            if (MyWebControlCheckBoxList.Items[i].Selected)
                            {
                                if (bFirstItem)
                                {
                                    _ControlValues_String.Append((MyWebControlCheckBoxList.ID.ToString() + ("=" + MyWebControlCheckBoxList.Items[i].Text)));
                                    bFirstItem = false;
                                }
                                else
                                {
                                    _ControlValues_String.Append((";" + MyWebControlCheckBoxList.Items[i].Text));
                                    bFirstItem = false;
                                }
                            }
                        }
                        if (!bFirstItem)
                        {
                            _ControlValues_String.Append("¦");
                        }
                    }
                    break;

                case "DropDownList":
                    System.Web.UI.WebControls.DropDownList MyWebControlDropDownList =
                        (System.Web.UI.WebControls.DropDownList)MyWebServerControl;
                    //  nuestra convenci�n es que un DropDownList cuyo valor
                    //  seleccionado es -1, 'no est� seleccionado'. La raz�n de
                    //  esto es que en Asp.Net un DropDownList SIEMPRE est�
                    //  seleccionado (!).
                    if (((MyWebControlDropDownList.SelectedIndex > -1) &&
                         (((string)(MyWebControlDropDownList.SelectedItem.Value)) != "-1")))
                    {
                        _ControlValues_String.Append((MyWebControlDropDownList.ID.ToString() + ("="
                                                                                                + (MyWebControlDropDownList.SelectedValue + "¦"))));
                    }
                    break;
                }
            }
            else
            {
                //  en el control collection vienen Panels y web controls que
                //  a su vez, contienen controls.
                RecorrerControles0(MyWebServerControl.Controls);
            }
        }
    }
Пример #52
0
 /// <summary>
 /// 设置复选框列表的值 用,号隔开
 /// </summary>
 /// <param name="cblControls"></param>
 /// <param name="strValue"></param>
 public static void SetGetCheckBoxListSelectValue(System.Web.UI.WebControls.CheckBoxList cblControls, string strValue)
 {
     SetGetCheckBoxListSelectValue(cblControls, strValue, ",");
 }
Пример #53
0
        /// <summary>
        /// CheckBoxList快速绑定

        /// </summary>
        /// <param name="ddlControls">cbl控件</param>
        /// <param name="dt">DataTable表</param>
        /// <param name="strName">要绑定的Text列</param>
        /// <param name="strValue">要绑定的Value列</param>
        public static void CheckBoxListBind(System.Web.UI.WebControls.CheckBoxList cblControls, DataTable dt, string strName, string strValue)
        {
            CheckBoxListBind(cblControls, dt, strName, strValue, true);
        }
Пример #54
0
        /// <summary>
        /// 将查询的结果绑定到指定的DropDownList中,
        /// </summary>
        /// <param name="strText">DropDownList中前台列表中显示的文字所对应的字段</param>
        /// <param name="strValue">DropDownList中后台对应的值所对应的字段</param>
        /// <param name="strSqlPra">获得绑定内容的查询语句</param>
        /// <param name="drop_TobeBundled">待绑定的DropDownList控件</param>
        /// <returns>返回绑定结果,成功则为true</returns>
        public static bool BindList(string strText, string strValue, string strSqlPra, System.Web.UI.WebControls.CheckBoxList drop_TobeBundled)
        {
            try
            {
                string strSql = strSqlPra;

                MyDataOp mdo = new MyDataOp(strSql);
                DataSet  ds  = mdo.CreateDataSet();
                drop_TobeBundled.DataTextField  = strText;
                drop_TobeBundled.DataValueField = strValue;
                drop_TobeBundled.DataSource     = ds;
                drop_TobeBundled.DataBind();
                return(true);
            }
            catch
            {
                return(false);
            }
        }
Пример #55
0
    /// <summary>
    ///		This method binds a drop down list to a given DataSet
    /// </summary>
    /// <param name="textField">
    ///		Field from the datasource to use for the option text
    /// </param>
    /// <param name="valueField">
    ///		Field from the datasource to use for the option value
    /// </param>
    /// <param name="dsDataSet">
    ///		DataSource
    /// </param>
    /// <param name="dropDownListID">
    ///		Name of the Drop down list
    /// </param>
    public void BindCheckList(string textField, string valueField, DataSet dsDataSet, System.Web.UI.WebControls.CheckBoxList checkBoxListID)
    {
        try
        {
            checkBoxListID.DataSource = dsDataSet.Tables[0];
            //set DataTextField property only if it is not null
            if (null != textField)
            {
                checkBoxListID.DataTextField = textField;
            }
            //set DataValueField property only if it is not null
            if (null != valueField)
            {
                checkBoxListID.DataValueField = valueField;
            }
            checkBoxListID.DataBind();
        }

        catch (Exception ex)
        {
            throw ex;
        }
        finally
        {
        }
    }
 private void RunDesignTimeTests()
 {
     try
     {
         this.DataGrid1.DataSource = WebControl_Attributes.m_dataSource;
         this.DataGrid2.DataSource = WebControl_Attributes.m_dataSource;
         this.DataList1.DataSource = WebControl_Attributes.m_dataSource;
         this.DataList2.DataSource = WebControl_Attributes.m_dataSource;
         this.DataGrid1.DataBind();
         this.DataGrid2.DataBind();
         this.DataList1.DataBind();
         this.DataList2.DataBind();
         GHTSubTest test1    = this.GHTSubTest25;
         WebControl control1 = this.Button1;
         this.AddAttributes(ref test1, ref control1);
         this.Button1      = (Button)control1;
         this.GHTSubTest25 = test1;
         test1             = this.GHTSubTest26;
         control1          = this.CheckBox1;
         this.AddAttributes(ref test1, ref control1);
         this.CheckBox1    = (CheckBox)control1;
         this.GHTSubTest26 = test1;
         test1             = this.GHTSubTest28;
         control1          = this.HyperLink1;
         this.AddAttributes(ref test1, ref control1);
         this.HyperLink1   = (HyperLink)control1;
         this.GHTSubTest28 = test1;
         test1             = this.GHTSubTest30;
         control1          = this.Image1;
         this.AddAttributes(ref test1, ref control1);
         this.Image1       = (Image)control1;
         this.GHTSubTest30 = test1;
         test1             = this.GHTSubTest32;
         control1          = this.ImageButton1;
         this.AddAttributes(ref test1, ref control1);
         this.ImageButton1 = (ImageButton)control1;
         this.GHTSubTest32 = test1;
         test1             = this.GHTSubTest34;
         control1          = this.Label1;
         this.AddAttributes(ref test1, ref control1);
         this.Label1       = (Label)control1;
         this.GHTSubTest34 = test1;
         test1             = this.GHTSubTest36;
         control1          = this.LinkButton1;
         this.AddAttributes(ref test1, ref control1);
         this.LinkButton1  = (LinkButton)control1;
         this.GHTSubTest36 = test1;
         test1             = this.GHTSubTest37;
         control1          = this.Panel1;
         this.AddAttributes(ref test1, ref control1);
         this.Panel1       = (Panel)control1;
         this.GHTSubTest37 = test1;
         test1             = this.GHTSubTest38;
         control1          = this.RadioButton1;
         this.AddAttributes(ref test1, ref control1);
         this.RadioButton1 = (RadioButton)control1;
         this.GHTSubTest38 = test1;
         test1             = this.GHTSubTest39;
         control1          = this.TextBox1;
         this.AddAttributes(ref test1, ref control1);
         this.TextBox1     = (TextBox)control1;
         this.GHTSubTest39 = test1;
         test1             = this.GHTSubTest40;
         control1          = this.DropDownList1;
         this.AddAttributes(ref test1, ref control1);
         this.DropDownList1 = (DropDownList)control1;
         this.GHTSubTest40  = test1;
         test1    = this.GHTSubTest41;
         control1 = this.ListBox1;
         this.AddAttributes(ref test1, ref control1);
         this.ListBox1     = (ListBox)control1;
         this.GHTSubTest41 = test1;
         test1             = this.GHTSubTest42;
         control1          = this.RadioButtonList1;
         this.AddAttributes(ref test1, ref control1);
         this.RadioButtonList1 = (RadioButtonList)control1;
         this.GHTSubTest42     = test1;
         test1    = this.GHTSubTest43;
         control1 = this.CheckBoxList1;
         this.AddAttributes(ref test1, ref control1);
         this.CheckBoxList1 = (CheckBoxList)control1;
         this.GHTSubTest43  = test1;
         test1    = this.GHTSubTest50;
         control1 = this.DataGrid1;
         this.AddAttributes(ref test1, ref control1);
         this.DataGrid1    = (DataGrid)control1;
         this.GHTSubTest50 = test1;
         test1             = this.GHTSubTest51;
         control1          = this.DataGrid2.Items[0];
         this.AddAttributes(ref test1, ref control1);
         this.GHTSubTest51 = test1;
         test1             = this.GHTSubTest52;
         control1          = this.DataList1;
         this.AddAttributes(ref test1, ref control1);
         this.DataList1    = (DataList)control1;
         this.GHTSubTest52 = test1;
         test1             = this.GHTSubTest53;
         control1          = this.DataList2.Items[0];
         this.AddAttributes(ref test1, ref control1);
         this.GHTSubTest53 = test1;
         test1             = this.GHTSubTest54;
         control1          = this.Table1;
         this.AddAttributes(ref test1, ref control1);
         this.Table1       = (Table)control1;
         this.GHTSubTest54 = test1;
         test1             = this.GHTSubTest55;
         control1          = this.Table5;
         this.AddAttributes(ref test1, ref control1);
         this.Table5       = (Table)control1;
         this.GHTSubTest55 = test1;
         test1             = this.GHTSubTest56;
         control1          = this.Table2;
         this.AddAttributes(ref test1, ref control1);
         this.Table2       = (Table)control1;
         this.GHTSubTest56 = test1;
         test1             = this.GHTSubTest57;
         control1          = this.Table3;
         this.AddAttributes(ref test1, ref control1);
         this.Table3       = (Table)control1;
         this.GHTSubTest57 = test1;
     }
     catch (Exception exception2)
     {
         // ProjectData.SetProjectError(exception2);
         Exception exception1 = exception2;
         this.GHTSubTestBegin();
         string text1 = string.Empty + exception1.GetType().ToString();
         text1 = text1 + " caught during preperations for design time tests.";
         text1 = text1 + "<br>Message: ";
         text1 = text1 + exception1.Message;
         text1 = text1 + "<br>Trace: ";
         text1 = text1 + exception1.StackTrace;
         this.GHTSubTestAddResult(text1);
         this.GHTSubTestEnd();
         // ProjectData.ClearProjectError();
     }
 }