Solved

Populating a combobox in MVC

Posted on 2015-02-22
2
68 Views
Last Modified: 2015-03-03
Just starting with web development and trying to learn mvc.  I am using devexpress componets. I want to bind a combo box to a datasource.  My controller name is MaintenanceList.  I really have no idea how to even start.

Thanks
0
Comment
Question by:Moed
2 Comments
 
LVL 33

Accepted Solution

by:
Big Monty earned 500 total points
ID: 40626772
taken from here

View
@{
 
if (@ViewContext.ViewData.ModelState.IsValid)

{

ViewBag.Title = "Index";

}

}
<h2>Abundant Code</h2>

@Html.DropDownList(“StateType”)

Controller


using MvcApplication1.Models;

using System;

using System.Collections.Generic;

using System.Linq;
 
using System.Web;

using System.Web.Mvc;

namespace MvcApplication1.Controllers

{

public class EmployeeController : Controller

{

public ActionResult Index()

{

ViewBag.ApplicationTitle = "AbundantCode App";

List<SelectListItem> obj = new List<SelectListItem>();

obj.Add(new SelectListItem { Text = "Solid State", Value = "1" });
obj.Add(new SelectListItem { Text = "Liquid State", Value = "2" });

Open in new window

0
 
LVL 2

Author Comment

by:Moed
ID: 40632242
I'll check it out.
0

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Introduction (All good things must come to an end (http://en.wikipedia.org/wiki/All_Good_Things...))The original MySQL API (http://php.net/manual/en/book.mysql.php) has gone away, deprecated by PHP in Version 5.5, and removed from PHP in all current…
This video teaches users how to migrate an existing Wordpress website to a new domain.
Learn how to set-up PayPal payment integration in your Wufoo form. Allow your users to remit payment through PayPal upon completion of your online form. This is helpful for collecting membership payments, customer payments, donations, and more.

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question