I have a Controller and I am taking an object of database and passing it to view. Here is the action method for it
public ActionResult NewRequest(Bookinfo bookinfo)
{
using (var db = new Database1Entities1())
{
return View(db.Bookinfoes.ToList());
}
}
And here is my view method
@model IEnumerable<MvcApplication.Models.Bookinfo>
@{
ViewBag.Title = "NewRequest";
}
<h2>NewRequest</h2>
<table>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.Bookname)
</td>
<td>
@Html.DisplayFor(modelItem => item.Authorname)
</td>
<td>
@Html.DisplayFor(modelItem => item.Publishername)
</td>
<td> </td>
</tr>
}
</table>
As you can see that I am able to display the data normally but i want to display the data in drop downlist. Also I want to select an item from dropdownlist and take its value so that i can manipulate it How can I do it??? Sorry if this seems to be a simple question. i have just started learning asp.net mvc4
Here is the book info model
namespace MvcApplication.Models
{
using System;
using System.Collections.Generic;
public partial class Bookinfo
{
public int Id { get; set; }
public string Bookname { get; set; }
public string Authorname { get; set; }
public string Publishername { get; set; }
}
}