当前位置: 首页>>代码示例>>C#>>正文


C# MultiSelectList类代码示例

本文整理汇总了C#中MultiSelectList的典型用法代码示例。如果您正苦于以下问题:C# MultiSelectList类的具体用法?C# MultiSelectList怎么用?C# MultiSelectList使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MultiSelectList类属于命名空间,在下文中一共展示了MultiSelectList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetLocationSelectedListItem

 public static void GetLocationSelectedListItem(IList<Location> locations, out MultiSelectList allLocation, out List<SelectListItem> selectListItems)
 {
     var multiSelectList = new MultiSelectList(locations, "LocationId", "Province", locations);
     allLocation = multiSelectList;
     selectListItems =
         locations.Select(o => new SelectListItem { Text = o.Province, Value = o.Province }).ToList();
 }
开发者ID:jzinedine,项目名称:Cedar,代码行数:7,代码来源:ControllerHelper.cs

示例2: Create

        public ActionResult Create([Bind(Include = "Name,LocationTypeId,CrimeTypeIds")]CrimeLocationTypeFormViewModel crimeLocationTypeForm)
        {
            if (ModelState.IsValid)
            {
                CrimeLocationTypeEntity crimeLocationTypeEntity = new CrimeLocationTypeEntity();
                crimeLocationTypeEntity.Name = crimeLocationTypeForm.Name;
                crimeLocationTypeEntity.LocationType = _locationTypeService.GetLocationTypeById(crimeLocationTypeForm.LocationTypeId);
                crimeLocationTypeEntity.LocationTypeId = crimeLocationTypeForm.LocationTypeId;
                crimeLocationTypeEntity.CrimeTypes = new List<CrimeTypeEntity>();
                foreach (var crimeTypeId in crimeLocationTypeForm.CrimeTypeIds)
                {
                    crimeLocationTypeEntity.CrimeTypes.Add(_crimeTypeService.GetCrimeTypeById(crimeTypeId));
                }

                _crimeLocationTypeService.CreateCrimeLocationType(crimeLocationTypeEntity);

                return RedirectToAction("Index");
            }

            List<LocationTypeEntity> dbLocationTypeModels = _locationTypeService.GetAllLocationTypes().ToList();
            List<CrimeTypeEntity> dbCrimeTypeModels = _crimeTypeService.GetAllCrimeTypes().ToList();

            ViewData["LocationTypes"] = new SelectList(dbLocationTypeModels, "LocationTypeId", "Name");
            ViewData["CrimeTypes"] = new MultiSelectList(dbCrimeTypeModels, "CrimeTypeId", "Name");

            return View(crimeLocationTypeForm);
        }
开发者ID:Joshhughes34,项目名称:FYP_webservice,代码行数:27,代码来源:CrimeLocationTypeController.cs

示例3: ArchitecturalStrategyViewModel

        public ArchitecturalStrategyViewModel(ArchitecturalStrategy strategy)
        {
            var scenarioRepository = new ScenarioRepository();
            var strategyRepository = new ArchitecturalStrategyRepository();
            Strategy = strategy;
            Strategy.Description = strategy.Description == null ? null : strategy.Description.Trim();

            AffiliatedScenarios = strategyRepository.GetAffiliatedScenariosByStratID(strategy.ID).OrderBy(x => x.Priority);

            //scenarios (in top 6th) not affiliated with strategy
            var slistNotUsed = scenarioRepository.GetTopSixth(strategy.ProjectID).OrderBy(x => x.Priority).ToList(); //new scenario
            if (strategy != null && strategy.ID !=0) //set used for existing scenario
            {
                slistNotUsed = scenarioRepository.GetTopSixth(strategy.ProjectID)
                    .Where(a => !Strategy.ExpectedUtilities.Select(x => x.Scenario.ID).Contains(a.ID)).OrderBy(x => x.Priority).ToList();
            }
            //scenarios affiliated with strategy
              //  var slistused = scenarioRepository.GetTopSixth(strategy.ProjectID)
              //                      .Where(a => strategy.ExpectedUtilities
              //                          .Select(x => x.ScenarioID). //Select Scenario IDs
            //                          Contains(a.ID)).ToList();   //a.ID =
               //needs to be list of availble scenarios, exclude already selected

                          //(theObjList, value, text to show, pre-SelectedItems)
            ScenarioSelectList = new MultiSelectList(slistNotUsed, "ID", "Name", strategy.ExpectedUtilities.Select(x => x.ScenarioID));
            ScenariosSelectedList = new MultiSelectList(AffiliatedScenarios, "ID", "Name", strategy.ExpectedUtilities.Select(x => x.ScenarioID));
            strategyForExpectedResponse = populateStrategyForExpectedResponse(strategy, AffiliatedScenarios);
        }
开发者ID:LMDarville,项目名称:CBAM,代码行数:28,代码来源:ArchitecturalStrategyViewModel.cs

示例4: FilterByTags

        public void FilterByTags(ViewDataDictionary viewData, int[] selectedTagsIds, IEnumerable<Tag> tags)
        {
            if (selectedTagsIds != null && selectedTagsIds[0] != 0)
            {
                var selectedTags = tags.Where(e => selectedTagsIds.Contains(e.TagID)).ToList();
                viewData["TagsFilter"] = new MultiSelectList(tags, "TagID", "Name", selectedTags);

                var tempConferences = new List<Conference>();
                foreach (var conference in Conferences)
                {
                    foreach (var selectedTagId in selectedTagsIds)
                    {
                        if (conference.Tags.Any(e => e.TagID == selectedTagId))
                        {
                            if (!tempConferences.Contains(conference))
                            {
                                tempConferences.Add(conference);
                            }
                        }
                    }
                }

                Conferences = tempConferences;
            }
        }
开发者ID:ewelinaolejnik,项目名称:ITConferences,代码行数:25,代码来源:FilterHelper.cs

示例5: ArticleModel

 public ArticleModel() : base()
 {
     SubTitle = "Holy Angels Article(s)";
     PageTitle = "Articles";
     Ministries = new List<MinistryModel>();
     MultiSelectMinistryList = new MultiSelectList(new List<MinistryModel>());
 }
开发者ID:kscott5,项目名称:HolyAngels,代码行数:7,代码来源:ArticleModel.cs

示例6: CheckBoxList

        public static MvcHtmlString CheckBoxList(this HtmlHelper htmlHelper, string name, MultiSelectList listInfo, IDictionary<string, object> htmlAttributes)
        {
            if (String.IsNullOrEmpty(name))
                throw new ArgumentException("The argument must have a value", "name");
            if (listInfo == null)
                throw new ArgumentNullException("listInfo");
            if (listInfo.Count() < 1)
                throw new ArgumentException("The list must contain at least one value", "listInfo");

            StringBuilder sb = new StringBuilder();

            foreach (SelectListItem info in listInfo)
            {
                TagBuilder builder = new TagBuilder("input");
                if (info.Selected) builder.MergeAttribute("checked", "checked");
                builder.MergeAttributes<string, object>(htmlAttributes);
                builder.MergeAttribute("type", "checkbox");
                builder.MergeAttribute("value", info.Value);
                builder.MergeAttribute("name", name);
                builder.InnerHtml = info.Text;
                sb.Append(builder.ToString(TagRenderMode.Normal));
                sb.Append("<br />");
            }
            return MvcHtmlString.Create(sb.ToString());
        }
开发者ID:anathan1,项目名称:ZergScheduler,代码行数:25,代码来源:HtmlHelpers.cs

示例7: MapUserRoles

        public UserRolesViewModel MapUserRoles(UserProfile user, IList<UserRole> roles)
        {
            if (user == null) return new UserRolesViewModel();
            var view = new UserRolesViewModel
                           {
                               FirstName = user.FirstName,
                               LastName = user.LastName,
                               UserName = user.UserName,
                               Roles = new List<RolesViewModel>()
                           };

            foreach (UserRole role in roles)
            {
                RolesViewModel roleView = Mapper.Map<UserRole, RolesViewModel>(role);
                foreach (UserRole userRole in user.Roles)
                {
                    roleView.IsChecked = userRole.Id == role.Id;

                }
                view.Roles.Add(roleView);

            }

            var selectRoles = new MultiSelectList(view.Roles, "RoleId", "RoleName",
                view.Roles
                .Where(x => x.IsChecked)
                .Select(x =>x.RoleId));

            view.MultiSelectRoles = selectRoles;

            return view;
        }
开发者ID:avington,项目名称:aviblog,代码行数:32,代码来源:UserProfileMappingService.cs

示例8: ClinicsList

        public ActionResult ClinicsList(string ID)
        {
            List<SelectListItem> listClinic = new List<SelectListItem>();
            if (ID == "ALL")
            {
                var itemsClinic = dbm.vwContract_Clinic_Analysis_ClinicMaterial_ForReports.Select(o => new { o.ClinicContractID, o.ClinicDesc, o.ClinicGroupDesc, o.ContractDesc }).Distinct().OrderBy(o => o.ContractDesc ).ToList();

                listClinic.Add(new SelectListItem { Text = "Все ЛПУ", Value = "ALL" });
                foreach (var item in itemsClinic)
                {
                    listClinic.Add(new SelectListItem { Text = item.ContractDesc + " - " + item.ClinicGroupDesc + " - " + item.ClinicDesc, Value = item.ClinicContractID.ToString() });
                }
            }
            else
            {
                var itemsClinic = dbm.vwContract_Clinic_Analysis_ClinicMaterial_ForReports.Where(o => o.ContractDesc == ID).Select(o => new { o.ClinicContractID, o.ClinicDesc, o.ClinicGroupDesc, o.ContractDesc  }).Distinct().OrderBy(o => o.ContractDesc ).ToList();

                listClinic.Add(new SelectListItem { Text = "Все ЛПУ", Value = "ALL" });
                foreach (var item in itemsClinic)
                {
                    listClinic.Add(new SelectListItem { Text = item.ContractDesc + " - " + item.ClinicGroupDesc + " - " + item.ClinicDesc, Value = item.ClinicContractID.ToString() });
                }
            }
            var selectClinic = new MultiSelectList(listClinic, "Value", "Text", "ALL");

            if (HttpContext.Request.IsAjaxRequest())
              return Json(selectClinic, JsonRequestBehavior.AllowGet);
            return RedirectToAction("Index");
        }
开发者ID:rymbln,项目名称:Spec_Soft,代码行数:29,代码来源:ReportController.cs

示例9: IndexViewModel

        public IndexViewModel()
        {
            ConsentValidFromStart = new OptionalDateInputViewModel(allowPastDates: true, showLabels: false);
            ConsentValidFromEnd = new OptionalDateInputViewModel(allowPastDates: true, showLabels: false);
            ConsentValidToStart = new OptionalDateInputViewModel(allowPastDates: true, showLabels: false);
            ConsentValidToEnd = new OptionalDateInputViewModel(allowPastDates: true, showLabels: false);
            NotificationReceivedStart = new OptionalDateInputViewModel(allowPastDates: true, showLabels: false);
            NotificationReceivedEnd = new OptionalDateInputViewModel(allowPastDates: true, showLabels: false);
            NotificationTypes = new SelectList(EnumHelper.GetValues(typeof(NotificationType)), dataTextField: "Value", dataValueField: "Key");
            TradeDirections = new SelectList(EnumHelper.GetValues(typeof(TradeDirection)), dataTextField: "Value", dataValueField: "Key");
            InterimStatus = new SelectList(new[]
            {
                new SelectListItem
                {
                    Text = "Interim",
                    Value = "true"
                },
                new SelectListItem
                {
                    Text = "Non-interim",
                    Value = "false"
                }
            }, dataTextField: "Text", dataValueField: "Value");
            OperationCodes = new MultiSelectList(EnumHelper.GetValues(typeof(OperationCode)), dataTextField: "Value", dataValueField: "Key");

            NotificationStatuses = new SelectList(GetCombinedNotificationStatuses(), dataTextField: "Name", dataValueField: "StatusId", dataGroupField: "TradeDirection", selectedValue: null);

            SelectedOperationCodes = new OperationCode[] { };
        }
开发者ID:EnvironmentAgency,项目名称:prsd-iws,代码行数:29,代码来源:IndexViewModel.cs

示例10: Edit

        public ActionResult Edit(string id)
        {
            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            var user = UserManager.FindById(id);
            if (user == null)
            {
                return HttpNotFound();
            }
        
            var db = new ApplicationDbContext();

            var userx = new UserViewModel
            {
                BranchId = user.BranchId,
                Name = user.UserName,
                Roles = user.Roles.Select(p => p.Role.Name).ToList(),
                AvailableRoles =  db.Roles.ToList()
            };

            var m = new MultiSelectList(db.Roles.ToList(), "Name", "Name");
            ViewBag.Roles = m;

            var x = new SelectList(db.Branches.ToList(), "Id", "Name");
            ViewBag.Branches = x;
            return View(userx);
            


        }
开发者ID:dwi-tanto-p,项目名称:Cashflow,代码行数:32,代码来源:AccountController.cs

示例11: SetPreferenceControl

        /// <summary>Generate a control for a set preference.</summary>
        private static string SetPreferenceControl(HtmlHelper helper, MetaAttribute ma, Preference preference)
        {
            string result;

            if (ma.HasChoices)
            {
                if (preference != null)
                {
                    MultiSelectList listData = new MultiSelectList(SelectHelper.DropDownRecordsFromValueSet(ma.ChoicesCollection), "Value", "Text",
                        SelectHelper.ValuesFromValueSet(preference.Set));
                    result = helper.ListBox(ma.PreferenceSetControlName, listData);
                }
                else
                {
                    MultiSelectList listData = new MultiSelectList(SelectHelper.DropDownRecordsFromValueSet(ma.ChoicesCollection), "Value", "Text");
                    result = helper.ListBox(ma.PreferenceSetControlName, listData);
                }
            }
            else
            {
                if (preference != null)
                {
                    result = helper.TextBox(ma.PreferenceSetControlName, preference.RawValues);
                }
                else
                {
                    result = helper.TextBox(ma.PreferenceSetControlName);
                }
            }
            return result;
        }
开发者ID:liammclennan,项目名称:Herald,代码行数:32,代码来源:BuyerHelper.cs

示例12: MinistryModel

 public MinistryModel() : base()
 {
     PageTitle = "Holy Angels Ministries";
     SubTitle = "Ministries";
     Users = new List<UserModel>();
     MultiSelectUserList = new MultiSelectList(new List<UserModel>());
 }
开发者ID:kscott5,项目名称:HolyAngels,代码行数:7,代码来源:MinistryModel.cs

示例13: Create

 public ActionResult Create()
 {
     var newEmployee = new Employee();
     ViewData["Projects"] = new MultiSelectList(_employeeService.GetAllProjects(), "ProjectId", "ProjectName");
     ViewData["Skills"] = new MultiSelectList(_employeeService.GetAllSkillSets(), "SkillSetId", "Name");
     //ViewBag.Skills = new MultiSelectList(_employeeService.GetAllRoles(), "Id", "Name");
     return View(newEmployee);
 }
开发者ID:abhijitrane,项目名称:EmployeeFinder,代码行数:8,代码来源:EmployeeController.cs

示例14: UserModel

        public UserModel()
        {
            UserStatus = UserStatus.Offline;
            Roles = new List<RoleModel>();
            Ministries = new List<MinistryModel>();

            MultiSelectRoleList = new MultiSelectList(new List<RoleModel>());
            MultiSelectMinistryList = new MultiSelectList(new List<MinistryModel>());
        }
开发者ID:kscott5,项目名称:HolyAngels,代码行数:9,代码来源:UserModel.cs

示例15: GetListItemsThrowsOnBindingFailure

        public void GetListItemsThrowsOnBindingFailure() {
            // Arrange
            MultiSelectList multiSelect = new MultiSelectList(GetSampleFieldObjects(),
                "Text", "Value", new string[] { "A", "C", "T" });

            // Assert
            ExceptionHelper.ExpectHttpException(
                delegate {
                    IList<SelectListItem> listItems = multiSelect.GetListItems();
                }, "DataBinding: 'System.Web.Mvc.Test.MultiSelectListTest+Item' does not contain a property with the name 'Text'.", 500);
        }
开发者ID:ledgarl,项目名称:Samples,代码行数:11,代码来源:MultiSelectListTest.cs


注:本文中的MultiSelectList类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。