Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

mvc 5 dropdownlist

//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>
Comment

mvc 5 dropdownlist


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

Comment

PREVIOUS NEXT
Code Example
Csharp :: unity topdown movement 
Csharp :: how set function when props update in vue 
Csharp :: reverse a string in c# 
Csharp :: accessing form controls from another class c# 
Csharp :: c# regex get matched string 
Csharp :: c# append text to file 
Csharp :: header export excel data only php 
Csharp :: 2d list in c# 
Csharp :: c# file directory selection 
Csharp :: dota2 
Csharp :: c# make request to rest api 
Csharp :: dialog box with form flutter 
Csharp :: run wpf application maximized 
Csharp :: c# string replace comma with newline 
Csharp :: c# byte array to file 
Csharp :: c# encode jpg hiight quality 
Csharp :: get last element of array c# 
Csharp :: unity c# check how many of an object exists 
Csharp :: how to remove space between string in c# 
Csharp :: how to check if file contains image c# 
Csharp :: check shell command success 
Csharp :: 2 rotation unity 
Csharp :: c# multiline comment 
Csharp :: winforms C# code cross thread operation is not valid 
Csharp :: c# set datetime to null value 
Csharp :: c# list audio devices 
Csharp :: c# list object sort alphabetically 
Csharp :: public gameobject unity 
Csharp :: c# return task list 
Csharp :: c# remove first three characters from string 
ADD CONTENT
Topic
Content
Source link
Name
8+4 =