Data is not display in Partail View
Below is my Class RoomDetailsMV
public class RoomDetailsMV
{
public int RoomId { get; set; }
public string RoomNumber { get; set; }
public string RoomDescriptionitem { get; set; }
public int? RoomCapacity { get; set; }
public string RoomImage { get; set; }
public decimal? RoomPrice { get; set; }
public string BookingStatus { get; set; }
public string RoomTypeName { get; set; }
}
It has Partial View Below
@model IEnumerable<HotelSM.ViewModel.RoomDetailsMV>
<table style="width:100%">
<thead>
<tr>
<th>Action:</th>
<th>Room Image</th>
<th>Room No:</th>
<th>Room Price:</th>
<th>Booking Status:</th>
<th>Room Type:</th>
<th>Room Capacity:</th>
<th>Room Description:</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<td></td>
<td><img src=@Url.Content("~/RoomImages/" + item.RoomImage) width="30" height="30" class="img-responsive"/></td>
<td>@item.RoomNumber</td>
<td>@item.RoomPrice</td>
<td>@item.BookingStatus</td>
<td>@item.RoomCapacity</td>
<td>@item.RoomDescriptionitem</td>
</tr>
}
</tbody>
</table>
RoomControllor
public PartialViewResult GetAllRooms()
{
IEnumerable<RoomDetailsMV> listOfRoomDetailViewModels =
(from objRoom in objDB.HotelRooms
join objBooking in objDB.BookingStatus on objRoom.BookIngStatusid equals objBooking.BookingStatusid
join objRoomType in objDB.RoomTypes on objRoom.RoomTypeid equals objRoomType.RoomTypeid
select new RoomDetailsMV()
{
RoomNumber = objRoom.RoomNumber,
RoomDescriptionitem = objRoom.RoomDescription,
RoomCapacity = objRoom.RoomCapacity,
RoomPrice = objRoom.RoomPrice,
BookingStatus = objBooking.BookingStatus,
RoomTypeName = objRoomType.RoomTypeName,
RoomImage = objRoom.RoomImage,
RoomId = objRoom.Roomid
}).ToList();
return PartialView("_RoomDetailPartial.cshtml", listOfRoomDetailViewModels);
}
Using index for redirecting on Partial View
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
LoadRoomDetails();
$("#btnSave").click(function () {
SaveRoomData();
});
});
function LoadRoomDetails() {
$.ajax({
async: true,
data: 'GET',
dataType: 'HTML',
contentType: false,
processData: false,
url: '/Room/GetAllRooms',
success: function (data) {
$("#divLoadRoomDetails").html(data);
},
error: function () {
alert('There Is some problem to process your request.');
}
});
}
<div style="margin-top: 70px"></div>
<div id="divLoadRoomDetails">
</div>