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
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.
Comments