Dropdownlist and MVC4 Entity Framework

Lidia Mesfin

here is my model class public class Question

{
    [Key]
    public int Id { get; set; }

    public int PollId { get; set; }

    public string Title { get; set; }

    public string Type { get; set; }

    public string Body { get; set; }


    public string Options { get; set; }

    public int Priority { get; set; }

    public bool IsActive { get; set; }

    public DateTime CreatedOn { get; set; }

    public DateTime ModifiedOn { get; set; }

    public List<Vote> Answers { get; set; }
}

i want to display the option column on dropdownlist and split using comma i tried this one it display the dropdownlist but it dose not separate the values using comma for example if my option on questionid 1 is Yes;No it displays both together like Yes;No but i want to display like this one the first value will be Yes and the second one No

my controller

ViewBag.MyOption = new SelectListItem() { Text = "Options" , Value = "Options" };

and finally my view

@Html.DropDownList("MyOption","---Select---")

what should i do pls help me

Supraj v

In your controller

var optionslist = options.Split(',').ToList(); //split comma seperated into list
ViewBag.MyOption = optionslist // Your List of an options

In your view

@Html.DropDownList("Select Option",new SelectList(ViewBag.MyOption))

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Populate DropDownList using MVC 4 & Entity Framework

From Dev

MVC with Entity Framework My DropDownList isn't a dropdownlist

From Dev

PieChart in mvc4 from Entity Framework

From Dev

Log4net with Entity Framework 5 and MVC4

From Dev

How to mock method with ViewModel in MVC4 with Entity Framework 4.0

From Dev

Will Orchard CMS support MVC4 with Entity Framework

From Dev

MVC4 Entity Framework Controller Database Issue

From Dev

MVC4 app - how to remove Entity Framework and implement SimpleMembershipProvider?

From Dev

How to mock method with ViewModel in MVC4 with Entity Framework 4.0

From Dev

MVC4 Entity Framework 6 Model State Validation Issues

From Dev

Entity Framework profiler - ASP.NET MVC4 with EF 6 -Unable to determine the provider name

From Dev

Single or multiple DbContext File in mvc4 using Entity framework 6

From Dev

Assigning [Key] attribute to Entity Framework generated class - MVC4 C#

From Dev

MVC4 Code First Entity Framework Upload large files to a SQL Server database

From Dev

How to retrieve image from database without using Entity Framework in ASP.NET MVC4

From Dev

upload image in server folder and save path in Sqlserver using entity framework mvc4

From Dev

.NET Membership in ASP.NET MVC4 and Entity Framework with Oracle as Db

From Dev

Merging MVC4 membership database with entity framework code first database

From Dev

Entity Framework profiler - ASP.NET MVC4 with EF 6 -Unable to determine the provider name

From Dev

Unable to Use an HtmlHelper in Razor syntax in MVC4 Intranet App using Entity Framework

From Dev

Assigning [Key] attribute to Entity Framework generated class - MVC4 C#

From Dev

upload image in server folder and save path in Sqlserver using entity framework mvc4

From Dev

How to retrieve image from database without using Entity Framework in ASP.NET MVC4

From Dev

How to perform edit function in MVC4 without using entity framework?

From Dev

ASP.NET MVC4 Entity Framework db.SaveChanges() Condition not working

From Dev

List of users that not yet in any role, (MVC4 with SimpleMembership and entity framework 5)

From Dev

MVC4 Validate Item Selected In DropDownList

From Dev

MVC4 dropdownlist selected value

From Dev

DropDownList C# Mvc4 Razor

Related Related

  1. 1

    Populate DropDownList using MVC 4 & Entity Framework

  2. 2

    MVC with Entity Framework My DropDownList isn't a dropdownlist

  3. 3

    PieChart in mvc4 from Entity Framework

  4. 4

    Log4net with Entity Framework 5 and MVC4

  5. 5

    How to mock method with ViewModel in MVC4 with Entity Framework 4.0

  6. 6

    Will Orchard CMS support MVC4 with Entity Framework

  7. 7

    MVC4 Entity Framework Controller Database Issue

  8. 8

    MVC4 app - how to remove Entity Framework and implement SimpleMembershipProvider?

  9. 9

    How to mock method with ViewModel in MVC4 with Entity Framework 4.0

  10. 10

    MVC4 Entity Framework 6 Model State Validation Issues

  11. 11

    Entity Framework profiler - ASP.NET MVC4 with EF 6 -Unable to determine the provider name

  12. 12

    Single or multiple DbContext File in mvc4 using Entity framework 6

  13. 13

    Assigning [Key] attribute to Entity Framework generated class - MVC4 C#

  14. 14

    MVC4 Code First Entity Framework Upload large files to a SQL Server database

  15. 15

    How to retrieve image from database without using Entity Framework in ASP.NET MVC4

  16. 16

    upload image in server folder and save path in Sqlserver using entity framework mvc4

  17. 17

    .NET Membership in ASP.NET MVC4 and Entity Framework with Oracle as Db

  18. 18

    Merging MVC4 membership database with entity framework code first database

  19. 19

    Entity Framework profiler - ASP.NET MVC4 with EF 6 -Unable to determine the provider name

  20. 20

    Unable to Use an HtmlHelper in Razor syntax in MVC4 Intranet App using Entity Framework

  21. 21

    Assigning [Key] attribute to Entity Framework generated class - MVC4 C#

  22. 22

    upload image in server folder and save path in Sqlserver using entity framework mvc4

  23. 23

    How to retrieve image from database without using Entity Framework in ASP.NET MVC4

  24. 24

    How to perform edit function in MVC4 without using entity framework?

  25. 25

    ASP.NET MVC4 Entity Framework db.SaveChanges() Condition not working

  26. 26

    List of users that not yet in any role, (MVC4 with SimpleMembership and entity framework 5)

  27. 27

    MVC4 Validate Item Selected In DropDownList

  28. 28

    MVC4 dropdownlist selected value

  29. 29

    DropDownList C# Mvc4 Razor

HotTag

Archive