selectlistitem

Strongly typed view with a SelectList for DropDownList via ViewData: type mismatch on submit

我是研究僧i 提交于 2020-01-22 15:14:50
问题 I am trying to create a form in ASP.NET MVC2 RC 2 that is based on a calendar event object. The object has eventTypeId which is a System.Int32 that I need to populate with via a select list. The controller to create the initial view is: [WAuthorize] public ActionResult AddCalendarEvent() { CalendarEventTypesManager calendarEventTypesManager = new CalendarEventTypesManager(); ViewData["eventTypeId"] = new SelectList( calendarEventTypesManager.SelectAll(), "Id", "Type"); return View(); } The

Strongly typed view with a SelectList for DropDownList via ViewData: type mismatch on submit

霸气de小男生 提交于 2020-01-22 15:13:52
问题 I am trying to create a form in ASP.NET MVC2 RC 2 that is based on a calendar event object. The object has eventTypeId which is a System.Int32 that I need to populate with via a select list. The controller to create the initial view is: [WAuthorize] public ActionResult AddCalendarEvent() { CalendarEventTypesManager calendarEventTypesManager = new CalendarEventTypesManager(); ViewData["eventTypeId"] = new SelectList( calendarEventTypesManager.SelectAll(), "Id", "Type"); return View(); } The

Html.DropDownListFor does not bind boolean SelectList

泪湿孤枕 提交于 2020-01-05 08:09:32
问题 I have this code the constructs a select list as a boolean response var responseList = new List<SelectListItem>(); responseList.Add(new SelectListItem { Text = "Going", Value = bool.TrueString}); responseList.Add(new SelectListItem { Text = "Not Going", Value = bool.FalseString }); ViewData[ViewDataKeys.ResponseTo] = vatOptionList; In my view I use the dropdownlist helper below. @Html.DropDownListFor(m => m.ResponseTo, (IEnumerable<SelectListItem>)ViewData[ViewDataKeys.ResponseTo], "--Select-

How to highlight the selected item of long list selector in windows phone 8

安稳与你 提交于 2020-01-05 08:06:12
问题 I've developed Windows Phone 8 application. In that I'm using the Long list selector to display items in the list. Everything is fine up till now. When the user clicks on any item of long list selector, I want to highlight that item's background color, so that the user clearly understands that he/she has selected an item. Could you please tell me how to do this in windows phone 8. I'm looking forward for the response. 回答1: http://code.msdn.microsoft.com/wpapps/Highlight-a-selected-item

How to highlight the selected item of long list selector in windows phone 8

落爺英雄遲暮 提交于 2020-01-05 08:04:10
问题 I've developed Windows Phone 8 application. In that I'm using the Long list selector to display items in the list. Everything is fine up till now. When the user clicks on any item of long list selector, I want to highlight that item's background color, so that the user clearly understands that he/she has selected an item. Could you please tell me how to do this in windows phone 8. I'm looking forward for the response. 回答1: http://code.msdn.microsoft.com/wpapps/Highlight-a-selected-item

SelectListItem not setting via dropdown after extending SelectList class

二次信任 提交于 2020-01-03 06:09:14
问题 I am trying to extend the SelectListItem class to add another property called CardColor. However when I try to access the property in my controller I get NullReferenceException: Object reference not set to an instance of an object.... return View("StringView", c.IssueSelected.CardColor); Controller: [HttpPost] public async Task<ActionResult> CardCreate(UpdateCardFormOptions c) { return View("StringView", c.IssueSelected.CardColor); } View @using (@Html.BeginForm()) { <p><label>Issue Category*

SelectListItem not setting via dropdown after extending SelectList class

旧城冷巷雨未停 提交于 2020-01-03 06:08:49
问题 I am trying to extend the SelectListItem class to add another property called CardColor. However when I try to access the property in my controller I get NullReferenceException: Object reference not set to an instance of an object.... return View("StringView", c.IssueSelected.CardColor); Controller: [HttpPost] public async Task<ActionResult> CardCreate(UpdateCardFormOptions c) { return View("StringView", c.IssueSelected.CardColor); } View @using (@Html.BeginForm()) { <p><label>Issue Category*

The ViewData item that has the key 'CategoryId' is of type 'System.Int32' but must be of type 'IEnumerable<SelectListItem>'.

夙愿已清 提交于 2019-12-24 16:56:08
问题 Can you please help with the error below? What is wrong with my codes. Thanks for your help. Error: The ViewData item that has the key 'CategoryId' is of type 'System.Int32' but must be of type 'IEnumerable'. controller public ActionResult ProductCreate() { ViewBag.Suppliers = db.Suppliers.Where(x => x.IsActive).ToList(); ViewBag.Categories = new SelectList(db.Categories.Where(x => x.IsActive).ToList(), "Id", "Name").ToList(); return View(); } [HttpPost] [ValidateAntiForgeryToken] public

The ViewData item that has the key 'CategoryId' is of type 'System.Int32' but must be of type 'IEnumerable<SelectListItem>'.

白昼怎懂夜的黑 提交于 2019-12-24 16:55:03
问题 Can you please help with the error below? What is wrong with my codes. Thanks for your help. Error: The ViewData item that has the key 'CategoryId' is of type 'System.Int32' but must be of type 'IEnumerable'. controller public ActionResult ProductCreate() { ViewBag.Suppliers = db.Suppliers.Where(x => x.IsActive).ToList(); ViewBag.Categories = new SelectList(db.Categories.Where(x => x.IsActive).ToList(), "Id", "Name").ToList(); return View(); } [HttpPost] [ValidateAntiForgeryToken] public

Asp.net mvc select list

狂风中的少年 提交于 2019-12-21 20:34:00
问题 I need to create a select list, preserving the state, which is not part of the model passed to the view. I suppose I should be using a ViewBag to pass a List to the View ? Any advise on implementation and how to preserve the state of the select list (how do I pass the selected value back to action and to the view again (possible ways of doing this) ? The Action as of now: public ActionResult Images(string x, string y) { //some code ContentPage cp = this.ContentPage; return View(cp); } //Post