I developed my asp.net mvc3 app in code first basis
I am getting Lastname in dropdown list
is there any possible way to get the Name along with Lastname
public class people /getting data from User class
{
[Key]
public int groupid { get; set; }
[Required]
public string name { get; set; }
[Required]
public int UserId { get; set; }
[ScriptIgnore]
public virtual Users user { get; set; }
}
public class Users/parent table
{
[Key]
public int UserId { get; set; }
[Required]
[StringLength(100)]
public string LastName { get; set; }
[Required]
[StringLength(100)]
public string Name { get; set; }
[ScriptIgnore]
public virtual ICollection
}
Jignesh TrivediPosted May 2, 2012, 11:36 PM
In mvc, to filldropdown use IEnumerable
var item = "Your Query that return collection or list";
var k = new MultiSelectList(item, "ValueFiled", "TextFiiled");
and k bind with dropdown.
OR
var ItemList = "Your Query that return collection or list";
Collection
foreach (var p in ItemList)
{
item.Add(new SelectListItem { Selected = false, Value = p.ValueField, Text = p.LastName +";"+ p.Name });
}
SelectList list = new SelectList(item, "Value", "Text");
hope this help.