Display IEnumerable<dynamic> in a view - c#

I have a model as shown below. The MenuItem model, which has different SQL queries (MenuItem.MenuSQLQuery).
I am executing these query agaist a progress DB and I want to display the result on the view. The return of the SQL query is IEnumerable dynamic (using dapper ORM).
Thanks for your time reading and appreciate any help.
Model
namespace Models.Menu
{
public class MenuItem
{
public int MenuItemId { get; set; }
public string MenuName { get; set; }
public string MenuCategory { get; set; }
public string MenuParent { get; set; }
public string MenuAction { get; set; }
public string MenuController { get; set; }
public string MenuSQLQuery { get; set; }
public string ResultColumnHeading { get; set; }
public string MenuRole { get; set;}
}
}
Controller
using Dapper;
using Microsoft.AspNet.Identity;
using System.Collections.Generic;
using System.Data;
using System.Data.Odbc;
using System.Linq;
using System.Web.Mvc;
using DataLayer;
using Models.Menu;
namespace Controllers
{
public class BrowseController : Controller
{
public ActionResult Index()
{
return View();
}
public ActionResult BrowseResult(int menuId)
{
ApplicationDbContext context = new ApplicationDbContext();
var odbcConnection = new OdbcConnection("DRIVER=Progress OpenEdge 10.2B Driver;****DIL=READ UNCOMMITTED");
// Open your connection
//ApplicationUser currentUser = context.Users.Where(u => u.UserName.Equals(UserName, StringComparison.CurrentCultureIgnoreCase)).FirstOrDefault();
var userid = User.Identity.GetUserId();
List<MenuUserAccess> menuAccess = context.MenuUserAccess.Where(m => m.MenuItemId == menuId).ToList();
var access = menuAccess.FirstOrDefault(o => o.MenuUserId == userid);
if (access != null)
{
odbcConnection.Open();
var menuitem = context.MenuItem.First(m => m.MenuItemId == menuId);
var browseResult = odbcConnection.Query(menuitem.MenuSQLQuery);
odbcConnection.Close();
odbcConnection.Dispose();
return View(browseResult);
}
else
{
return View();
}
}
}
}
This is the view I am using, but not getting any output.
#model IEnumerable<dynamic>
<div>
<h2>BrowseResult</h2>
#if (Model.Count() > 0)
{
ViewBag.Title = "BrowseResult";
WebGrid grid = new WebGrid(source: Model);
#grid.GetHtml()
}
else
{
<p> No Data Found</p>
}
<h2>End</h2>
</div>

You need something like this
#model IEnumerable<dynamic>
<div>
<h2>BrowseResult</h2>
#if (Model.Count() > 0)
{
ViewBag.Title = "BrowseResult";
foreach(dynamic item in Model)
{
<span>#item.MenuName</span>
}
}
else
{
<p> No Data Found</p>
}
<h2>End</h2>
</div>
Returns
name1 name2
There's an example with WebGrid in this link: https://www.w3schools.com/asp/webpages_webgrid.asp

I made it working.
This is my view code.
#model IEnumerable<dynamic>
<div>
#{
int i = 0;
}
<table class="table-striped">
<tr>
#foreach (KeyValuePair<string, object> kvp in Model.ElementAt(1))
{
// This will be the column heading
<td> <b> #kvp.Key </b></td>
}
</tr>
#foreach (var d in Model)
{
<tr>
#foreach (KeyValuePair<string, object> kvp in Model.ElementAt(i))
{
//This will be the row data
<td> #kvp.Value </td>
}
</tr>
i++;
}
</table>
</div>

Related

SqlException: Cannot insert the value NULL into column 'CarId', table 'AutoServiceDb.dbo.ServiceOrders'; column does not allow nulls. INSERT fails

When I want to add a new entry it throws an error
SqlException: Cannot insert the value NULL into column 'CarId', table 'AutoServiceDb.dbo.ServiceOrders'; column does not allow nulls. INSERT fails. The statement has been terminated.
Below is the controller code, DTO, service and Blazor contoller
using System;
using Microsoft.AspNetCore.Mvc;
using AutoService.Domain.Entities;
using AutoService.Application.Interfaces;
using System.Threading.Tasks;
using AutoService.API.Models;
using AutoMapper;
using AutoService.Application.DTOs;
namespace AutoService.API.Controllers
{
[ApiController]
[Route("[controller]")]
public class ServiceOrderController : ControllerBase
{
private readonly IServiceOrderService _serviceOrder;
private readonly IMapper _mapper;
public ServiceOrderController(IServiceOrderService serviceOrder , IMapper mapper)
{
_serviceOrder = serviceOrder;
_mapper = mapper;
}
[HttpPost("scheduleservice")]
public IActionResult ScheduleService([FromBody] ScheaduleViewModel model)
{
var order = _mapper.Map<ScheaduleViewModel, OrderDTO>(model);
var result = _serviceOrder.ScheduleService(order);
if (result == null) return BadRequest();
return Ok(result);
}
[HttpGet]
public async Task<IActionResult> GetService()
{
var result = await _serviceOrder.GetServicesAsync();
return Ok(result);
}
}
}
OrderDTO
using System;
using System.Collections.Generic;
using System.Text;
namespace AutoService.Application.DTOs
{
public class OrderDTO
{
//create
public string ClientName { get; set; }
public string ClientPhone { get; set; }
public string CarMake { get; set; }
public string CarModel { get; set; }
public string CarPlate { get; set; }
public string CarColor { get; set; }
public DateTime ScheduledDate { get; set; }
}
}
Service
using AutoService.Application.DTOs;
using AutoService.Application.Interfaces;
using AutoService.Domain.Entities;
using AutoService.Infrastructure.Context;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace AutoService.Application.Services
{
public class ServiceOrderService : IServiceOrderService
{
private readonly ServicingContext _context;
public ServiceOrderService(ServicingContext context)
{
_context = context;
}
public async Task CreateService(ServiceOrder serviceOrder)
{
_context.ServiceOrders.Add(serviceOrder);
await _context.SaveChangesAsync();
}
public async Task<List<ServiceOrder>> GetServicesAsync()
{
var result = await _context.ServiceOrders
.Include(c => c.Client)
.Include(k => k.Car)
.ToListAsync();
return result;
}
public ServiceOrder ScheduleService(OrderDTO orderDTO)
{
var client = _context.Clients.FirstOrDefault(c => c.FirstName == orderDTO.ClientName);
if (client == null)
{
_context.Clients.Add(new Client
{
FirstName = orderDTO.ClientName,
PhoneNumber = orderDTO.ClientPhone
});
}
var car = _context.Cars.Where((c => c.Makes == orderDTO.CarMake && c.Model == orderDTO.CarModel && c.Color == orderDTO.CarColor && c.LicensePlate == orderDTO.CarPlate)).FirstOrDefault();
if (car == null)
{
var entity = _context.Cars.Add(new Car
{
Makes = orderDTO.CarMake,
Model = orderDTO.CarModel,
Color = orderDTO.CarColor,
LicensePlate = orderDTO.CarPlate
});
}
var serviceOrder = _context.Add(new ServiceOrder
{
Client = client,
Car = car,
ScheduledTime = orderDTO.ScheduledDate,
CreationDate = DateTime.UtcNow
});
_context.SaveChanges();
return serviceOrder.Entity;
}
}
Blazor page AddNewOrder
#page "/addServiceOrder"
#using System.Text.Json
#using System.Text
#using AutoService.API.Models
<link rel="stylesheet" href="css/bootstrap/bootstrap.min.css" />
<link href="css/site.css" rel="stylesheet" />
<form method="post">
<table>
<label ></label>
<tr>
<td>Client name:</td>
<td><input #bind="ClientName" /></td>
</tr>
<tr>
<td>Client phone</td>
<td><input #bind="ClientPhone" /></td>
</tr>
<tr>
<td>Car model</td>
<td><input #bind="CarModel" /></td>
</tr>
<tr>
<td>Car make</td>
<td><input #bind="CarMake" /></td>
</tr>
<tr>
<td>Car plate</td>
<td><input #bind="CarPlate" /></td>
</tr>
<tr>
<td>Car color</td>
<td><input #bind="CarColor" /></td>
</tr>
<tr>
<td>Scheduled date</td>
<td><input #bind="ScheduledDate" /></td>
</tr>
</table>
<a class="btn btn-secondary" href="serviceOrder">Back</a>
<button type="button" class="btn btn-primary" #onclick="AddNewOrder">✔Add</button> #Alert
<p />
</form>
<h1>Add service order</h1>
<p />
#code {
#inject IHttpClientFactory clientFactory;
protected string ClientName { get; set; }
protected string ClientPhone { get; set; }
protected string CarMake { get; set; }
protected string CarModel { get; set; }
protected string CarPlate { get; set; }
protected string CarColor { get; set; }
protected DateTime ScheduledDate { get; set; }
protected string Alert { get; set; }
protected async Task AddNewOrder()
{
Alert = " ";
if (ClientName == string.Empty || ClientPhone == string.Empty || CarMake == string.Empty || CarModel == string.Empty || CarPlate == string.Empty || CarColor == string.Empty || ScheduledDate == DateTime.Now)
{
Alert = "Fill all fields!";
return;
}
Alert = "Added new order";
var _client = clientFactory.CreateClient();
ScheaduleViewModel _newOrder = new ScheaduleViewModel { ClientName = ClientName, ClientPhone = ClientPhone, CarMake = CarMake, CarModel = CarModel, CarPlate = CarPlate, CarColor = CarColor, ScheduledDate = ScheduledDate, };
var _content = new StringContent(JsonSerializer.Serialize(_newOrder), Encoding.UTF8, "application/json");
await _client.PostAsync("https://localhost:5001/ServiceOrder/scheduleservice", _content);
}
}
Blazor page "ServiceOrder"
#page "/serviceOrder"
#using AutoService.Domain.Entities
#using System.Text.Json
<h1>Service order</h1>
<p />
<a class="btn btn-primary" href="addServiceOrder">✒Add order</a>
<p />
#if (ServiceOrdersList == null)
{
<div>Loading...</div>
}
else
{
<table class="table">
<thead>
<tr>
<td>Id</td>
<td>Firs name owner</td>
<td>Car model</td>
<td>Creation </td>
<td>Scheduled time</td>
</tr>
</thead>
<tbody>
#foreach (var serviceOrder in ServiceOrdersList)
{
<tr>
<td>#serviceOrder.Id</td>
<td>#serviceOrder.Client.FirstName</td>
<td>#serviceOrder.Car.Model</td>
<td>#serviceOrder.CreationDate</td>
<td>#serviceOrder.ScheduledTime</td>
</tr>
}
</tbody>
</table>
}
#code {
public List<ServiceOrder> ServiceOrdersList { get; set; }
#inject IHttpClientFactory _clientFactory;
protected string info;
protected override async Task OnInitializedAsync()
{
var client = _clientFactory.CreateClient();
var result = await client.GetAsync("https://localhost:5001/serviceOrder");
info = await result.Content.ReadAsStringAsync();
var options = new JsonSerializerOptions
{
IgnoreNullValues = true,
PropertyNameCaseInsensitive = true
};
ServiceOrdersList = JsonSerializer.Deserialize<List<ServiceOrder>>(info, options);
}
}
enter image description here
Car model
using System;
using System.Collections.Generic;
using System.Text;
namespace AutoService.Domain.Entities
{
public class Car
{
public int Id { get; set; }
public string Makes { get; set; }
public string Model { get; set; }
public string Color { get; set; }
public string LicensePlate { get; set; }
}
}
It looks like you are not assigning the new 'entity' to your 'car' object you are trying to create...
var car = _context.Cars.Where(...).FirstOrDefault();
if (car == null)
{
var entity = _context.Cars.Add(new Car
{
...
});
}
var serviceOrder = _context.Add(new ServiceOrder
{
Client = client,
Car = car, // <-- 'car' is still null when you assign it's value to the service order
...
}
Try adding something like this:
var car = _context.Cars.Where(...).FirstOrDefault();
if (car == null)
{
car = new Car // Assign the new car to the null car variable.
{
...
};
_context.Cars.Add(car); // Then add it to the context.
}
Because the 'ServiceOrder.Car' property is null when are trying to insert it into SQL the database tries to insert NULL into CarId.

How can I display a model property name that is coming from the database?

I currently am pulling a list of url's from a view using Entity Framework 5 and MVC 5. I have the view populating all the links but I need each link to display their 'LinkState' names like in my model so it will output:
Alabama
Georgia
etc.
with the link attached to the LinkState. Instead of the view foreach loop saying State Link. I cant get my model/controlled to pull the correct information.
Repository:
public class LinkRepository
{
private readonly LinkLibrary _entities = new LinkLibrary ();
public LinkRepository()
{
_entities = new LinkLibrary ();
}
public List<LinkModels> RetrieveStateLink(string year)
{
return
_entities.vw_URLLibrary.Where(s => s.YEAR.Equals(year) && s.URL_TYPE.Equals("United States")).Select(m => new LinkModels()
{
UrlLink = m.LinkLocation
}).ToList();
}
}
Model
public class LinkModels
{
public string LinkYear { get; set; }
public string LinkState { get; set; }
public string UrlLink { get; set; }
public string LinkType { get; set; }
public List<string> ListOfUrls{ get; set; }
}
Controller
public ActionResult GetStateLinks()
{
var stateLink = new List<string>();
var model = rr.RetrieveStateLinks("2014").Select(m=> m.UrlLink).ToList();
foreach (var s in model)
{
stateLink.Add(s);
}
var rm = new LinkModels();
rm.ListOfUrls = stateLink;
return View(rm);
}
View
#foreach (var item in Model.StateLinkList)
{
<td>
State Link
</td>
}
Your issue is that you are returning a List of strings as opposed to a list of LinkModels. I updated the repository to return the url and link name
removed some unneccessary code in your controller and updated it to work with a list of LinkObjects. Then updated the view to display the info.
You will have to update your view #model List<LinkModels> instead of #model List<string>
public class LinkRepository
{
private readonly LinkLibrary _entities = new LinkLibrary ();
public LinkRepository()
{
_entities = new LinkLibrary ();
}
public List<LinkModels> RetrieveStateLink(string year)
{
return
_entities.vw_URLLibrary.Where(s => s.YEAR.Equals(year) && s.URL_TYPE.Equals("United States")).Select(m => new LinkModels()
{
LinkState = m.LinkState,
UrlLink = m.LinkLocation
}).ToList();
}
}
public ActionResult GetStateLinks()
{
var stateLink = new List<LinkModels>();
var model = rr.RetrieveStateLinks("2014");
return View(model);
}
#foreach (var item in Model)
{
<td>
#item.LinkState
</td>
}
Controller
public ActionResult GetStateLinks()
{
var model = rr.RetrieveStateLinks("2014");
return View(model);
}
View (change your view model to list of LinkModels)
#foreach (var item in Model)
{
<td>
#item.LinkState
</td>
}

Html table not populating from ViewModel

I am trying to populate an HTML table with data from a table in my database. The issue is simply that the HTML table is not getting populated with any data.
Here is the ViewModel:
public class TestViewModel
{
public string MatchedId { get; set; }
public string UnmatchedId { get; set; }
public string Auth { get; set; }
public DateTime CreditDate { get; set; }
public string CreditNumber { get; set; }
public decimal CreditAmount { get; set; }
public DateTime DeniedDate { get; set; }
public int DeniedReasonId { get; set; }
public string DeniedNotes { get; set; }
}
Controller Action:
[HttpPost]
public ActionResult UploadValidationTable(HttpPostedFileBase csvFile)
{
var inputFileDescription = new CsvFileDescription
{
SeparatorChar = ',',
FirstLineHasColumnNames = true
};
var cc = new CsvContext();
var filePath = uploadFile(csvFile.InputStream);
var model = cc.Read<Credit>(filePath, inputFileDescription);
try
{
var entity = new Entities();
//model here is the .csv, doesn't have anything to do with this issue
foreach (var item in model)
{
var tc = new TemporaryCsvUpload
{
Id = item.Id,
CreditAmount = item.CreditAmount,
CreditDate = item.CreditDate,
CreditNumber = item.CreditNumber,
DeniedDate = item.DeniedDate,
DeniedReasonId = item.DeniedReasonId,
DeniedNotes = item.DeniedNotes
};
entity.TemporaryCsvUploads.Add(tc);
}
entity.SaveChanges();
System.IO.File.Delete(filePath);
//This is where the database table is getting filled
entity.Database.ExecuteSqlCommand("Insert into CsvReport Select p.Id as MatchedId, case when p.Id is null then t.Id end as UnmatchedId, p.Auth,p.CreditDate, p.CreditNumber,p.CreditAmount, p.DeniedDate,p.DeniedReasonId, p.DeniedNotes from TemporaryCsvUpload t left join PermanentTable p on p.Id = t.Id;");
TempData["Success"] = "Updated Successfully";
}
catch (LINQtoCSVException)
{
TempData["Error"] = "Upload Error: Ensure you have the correct header fields and that the file is of .csv format.";
}
return View("Upload");
}
View:
#model IEnumerable<TestProject.TestViewModel>
#if (Model != null)
{
foreach (var item in Model.Where(x => x.IdMatched != null))
{
<tr>
<td>
#item.MatchedId
</td>
<td>
#item.Auth
</td>
<td>
#item.CreditDate
</td>
<td>
#item.CreditNumber
</td>
<td>
#item.CreditAmount
</td>
<td>
#item.DeniedDate
</td>
<td>
#item.DeniedReasonId
</td>
<td>
#item.DeniedNotes
</td>
</tr>
}
}
It's a little weird because I am populating the database with an SQL command. What am I missing here? Do I need to try and pass it through the controller action? Let me know if you need more information. Thanks!
Edit
I tried to pass the instance through, but I may still be doing it incorrectly:
var testModel = new TestViewModel();
return View("Upload", testModel);
Here is what its padding through:
public class TestViewModel
{
public IEnumerable<Test> Test { get; set; }
}
Made an answer so essentially the view doesn't know what to render you need to pass an actual filled model (in your case an IEnumerable to the view). This can be done using the method:
View("Upload", viewModelList);
Controller.View docs on MSDN
It looks like you are not adding any data to your view model.
If your view model is a collection of Test objects, you need to add some
Test objects to the collection.
var model = new TestViewModel()
{
Test = new List<Test>() { new Test(), new Test(), ... }
}
return View("Upload", model);

Adding multiple values in ViewModel and show them in a view

How can I pass values from a Linq select from multiple tables to a view? I have a model that shows the contents of a page. A page can have multiple contents and which contente can have multiple files.
I have a ViewModel to assembly the information of the contents:
namespace WeChange.ViewModels
{
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Web.Mvc;
public class FicheirosInformationViewModel
{
public int id_filec { get; set; }
public string filenamec { get; set; }
public string fileurlc { get; set; }
public string fileimg { get; set; }
public string fileextc { get; set; }
}
public class FicheirosConteudosViewModel
{
public int id_conteudo { get; set; }
public string conttitle { get; set; }
public string conttext { get; set; }
public DateTime contdate { get; set; }
public ICollection<FicheirosInformationViewModel> FicheirosInformation { get; set; }
}
}
In the controller I have:
public ActionResult Index(FicheirosInformationViewModel FichInfoVM, FicheirosConteudosViewModel FichConteVM)
{
ViewBag.Message = "Academia Page";
var cwc_academia = db.CWC_CONTEUDOS.Include(c => c.CWC_PAGINAS).Where(c => c.CWC_PAGINAS.id_page == 1);
foreach (var itemfile in cwc_academia)
{
var FichesContes = new FicheirosConteudosViewModel();
FichesContes.id_conteudo = itemfile.id_conteudo;
FichesContes.conttitle = itemfile.conttitle;
FichesContes.conttext = itemfile.conttext;
FichesContes.contdate = itemfile.contdate;
var ficheirosconteudos = from c in db.CWC_FILESCONTEUDOS
join d in db.CWC_FICHEIROS on c.idfile equals d.id_file
join e in db.CWC_TIPOSFICHEIROS on d.idfiletype equals e.id_tpfile
join f in db.CWC_EXTENSOESFILES on e.id_tpfile equals f.idtpdoc
where c.idconte == itemfile.id_conteudo
select new FicheirosInformationViewModel()
{
id_filec = d.id_file,
filenamec = d.filename,
fileurlc = d.fileurl,
fileimg = e.tipoimg,
fileextc = f.extensao
};
}
return View(FichConteVM);
}
}
And in the View:
#model IEnumerable<WeChange.ViewModels.FicheirosConteudosViewModel>
#foreach (var item in Model)
{
<div class="divider"><div class="circle"><img src="/Images/orange.png" alt="" /></div></div>
<div id="acad" class="container">
<div class="jumbotron">
<h2>#Html.Raw(item.conttitle)</h2>
#Html.Raw(item.conttext)
</div>
</div>
foreach (var fich in item.FicheirosInformation)
{
#fich.id_filec
<br />
#fich.filenamec
<br />
#fich.fileurlc
}
}
I´m always getting an error:
The model item passed into the dictionary is of type 'WeChange.ViewModels.FicheirosConteudosViewModel', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable`1[WeChange.ViewModels.FicheirosConteudosViewModel]'.
What I´m going wrong?
The view is expecting a collection of FicheirosConteudosViewModel and you have passed a single object to it.
Try this:
return View(ficheirosconteudos);
Which will use the FicheirosInformationViewModel collection from your LINQ statement and then pass it to the View.

Which Model Statement to use in MVC 3

I am very new to MVC 3 framework. I have added an Entity with the EntityFramework 6.0, and in my controller, I would like to query the entity for all "DeviceInterfaces" which belong to a particular device. My view is throwing this error:
The model item passed into the dictionary is of type System.Data.Entity.Infrastructure.DbQuery`1[<>f__AnonymousType1`2[System.String,System.String]], but this dictionary requires a model item of type System.Collections.Generic.IEnumerable`1[FindDevice.DeviceInterfaces].
My Controller:
public ActionResult DeviceName(string name)
{
SampleEntities sampleEntities = new SampleEntities();
try
{
var Model = (from dev in sampleEntities.NetworkDevices
where dev.Name == name
from inter in sampleEntities.DeviceInterfaces
where inter.NetworkDevice.Id == dev.Id
//select inter);
select new { DeviceName = dev.Name, InterfaceName = inter.Name});
return View(Model);
}
catch
{
}
return View();
}
My View:
#model IEnumerable<FindDevice.DeviceInterfaces>
#{
ViewBag.Title = "DeviceName";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<h2>Displaying Device with name "#ViewBag.MyName"</h2>
<table>
<tr>
<th>Device</th>
<th>Interface</th>
<th>IPv4 Address</th>
<th>Subnet Mask</th>
<th>CIDR</th>
<th>Network</th>
</tr>
#foreach (var item in Model)
{
<tr>
<td>item.NetworkDevice.Name</td>
<td>#item.Name</td>
<td>#item.IPv4Address</td>
<td>#item.IPv4SubnetMask</td>
<td>#item.CIDR</td>
<td>#item.Subnet</td>
</tr>
}
I understand why the error is thrown, what I don't understand is what I can change my #model statement to so that I can display the Device Name, as well as the Interface Name and all other interface properties in this view.
I'd suggest using a strongly typed model. Add the below class in Models folder
public class DeviceInterfaceModel
{
public string DeviceName { get; set; }
public string InterfaceName { get; set; }
public string IPv4Address { get; set; }
public string IPv4SubnetMask { get; set; }
public string CIDR { get; set; }
public string Subnet { get; set; }
}
Then map the query results to a List<DeviceInterfaceModel> in your controller
public ActionResult DeviceName(string name)
{
SampleEntities sampleEntities = new SampleEntities();
try
{
var model = (from dev in sampleEntities.NetworkDevices
where dev.Name == name
from inter in sampleEntities.DeviceInterfaces
where inter.NetworkDevice.Id == dev.Id
select new DeviceInterfaceModel
{
DeviceName = dev.Name,
InterfaceName = inter.Name,
IPv4Address = inter.IPv4Address,
IPv4SubnetMask = inter.IPv4SubnetMask,
CIDR = inter.CIDR,
Subnet = inter.Subnet
}).ToList();
return View(model);
}
catch
{
}
return View();
}
and change the model type to IEnumerable<DeviceInterfaceModel> in your view
#model IEnumerable<DeviceInterfaceModel>
#{
ViewBag.Title = "DeviceName";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<h2>Displaying Device with name "#ViewBag.MyName"</h2>
<table>
<tr>
<th>Device</th>
<th>Interface</th>
<th>IPv4 Address</th>
<th>Subnet Mask</th>
<th>CIDR</th>
<th>Network</th>
</tr>
#foreach (var item in Model)
{
<tr>
<td>#item.DeviceName</td>
<td>#item.InterfaceName</td>
<td>#item.IPv4Address</td>
<td>#item.IPv4SubnetMask</td>
<td>#item.CIDR</td>
<td>#item.Subnet</td>
</tr>
}

Categories

Resources