Hi rani,
Using the below article i have created the example.
Model
public class CustomerModel
{
public int Id { get; set; }
public string Name { get; set; }
public Phone Phone { get; set; }
}
public class Phone
{
public string Office { get; set; }
public string Home { get; set; }
}
Controller
public class HomeController : Controller
{
public IActionResult Index()
{
CustomerModel customers = new CustomerModel
{
Id = 1,
Name = "Maria Anders",
Phone = new Phone
{
Home = "030-0074321",
Office = "030-0076545"
}
};
return View(customers);
}
}
View
Index
@model PartialView_Core.Models.CustomerModel
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Index</title>
</head>
<body>
<table>
<tr>
<th>Id</th>
<th>Name</th>
<th>Phone</th>
</tr>
<tr>
<td>@Model.Id</td>
<td>@Model.Name</td>
<td>@Html.Partial("_Phone.cshtml", Model.Phone) </td>
</tr>
</table>
</body>
</html>
PartialView
@model PartialView_Core.Models.Phone
<table>
<tr>
<th>Office</th>
<th>Home</th>
</tr>
<tr>
<td>@Model.Office</td>
<td>@Model.Home</td>
</tr>
</table>
Screenshot