public partial class EntryTable
{
public int Id { get; set; }
public string Name { get; set; }
public DateTime Date { get; set; }
public long Mobile { get; set; }
public string Email { get; set; }
[Display(Name="City")]
public int CityId { get; set; }
public IEnumerable City { get; set; }
[Display(Name="Category")]
public int CategoryId { get; set; }
public IEnumerable Category { get; set; }
public string Gender { get; set; }
public string Address { get; set; }
}
//controller
public ActionResult Index()
{
return View(db.EntryTables.ToList());
}
//View
@Html.DisplayNameFor(model => model.Email)
@Html.DisplayNameFor(model => model.CityId)
@Html.DisplayNameFor(model => model.CategoryId)
here i created two dropdowns, one for City and another for Category. My table is showing only Id of selected dropdown istead of Name.
how can i show the name from selected dropdown in the index view table.
4 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
vishnu sharmaPosted Jul 26, 2018, 5:51 AM
Jenith ThakkarPosted Jul 26, 2018, 3:54 AM
and using loop you can show that record like this
https://www.c-sharpcorner.com/UploadFile/f82e9a/data-displaying-in-table-format-in-diffrent-ways-in-mvc/
vishnu sharmaPosted Jul 26, 2018, 3:42 AM
Jenith ThakkarPosted Jul 26, 2018, 3:13 AM