Solved

Populating a combobox in MVC

Posted on 2015-02-22
2
66 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 32

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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Using Quotation Marks in PHP This question (http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/Q_28217211.html) seems to come up a lot for developers who are new to PHP.  And it got me thinking, "How can we explain the rule…
If I have to fix slow responding website my first thoughts are server side optimizations: the database may not be optimized or caching is not enabled, or things like that. We often overlook another major part of our web application: the client. We o…
This video teaches viewers how to create their own website using cPanel and Wordpress. Tutorial walks users through how to set up their own domain name from tools like Domain Registrar, Hosting Account, and Wordpress. More specifically, the order in…
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to selectively show certain fields based on user input using rules to gather relevant information and data from your forms. The rules feature provides you with an opportunity…

759 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now