Simple form submission gives missing resource on postback - asp.net-mvc

Apologies if this seems mundane, but I am a huge beginner to MVC and this seemingly simple task is giving me a massive headache.
I can't understand why my code isn't working. I'm submitting a form from my Index.cshtml and the postback is telling me the resource /Index (the page I am posting from) doesn't exist.
Could I please get some help on what I am doing wrong?
My View (Index.cshtml):
#model MyProject.Connection
#{
ViewBag.Title = "Index";
}
<div id="container" class="container centered primary">
#using (Html.BeginForm(FormMethod.Post))
{
<img src="#Url.Content("/Content/images/default.png")" alt="CMGR Web" />
<div class="divider"></div>
<fieldset id="fs_server" class="borderless!T">
<legend>Server details</legend>
<table>
<tr>
<td>
#Html.LabelFor(c => c.serverHost)
</td>
<td>
#Html.TextBoxFor(c => c.serverHost)
</td>
</tr>
<tr>
<td>
#Html.LabelFor(c => c.instanceName)
</td>
<td>
#Html.TextBoxFor(c => c.instanceName)
</td>
</tr>
</table>
</fieldset>
<fieldset id="fs_user" class="borderless!T">
<legend>Your credentials</legend>
<table>
<tr>
<td>
#Html.LabelFor(c => c.username)
</td>
<td>
#Html.TextBoxFor(c => c.username)
</td>
</tr>
<tr>
<td>
#Html.LabelFor(c => c.password)
</td>
<td>
#Html.PasswordFor(c => c.password)
</td>
</tr>
</table>
</fieldset>
<div class="divider"></div>
<table>
<tr>
<td>
#Html.CheckBoxFor(c => c.remember)
#Html.Label("Remember me?")
</td>
<td>
<input type="submit"/>
</td>
</tr>
</table>
}
</div>
My Model (Connection.cs):
namespace MyProject.Models
{
public class Connection
{
[Display(Name="Server Host")]
public string serverHost { get; set; }
[Display(Name="Instance Name")]
public string instanceName { get; set; }
[Display(Name = "Username")]
public string username { get; set; }
[Display(Name = "Password")]
public string password { get; set; }
[Display(Name = "Remoting Password")]
public string remotingPassword { get; set; }
[Display(Name = "Persistent")]
public bool remember { get; set; }
}
}
My Controller (IndexController.cs)
namespace MyProject.Controllers
{
public class IndexController : Controller
{
//
// GET: /Login/
[HttpGet]
public ActionResult Index()
{
return View();
}
[HttpPost]
private ActionResult Index(Connection channel)
{
return View();
}
}
}

Your Post ActionResult is set to Private so it isnt accessible. Change it to public
private ActionResult Index(Connection channel)
{
return View();
}
public ActionResult Index(Connection channel)
{
return View();
}

Related

One-To-Many relationship between ApplicationUser and an other object

I am struggling trying to implement à create action and an index for my controller.
Basically, I want each user to have multiple pizzas.
I want the connected user to create his own pizzas.
And in the index of my controller I want to show, only the pizzas created by the current connected user.
Here are my models :
1/Pizzas :
public class PizzaModel
{
[Key]
public int PizzaID { get; set; }
[Display(Name = "Nom")]
public string nom { get; set; }
[Display(Name = "Prix(€)")]
public float prix { get; set; }
[Display(Name = "Végétarienne")]
public bool vegetarienne { get; set; }
[Display(Name = "Ingrédients")]
public string ingredients { get; set; }
public virtual ApplicationUser ApplicationUser { get; set; }
public string ApplicationUserId { get; set; }
}
2/ ApplicationUser :
public class ApplicationUser : IdentityUser
{
public ICollection<PizzaModel> Pizzas { get; set; }
}
3/ This is my Context :
public class AuthDbContext : IdentityDbContext<ApplicationUser>
{
public AuthDbContext(DbContextOptions<AuthDbContext> options) : base(options)
{
}
public DbSet<PizzaModel> Pizzas { get; set; }
public DbSet<ApplicationUser> ApplicationUsers { get; set; }
protected override void OnModelCreating(ModelBuilder builder)
{
builder.Entity<ApplicationUser>()
.HasMany(p => p.Pizzas)
.WithOne(u => u.ApplicationUser)
.IsRequired()
.HasForeignKey(p => p.ApplicationUserId);
base.OnModelCreating(builder);
}
I want to create a "create action" and an "index action" that shows only the pizzas created by the current connected user. Here is what I have done so far :
1/ Index action method :
public async Task<IActionResult> Index(string searchByName)
{
var userId = User.FindFirstValue(ClaimTypes.NameIdentifier);
IEnumerable<PizzaModel> pizzas = new List<PizzaModel>();
pizzas = _context.Pizzas.Where(x => x.ApplicationUserId == userId);
return View(pizzas);
}
2/ Create Action Method :
public async Task<IActionResult> Create(PizzaModel model)
{
_context.ApplicationUsers.Add(model);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index), "Pizza");
}
Could you please help me with these 2 actions (Create and Index) ?
According to your Model and DbContext, I create the actions as below: I'm using the Home Controller and Project name is "WebApplication3"
public class HomeController : Controller
{
private readonly ILogger<HomeController> _logger;
private readonly ApplicationDbContext _dbContext;
public HomeController(ILogger<HomeController> logger, ApplicationDbContext dbContext)
{
_logger = logger;
_dbContext = dbContext;
}
public IActionResult Index()
{
var userId = User.FindFirstValue(ClaimTypes.NameIdentifier);
IEnumerable<PizzaModel> pizzas = new List<PizzaModel>();
pizzas = _dbContext.Pizzas.Where(x => x.ApplicationUserId == userId);
return View(pizzas);
}
public IActionResult Create()
{
return View();
}
[HttpPost]
public async Task<IActionResult> Create(PizzaModel model)
{
//Note: if you check the ModelState.IsValid, it will return false, because there is no ApplicationID and PizzaID,
//you can create a view model to enter the new value, then, convert it to PizzaModel
//validate the model
//if (ModelState.IsValid)
//{
//get current user id
var userId = User.FindFirstValue(ClaimTypes.NameIdentifier);
if (userId != null)
{
//based on the userid to find current user and get its pizzas.
var currentuser = _dbContext.ApplicationUsers.Include(c => c.Pizzas).First(c => c.Id == userId);
List<PizzaModel> pizzas = new List<PizzaModel>();
pizzas = currentuser.Pizzas.ToList();
//add the new item to pizza list
pizzas.Add(new PizzaModel()
{
nom = model.nom,
prix = model.prix,
vegetarienne = model.vegetarienne,
ingredients = model.ingredients
});
//update the pizzas for current user.
currentuser.Pizzas = pizzas;
await _dbContext.SaveChangesAsync();
}
return RedirectToAction(nameof(Index));
//}
//else
//{
// return View();
//}
}
The Index view as below:
#model IEnumerable<WebApplication3.Data.PizzaModel>
#{
ViewData["Title"] = "Index";
}
<h1>Index</h1>
<table class="table">
<thead>
<tr>
<th>
#Html.DisplayNameFor(model => model.PizzaID)
</th>
<th>
#Html.DisplayNameFor(model => model.nom)
</th>
<th>
#Html.DisplayNameFor(model => model.prix)
</th>
<th>
#Html.DisplayNameFor(model => model.vegetarienne)
</th>
<th>
#Html.DisplayNameFor(model => model.ingredients)
</th>
<th>
#Html.DisplayNameFor(model => model.ApplicationUserId)
</th>
<th></th>
</tr>
</thead>
<tbody>
#if(Model.ToList().Count > 0)
{
#foreach (var item in Model) {
<tr>
<td>
#Html.DisplayFor(modelItem => item.PizzaID)
</td>
<td>
#Html.DisplayFor(modelItem => item.nom)
</td>
<td>
#Html.DisplayFor(modelItem => item.prix)
</td>
<td>
#Html.DisplayFor(modelItem => item.vegetarienne)
</td>
<td>
#Html.DisplayFor(modelItem => item.ingredients)
</td>
<td>
#Html.DisplayFor(modelItem => item.ApplicationUserId)
</td>
<td>
#Html.ActionLink("Edit", "Edit", new { /* id=item.PrimaryKey */ }) |
#Html.ActionLink("Details", "Details", new { /* id=item.PrimaryKey */ }) |
#Html.ActionLink("Delete", "Delete", new { /* id=item.PrimaryKey */ })
</td>
</tr>
}
}
else
{
<tr><td colspan="7">Empty</td></tr>
}
</tbody>
</table>
<p>
<a asp-action="Create">Create New Pizza</a>
</p>
The Create View:
#model WebApplication3.Data.PizzaModel
#{
ViewData["Title"] = "Create";
}
<h1>Create</h1>
<h4>PizzaModel</h4>
<hr />
<div class="row">
<div class="col-md-4">
<form asp-action="Create">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<div class="form-group">
<label asp-for="nom" class="control-label"></label>
<input asp-for="nom" class="form-control" />
<span asp-validation-for="nom" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="prix" class="control-label"></label>
<input asp-for="prix" class="form-control" />
<span asp-validation-for="prix" class="text-danger"></span>
</div>
<div class="form-group form-check">
<label class="form-check-label">
<input class="form-check-input" asp-for="vegetarienne" /> #Html.DisplayNameFor(model => model.vegetarienne)
</label>
</div>
<div class="form-group">
<label asp-for="ingredients" class="control-label"></label>
<input asp-for="ingredients" class="form-control" />
<span asp-validation-for="ingredients" class="text-danger"></span>
</div>
<div class="form-group">
<input type="submit" value="Create" class="btn btn-primary" />
</div>
</form>
</div>
</div>
<div>
<a asp-action="Index">Back to List</a>
</div>
The result as below:
Generally, in the HttpPost method such as the Create or Update action method, we need to validte the model is valid or not, then based on the result to show validation message or go the next steps. You can refer the following tutorials:
Model validation in ASP.NET Core MVC and Razor Pages
Tutorial: Implement CRUD Functionality - ASP.NET MVC with EF Core

'Model' conflicts with the declaration 'System.Web.Mvc.WebViewPage<TModel>.Model'

I am having a problem in my code and I can not use a list inside a class in a foreach, has anyone had a similar problem?
Follows the code:
Model
public class Detalhes_Pedido
{
public Pedidos Pedido { get; set; }
public Pedidos_Endereco Pedido_Endereco { get; set; }
public Pedidos_Status Pedido_Status { get; set; }
public List<Pedidos_Produtos> Pedido_Produto { get; set; }
public List<Produtos> Produto { get; set; }
public Clientes Cliente { get; set; }
public Metodos_Entrega Metodo_entrega { get; set; }
public Metodos_Pagamento Metodos_Pagamento { get; set; }
}
View
#model Ecommerce.Models.Repository.Pedido_Repository.Detalhes_Pedido
#Html.AntiForgeryToken()
#Html.HiddenFor(model => model.Pedido.ID)
<div class="module_content">
<div class="ModuleConteiner">
#Html.ValidationSummary(true)
<table class="QuatroColumnTable">
<tr>
<td colspan="2">
<h3>Dados da Transação</h3>
<br />
</td>
</tr>
<tr>
<td>
#Html.LabelFor(model => model.Pedido.ID, "Número do Pedido: ")
<br />
</td>
here is where the problem occurs:
<td>
#Html.DisplayFor(model => model.Pedido.ID)
<br />
</td>
</tr>
<tr>
<td>
#Html.LabelFor(model => model.Pedido, "Peso total da compra: ")
</td>
<td>
**#foreach (var item in model.Produto)
{
}**
</td>
</tr>
</table>
What can be happening?
You need a capital M in Model:
#foreach (var item in Model.Produto)
{
}

When i set value of elements in editor template for grid pop up create , posting to controller as null

in my view there are two grid. when i select a row in first grid, second one is binding according to first one.
what i want to do is take common parameters from first one, used in second one create template in readonly or disabled inputs. my problem is input elements take parameter from first grid but, dont post to controller.
Controller Function
[AcceptVerbs(HttpVerbs.Post)]
public JsonResult DonemKursSinifiOlustur([DataSourceRequest] DataSourceRequest request, DonemKursSinifi model,string DonemId, string DersId, string EgitmenId )
{
if (model != null && ModelState.IsValid)
{
Helper.Islemci.DonemKursSinifiTanimla(model);
}
return Json(new[] { model }.ToDataSourceResult(request, ModelState));
}
model.DonemId, model.DersId, model.EgitmenId and DonemId, DersId, EgitmenId come null.
EditorTemplate View for Grid Create and Update
#model Kurslar.Models.DonemKursSinifi
#using (Html.BeginForm("DonemKursSinifiOlustur","Tanim",FormMethod.Post))
{
<table>
<tr>
<td>
Lütfen Gün ve Saati Belirtiniz:
</td>
<td>
#Html.Kendo().AutoCompleteFor(m=>m.Tanim)
</td>
</tr>
<tr>
<td>
Donem :
</td>
<td>
#Html.Kendo().AutoCompleteFor(m=>m.DonemBaslangicBitis)
#Html.HiddenFor(m => m.DonemId)
</td>
</tr>
<tr>
<td>
Ders Adı:
</td>
<td>
#Html.Kendo().AutoCompleteFor(m=>m.DersAdi)
#Html.HiddenFor(m => m.DersId)
</td>
</tr>
<tr>
<td>
Eğitmen
</td>
<td>
#Html.Kendo().AutoCompleteFor(m=>m.EgitmenAdiSoyadi)
#Html.HiddenFor(m => m.DonemId)
</td>
</tr>
</table>}
First AutoCompleteFor works correctly because take input from user, not before setted.
*and my javaScript code to fill parameters to EditorTemplate *
and it works fine
var grid = $("#donemGrid").data("kendoGrid");
var rows = grid.select();
alert(rows);
try {
var donemID = grid.dataItem(rows).DonemId;
var dersID = grid.dataItem(rows).DersId;
var egitmenID = grid.dataItem(rows).EgitmenId;
var dersAdi = grid.dataItem(rows).DersAdi;
var egitmenAdiSoyadi= grid.dataItem(rows).EgitmenAdiSoyadi;
var donemBaslangicBitis = grid.dataItem(rows).DonemBaslangicBitis;
} catch (e) {
alert(e);
}
$("#DonemBaslangicBitis").data("kendoAutoComplete").value(donemBaslangicBitis);
$("#DersAdi").data("kendoAutoComplete").value(dersAdi);
$("#EgitmenAdiSoyadi").data("kendoAutoComplete").value(egitmenAdiSoyadi);
$("#DonemId").val(donemID);
$("#DersId").val(dersID);
$("#EgitmenId").val(egitmenID);
*if needed, my model *
public class DonemKursSinifi
{
[Key]
[Required]
[PersistentProperty(IsAutoIncremented = true)]
public int Id { get; set; }
[PersistentProperty]
public string Tanim { get; set; }
[PersistentProperty]
public int DonemId { get; set; }
[PersistentProperty]
public int DersId { get; set; }
[PersistentProperty]
public int EgitmenId { get; set; }
[PersistentProperty]
public int KontenjanSayisi { get; set; }
[PersistentProperty]
public int TarifeId { get; set; }
[PersistentProperty]
public int IslemNo { get; set; } // default 1
public string EgitmenAdiSoyadi { get; set; }
public string DersAdi { get; set; }
public string DonemBaslangicBitis { get; set; }
}
ok, probably you have repeated the id in the grid and also have the same name attributes in the same form to do this:
#Html.HiddenFor(m => m.DersId)
mabe you can do somethin like this:
form:
#model Kurslar.Models.DonemKursSinifi
#using (Html.BeginForm("DonemKursSinifiOlustur","Tanim", FormMethod.Post, new { id="myform"}))
{
<input type="hidden" value="" name="Tanim" />
<input type="hidden" value="" name="DonemBaslangicBitis" />
<input type="hidden" value="" name="DonemId" />
<input type="hidden" value="" name="DersAdi" />
<input type="hidden" value="" name="DersId" />
<input type="hidden" value="" name="EgitmenAdiSoyadi" />
<input type="hidden" value="" name="DonemId" />
}
table:
<table>
<tr>
<td>Lütfen Gün ve Saati Belirtiniz:</td>
<td>#Html.Kendo().AutoCompleteFor(m=>m.Tanim)</td>
</tr>
<tr>
<td>Donem :</td>
<td>#Html.Kendo().AutoCompleteFor(m=>m.DonemBaslangicBitis) #Html.HiddenFor(m => m.DonemId)</td>
</tr>
<tr>
<td>Ders Adı:</td>
<td>#Html.Kendo().AutoCompleteFor(m=>m.DersAdi) #Html.HiddenFor(m => m.DersId)</td>
</tr>
<tr>
<td>Eğitmen</td>
<td>#Html.Kendo().AutoCompleteFor(m=>m.EgitmenAdiSoyadi) #Html.HiddenFor(m => m.DonemId)</td>
</tr>
</table>
js:
var
grid = $("#donemGrid").data("kendoGrid"),
rows = grid.select(),
form = $('#myform');
form.find('input[name="DonemBaslangicBitis"]').val(grid.dataItem(rows).DonemBaslangicBitis);
form.find('input[name="DersAdi"]').val(grid.dataItem(rows).DersAdi);
form.find('input[name="EgitmenAdiSoyadi"]').val(grid.dataItem(rows).EgitmenAdiSoyadi);
form.find('input[name="DonemId"]').val(grid.dataItem(rows).DonemId);
form.find('input[name="DersId"]').val(grid.dataItem(rows).DersId);
form.find('input[name="EgitmenId"]').val(grid.dataItem(rows).EgitmenId);
form.submit();

Passing back child entity from MVC view to controller

I'm trying to delete entries which are marked (checked) in view, but not sure how to pass back the collection back to the controller
my mode is:
Group which has ICollection<SubGroup> SubGroups and SubGroup has ICollection<Event> Events
I pass Group to the view and iterate and display Event details including a checkbox so if it's checked the event entry should be deleted.
When I get the postback to the controller, Group.SubGroups is null
How do I make sure the child entities are passed back to the controller?
Can I use #Html.CheckBox instead Of <input type="checkbox"... ?
Update: Model
public class Group
{
[Key]
public int GroupId { get; set; }
public virtual IList<SubGroup> SubGroups { get; set; }
....
}
public class SubGroup
{
[Key]
public int SubGroupId { get; set; }
public virtual IList<Event> Events { get; set; }
....
}
public class Events
{
[Key]
public int EventId { get; set; }
public string EventName { get; set; }
public bool IsDeleted { get; set; }
....
}
I am passing Group to the view (see below) as the Model and want to delete events which are checked by the user
View:
#using System.Globalization
#model NS.Models.Group
#{
ViewBag.Title = "Edit";
}
#using (Html.BeginForm())
{
#Html.ValidationSummary(true)
<fieldset>
<legend>Booking Details</legend>
<div class="display-label">
Group Name
</div>
<div class="display-field">
#Html.DisplayFor(model => model.GroupName)
</div>
<div class="display-field">
#foreach (var b in Model.SubGroup)
{
groupNo += 1;
<table class="main" style="width: 80%; margin-top: 10px">
<tr>
<th>
#Html.DisplayName("Sub Group ")
#Html.DisplayName(b.SubGroupName)
</th>
</tr>
<table class="main" style="width: 80%;">
<tr>
<th>Event</th>
<th>Delete</th>
</tr>
#foreach (var ev in b.Events)
{
<tr>
<td>
#Html.DisplayFor(modelItem => ev.EventName)
</td>
<td>
<input type="checkbox" id="eventToDelete" name="eventToDelete" value="#ev.EventId" />
</td>
</tr>
}
</table>
</table>
}
</div>
<p>
<input type="submit" name="xc" value="Delete" class="button" />
</p>
</fieldset>
}
Thank You
Try this...
public ActionResult ViewName(FormCollection collection)
{
if(collection['eventToDelete']!=null && collection['eventToDelete'].ToString()!="")
{
//delete....
}
return....
}
Try this
public ActionResult ViewName(Group model)
{
if(model != null && ModelState.IsValid)
{
//delete....
}
return....
}

How to link a list table view to another table view for details using ASP.NET MVC

I am viewing a list on the 1st page and on the 2nd page it should link using the same id from the database on the 1st page, but the 2nd page its details page.
1st page - listview
2nd page - details
Here is what I have already tried
Example: http://abctutorial.com/Post/53/mvc5-master-detail-edit-using-aspnet--jquery--razor
The Model called: "Ordering" and its display on the ListView
public Ordering()
{
this.Invoice_Line_Item = new HashSet<Invoice_Line_Items>();
}
[Key]
public int order_id { get; set; }
public Guid? CustomerId { get; set; }
public int? CustId { get; set; }
[DatabaseGenerated(DatabaseGeneratedOption.Computed)]
[StringLength(34)]
public string invoice_number { get; set; }
[StringLength(200)]
public string EmailId { get; set; }
[StringLength(50)]
public string ClientFirstname { get; set; }
[StringLength(50)]
public string ClientLastname { get; set; }
[StringLength(50)]
public string MobileNumber { get; set; }
[StringLength(50)]
public string PaymentStatus { get; set; }
[StringLength(50)]
public string trackingorderno { get; set; }
[StringLength(50)]
public string Status { get; set; }
[StringLength(200)]
public string DeliveryNote { get; set; }
[StringLength(250)]
public string Agent { get; set; }
public DateTime? date_order_placed { get; set; }
public virtual ICollection<Invoice_Line_Items> Invoice_Line_Item {
get; set; }
ListView page for "Ordering"
#model IEnumerable<LifestyleAdminOriginal.Models.Ordering>
#foreach (var item in Model)
{
<tr>
<td>
#Html.DisplayFor(modelItem => item.invoice_number)
</td>
<td>
#Html.DisplayFor(modelItem => item.ClientFirstname) #Html.DisplayFor(modelItem => item.ClientLastname)
</td>
<td>
#Html.DisplayFor(modelItem => item.EmailId)
</td>
<td>
#Html.DisplayFor(modelItem => item.MobileNumber)
</td>
<td>
<span class="label label-danger">#Html.DisplayFor(modelItem => item.Status)</span>
</td>
<td>
#Html.ActionLink("View", "NewOrdersDetails", new { id = item.CustId })
</td>
</tr>
}
Details page for "Invoice_Line_Items"
<div class="row">
#if (Model.Count() != 0)
{
foreach (var item in Model)
{
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
<div class="invoice-sp">
<table class="table table-hover">
<thead>
<tr>
<th>Service</th>
<th>Item</th>
<th>Gender</th>
<th>Unit Price</th>
<th>Quantity</th>
<th>Total</th>
</tr>
</thead>
<tbody>
<tr>
#foreach (var inv in item.Invoice_Line_Item)
{
<th>#inv.service</th>
<td>#inv.item</td>
<td>#inv.gender</td>
<td>#inv.price</td>
<td>#inv.quantity</td>
<td>#inv.price</td>
}
</tr>
</tbody>
</table>
</div>
</div>
}
}
</div>
Listview Controller for "Ordering"
public ActionResult NewOrders()
{
var count = db.Orderings.Where(s => s.trackingorderno == "New Order").Count();
ViewBag.totalall = count;
return View(db.Orderings.ToList().Where(x => x.trackingorderno == "New Order").Select(x => x));
}
Detailsview Controller for "Invoice_Line_Items" and "Ordering"
public ActionResult NewOrdersDetails(int? CustId)
{
if (CustId == null)
{
return new System.Web.Mvc.HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
List<Ordering> OrderAndCustomerList = db.Orderings.ToList();
if (OrderAndCustomerList == null)
{
return HttpNotFound();
}
return View(OrderAndCustomerList);
}
Basically, whenever a user clicks "View" on listview page, it should take them to the details page where it shows the invoice line items and displays the customer details as well on one page which is "DetailsView"
In First table Where You Show Main Data and Second Table Detail Of the First table data
so you have to take detail table content id in Main Table content and send it to second page with detail id from main table.
I managed to get the answer from the following example on the below link. I used the ICollection on the model Ordering
https://learn.microsoft.com/en-us/aspnet/mvc/overview/getting-started/getting-started-with-ef-using-mvc/implementing-basic-crud-functionality-with-the-entity-framework-in-asp-net-mvc-application
**Ordering Model**
[ForeignKey("order_id")]
public virtual ICollection<Invoice_Line_Items> Invoice_Line_Item { get; set; }
**Invoice_Line_Items Model**
public virtual Ordering Ordering { get; set; }
**Details Page**
<table class="table">
<tr>
<th>Service</th>
<th>Department</th>
</tr>
#foreach (var item in Model.Invoice_Line_Item)
{
<tr>
<td>
#Html.DisplayFor(modelItem => item.invoice_number)
</td>
<td>
#Html.DisplayFor(modelItem => item.service)
</td>
<td>
#Html.DisplayFor(modelItem => item.department)
</td>
<td>
#Html.DisplayFor(modelItem => item.item)
</td>
<td>
#Html.DisplayFor(modelItem => item.quantity)
</td>
<td>
#Html.DisplayFor(modelItem => item.price)
</td>
<td>
#Html.DisplayFor(modelItem => item.vat)
</td>
<td>
#Html.DisplayFor(modelItem => item.grandtotal)
</td>
</tr>
}
</table>

Resources