Esempio n. 1
0
 public static void FillToListBox(ListItemCollection lstItems, DataTable source, int rootId, bool superUser)
 {
     DataRow[] drCommands = source.Select("CommandParentID = " + rootId);
     foreach(DataRow row in drCommands)
     {
         if (!superUser && (bool)row["IsSuperUser"]) continue;
         ListItem rootItem = new ListItem(row["CommandName"].ToString(), row["CommandID"].ToString());
         rootItem.Attributes.Add("Level","0");
         lstItems.Add(rootItem);
         LoadForCurListItem(lstItems, rootItem, source, superUser);
     }
     lstItems.Insert(0, new ListItem("Root","0"));
 }
Esempio n. 2
0
 /// <summary>
 /// 绑定控件的ListItem项
 /// </summary>
 /// <param name="LIC"></param>
 /// <param name="IsFistNull"></param>
 public void InitListItems(ListItemCollection LIC, bool IsFistNull)
 {
     if (LIC.Count > 0)
     {
         LIC.Clear();
     }
     Hashtable ht = GetTextValue();
     foreach (DictionaryEntry de in ht)
     {
         LIC.Add(new ListItem(de.Value.ToString(), de.Key.ToString()));
     }
     if (IsFistNull)
     {
         LIC.Insert(0, "");
     }
 }
        private void LoadEmailTemplateItems(string templateUrl, string selectedValue)
        {
            try
            {
                txtTemplateName.Items.Clear();
                ListItemCollection DropdownListSource = new ListItemCollection();
                SPList list = Utility.GetListFromURL(templateUrl);
                SPQuery query = new SPQuery() { Query = "<OrderBy><FieldRef Name='Title' Ascending='True' /></OrderBy>" };

                SPListItemCollection items = list.GetItems(query);

                DropdownListSource.Insert(0, (new ListItem() { Text = "Select a template", Value = string.Empty }));
                foreach (SPListItem item in items)
                {
                    DropdownListSource.Add(new ListItem() { Text = item["Title"] as string, Value = item["Title"] as string });
                }
                if (DropdownListSource.Count > 0)
                {
                    BindDropDownSource(txtTemplateName, DropdownListSource);
                    if (string.IsNullOrEmpty(selectedValue))
                        txtTemplateName.Items[0].Selected = true;
                    else
                        txtTemplateName.SelectedValue = selectedValue;

                    //Load Extend DropDownList Source
                    if (AssociateControls != null)
                    {
                        foreach (DropDownList ddl in AssociateControls)
                        {
                            BindDropDownSource(ddl, DropdownListSource);
                        }
                    }
                }
            }
            catch
            {
                if (!string.IsNullOrEmpty(templateUrl) && allowNull == false)
                {
                    txtTemplateName.Items.Clear();
                    txtTemplateUrlValidator.ErrorMessage = "Cannot get email template from this url";
                    txtTemplateUrlValidator.IsValid = false;
                }
            }
        }
Esempio n. 4
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            if (!IsPostBack)
            {
                if (Model.Groups.Count > 0)
                {
                    groupList.DataSource = Model.Groups;
                    groupList.DataBind();
                    groupList.Items.Insert(0, new ListItem(Localization.GetString("None_Specified"), Null.NullInteger.ToString()));
                }
                else
                {
                    filterBySelector.Items.FindByValue("Group").Enabled = false;
                }

                foreach (var rel in Model.Relationships)
                {
                    relationShipList.AddItem(Localization.GetString(rel.Name, Localization.SharedResourceFile), rel.RelationshipId.ToString());
                }


                var profileResourceFile = "~/DesktopModules/Admin/Security/App_LocalResources/Profile.ascx";


                System.Web.UI.WebControls.ListItemCollection propertiesCollection = GetPropertiesCollection(profileResourceFile);


                //Bind the ListItemCollection to the list
                propertyList.DataSource = propertiesCollection;
                propertyList.DataBind();

                //Insert custom properties to the Search field lists
                propertiesCollection.Insert(0, new ListItem(Localization.GetString("Username", LocalResourceFile), "Username"));
                propertiesCollection.Insert(1, new ListItem(Localization.GetString("DisplayName", LocalResourceFile), "DisplayName"));
                propertiesCollection.Insert(2, new ListItem(Localization.GetString("Email", LocalResourceFile), "Email"));

                //Bind the properties collection in the Search Field Lists

                searchField1List.DataSource = propertiesCollection;
                searchField1List.DataBind();

                searchField2List.DataSource = propertiesCollection;
                searchField2List.DataBind();

                searchField3List.DataSource = propertiesCollection;
                searchField3List.DataBind();

                searchField4List.DataSource = propertiesCollection;
                searchField4List.DataBind();

                filterBySelector.Select(_filterBy, false, 0);

                switch (_filterBy)
                {
                case "Group":
                    groupList.Select(_filterValue, false, 0);
                    break;

                case "Relationship":
                    relationShipList.Select(_filterValue, false, 0);
                    break;

                case "ProfileProperty":
                    propertyList.Select(_filterValue, false, 0);
                    break;

                case "User":
                    break;
                }

                searchField1List.Select(GetTabModuleSetting("SearchField1", _defaultSearchField1));
                searchField2List.Select(GetTabModuleSetting("SearchField2", _defaultSearchField2));
                searchField3List.Select(GetTabModuleSetting("SearchField3", _defaultSearchField3));
                searchField4List.Select(GetTabModuleSetting("SearchField4", _defaultSearchField4));
            }
        }