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 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questionsForums
Top experts
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Jenith ThakkarRank #789 · 2.9K reputationPosted Jul 25, 2018, 11:13 PM EDT
vishnu sharma18 reputationPosted Jul 25, 2018, 11:42 PM EDT
Jenith ThakkarRank #789 · 2.9K reputationPosted Jul 25, 2018, 11:54 PM EDT
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 sharma18 reputationPosted Jul 26, 2018, 1:51 AM EDT