“MVC 5 Lista desplegable” Código de respuesta

MVC 5 Lista desplegable

//To populate DropDownList using Viewbag, let's create some collection list with 
//selectListItem types and assign to the Viewbag with appropriate name:

public ActionResult Index() {
  	#region ViewBag  
    List < SelectListItem > mySkills = new List < SelectListItem > () {  
        new SelectListItem {  
            Text = "ASP.NET MVC", Value = "1"  
        },  
        new SelectListItem {  
            Text = "ASP.NET WEB API", Value = "2"  
        },  
        new SelectListItem {  
            Text = "ENTITY FRAMEWORK", Value = "3"  
        },  
        new SelectListItem {  
            Text = "DOCUSIGN", Value = "4"  
        },  
        new SelectListItem {  
            Text = "ORCHARD CMS", Value = "5"  
        },  
        new SelectListItem {  
            Text = "JQUERY", Value = "6"  
        },  
        new SelectListItem {  
            Text = "ZENDESK", Value = "7"  
        },  
        new SelectListItem {  
            Text = "LINQ", Value = "8"  
        },  
        new SelectListItem {  
            Text = "C#", Value = "9"  
        },  
        new SelectListItem {  
            Text = "GOOGLE ANALYTICS", Value = "10"  
        },  
    };  
    ViewBag.MySkills = mySkills;
  	#endregion  
    return View();  
}

//And now bind the ViewBag.MySkills values to DropDownlist as below code in view:

<tr>  
    <td> Populating With ViewBag Data </td>  
    <td> @Html.DropDownList("MySkills", (IEnumerable  
        <SelectListItem>)ViewBag.MySkills) </td>  
</tr>
Mirsho

MVC 5 Lista desplegable


 public List<SelectListItem> mapLocationItemTypes { get; set; }
 public int mapLocationItemVal { get; set; }

Different Dormouse

Respuestas similares a “MVC 5 Lista desplegable”

Preguntas similares a “MVC 5 Lista desplegable”

Más respuestas relacionadas con “MVC 5 Lista desplegable” en C#

Explore las respuestas de código populares por idioma

Explorar otros lenguajes de código