本文整理汇总了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();
}
示例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);
}
示例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);
}
示例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;
}
}
示例5: ArticleModel
public ArticleModel() : base()
{
SubTitle = "Holy Angels Article(s)";
PageTitle = "Articles";
Ministries = new List<MinistryModel>();
MultiSelectMinistryList = new MultiSelectList(new List<MinistryModel>());
}
示例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());
}
示例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;
}
示例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");
}
示例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[] { };
}
示例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);
}
示例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;
}
示例12: MinistryModel
public MinistryModel() : base()
{
PageTitle = "Holy Angels Ministries";
SubTitle = "Ministries";
Users = new List<UserModel>();
MultiSelectUserList = new MultiSelectList(new List<UserModel>());
}
示例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);
}
示例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>());
}
示例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);
}