
Untitled
By: a guest on
Jul 24th, 2012 | syntax:
None | size: 1.37 KB | hits: 23 | expires: Never
linq and json, anonymous type cannot have multiple properties with the same name
var jsonData = new
{
total = totalPages,
page = page,
records = totalRecords,
rows = reservations.Select(x => new { x.ReservationId, x.Employee.Name,roomName = x.Room.Name, x.Date, x.StartTime, x.EndTime, x.Notes}).ToList()
.Select(x => new
{
id = x.ReservationId,
cell = new string[]
{
roomName,
x.Name,
x.Date.ToString().Split(' ')[0],
x.StartTime.ToString().Remove(5) +" - " +x.EndTime.ToString().Remove(5),
x.Notes,
String.Format("<input type="button" value="DETAILS" onclick="window.location.href='/Reservation/Details/{0}'"/>   <input type="button" value="EDIT" onclick="window.location.href='/Reservation/Edit/{0}'"/>   <input type="button" value="DELETE" onclick="window.location.href='/Reservation/Delete/{0}'"/>", x.ReservationId),
}
}).ToArray(),
};
$('#grid').jqGrid({
colNames: [ 'roomName', 'Name', ..... other columns ],
colModel: [
{ name: 'roomName', index: 'roomName' },
{ name: 'Name', index: 'Name' },
.....
],
........
});