html.dropdownlistfor

How to populate the dropdown list from sql server database using LinkedHashMap in java

北战南征 提交于 2019-12-02 03:32:00
In SQL Server database I have a table which has three columns namely Ref_Name,Ref_from and Ref_to.Now I want a dropdown list to hold values row-wise i.e all column values of the row should be in the dropdown list in following way:- Reference-1(2014-10-10 07:17:00.000 to 2014-10-10 08:46:00.000) Reference-2(2014-09-01 10:00:00.000 to 2014-09-01 11:00:00.000) For this I have used LinkedHashMap as:- public LinkedHashMap<String, List<String>> connect() { ArrayList<String> list = new ArrayList<String>(); try { con = getConnection(); stmt = con.createStatement(); String sql="select Ref_No,From_Date

Problem with DropDownListFor SelectedItem

旧时模样 提交于 2019-12-01 22:13:05
问题 This has totally puzzled me. Here's my View: @Html.DropDownListFor(model => model.ScoreDescription, Model.RatingOptions, "--", new { @id = clientId }) And the model: public decimal? Score { get; set; } public SelectList RatingOptions { get { var options = new List<SelectListItem>(); for (var i = 1; i <= 5; i++) { options.Add(new SelectListItem { Selected = Score.HasValue && Score.Value == Convert.ToDecimal(i), Text = ((decimal)i).ToRatingDescription(ScoreFactorType), Value = i.ToString() });

Problem with DropDownListFor SelectedItem

房东的猫 提交于 2019-12-01 20:19:22
This has totally puzzled me. Here's my View: @Html.DropDownListFor(model => model.ScoreDescription, Model.RatingOptions, "--", new { @id = clientId }) And the model: public decimal? Score { get; set; } public SelectList RatingOptions { get { var options = new List<SelectListItem>(); for (var i = 1; i <= 5; i++) { options.Add(new SelectListItem { Selected = Score.HasValue && Score.Value == Convert.ToDecimal(i), Text = ((decimal)i).ToRatingDescription(ScoreFactorType), Value = i.ToString() }); } var selectList = new SelectList(options, "Value", "Text"); // At this point, "options" has an item

Powershell..select drop down menu from web page

馋奶兔 提交于 2019-12-01 05:39:53
问题 im trying to select a drop down menu on a website but im completely lost on how to do so. i googled the hell out of it but no luck on finding anything. this is what im trying to do.. connect to the web.. select a item from the drop down menu set quantity then add to cart ........................................................ [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing") [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") $objForm =

how to change background color of selected items in multiselect dropdown box?

时光总嘲笑我的痴心妄想 提交于 2019-12-01 04:13:40
I want to give the yellow color to the selected items in multiselect dropdown box. By default it has gray background after selecting, I want to do this in HTML, CSS . Can any one help in this? We can simply do with the help of the below css. select option:checked{ background: #1aab8e -webkit-linear-gradient(bottom, #1aab8e 0%, #1aab8e 100%); } <style> .select2-container--default .select2-results__option[aria-selected=true] { background-color: inherit; color: lightgray; } </style> Add your own style inside the block. We can use JS to select the DOMs. $('select').change(function() { $('option')

Select a default value in dropdownlistfor MVC 4

ぐ巨炮叔叔 提交于 2019-12-01 03:38:34
I'm trying to make a dropdownlistfor with a selected value but it doesn't work :/ And I search on the web but I don't find the solution :/ For the moment, I'm doing this : In C# : ViewBag.ID_VEH = new SelectList(db.VEHI, "ID_VEH", "COD_VEH", 4); // 4 is an example In my cshtml : @Html.DropDownListFor(model => model.ID_VEH, ViewBag.ID_VEH as SelectList) The dropdownlist is well complete but the default value is not selected :/ do you have an idea please ? Dylan Slabbinck What I like to do is add a list of the items to display in the dropdownlist to my model, so I don't have to pass that list

how to change background color of selected items in multiselect dropdown box?

久未见 提交于 2019-12-01 01:27:59
问题 I want to give the yellow color to the selected items in multiselect dropdown box. By default it has gray background after selecting, I want to do this in HTML, CSS . Can any one help in this? 回答1: We can simply do with the help of the below css. select option:checked{ background: #1aab8e -webkit-linear-gradient(bottom, #1aab8e 0%, #1aab8e 100%); } 回答2: <style> .select2-container--default .select2-results__option[aria-selected=true] { background-color: inherit; color: lightgray; } </style>

DataBinding: 'System.Web.Mvc.SelectListItem' does not contain a property with the name 'CategoryTypeID'

瘦欲@ 提交于 2019-11-30 18:22:46
I am using MVC. I want to pass the category data I entered from my view and passed to my Post/ Createcontroller, but it's not's letting me pass my categoryTypeID that I have selected from my dropdownlist. Here is the error: DataBinding: 'System.Web.Mvc.SelectListItem' does not contain a property with the name 'CategoryTypeID'. Here is my code: My CreateController: // // POST: /Category/Create [HttpPost] public ActionResult Create(Category category) { if (ModelState.IsValid) { db.Categories.Add(category); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.CategoryTypes = new

asp.net mvc 3 pre-select Html.DropDownListFor not working in nerd dinner

放肆的年华 提交于 2019-11-30 08:46:02
Learning about dropdown lists, Im trying to add a RSVP create page for nerddinner as in Scott Gu's blog with a Html.DropDownListFor listing available dinners. I can get the dropdown list populated but I cannot get the dropdown to pre select the value ("Sample Dinner 2") I want. Im using an initilizer to seed a few dinner objects in the db. The database is sql ce 4 using a EF 'code first approach'. Sorry I know this is a v common problem and hate to ask, but honestly have spent quite some time on this but cant get it to work: ViewModel public class RSVPViewModel { public SelectList DinnersList

How to use MVC Html Helper .DropDownListFor<> with an Enum

我与影子孤独终老i 提交于 2019-11-30 07:32:49
In my MVC 3 Razor app, I have a Model with an enum.. Model Example: public class EmployeeModel { public enum Title { Accountant = 111, Sales = 222, Production = 333 } [Required] public string Name {get; set;} [Required] public Title JobTitle {get; set;} } In my View I would like to use the Html helpers to build an Html Form... View Example: @model ..Models.EmployeeModel @using (Html.BeginForm()) { @Html.LabelFor(m => m.Name) @Html.TextBoxFor(m => m.Name) <br> @Html.LabelFor(m => m.JobTitle) @Html.DropDownListFor(m => m.JobTitle, ??How do I get Title enum values??) <br> <input type="submit /> }