我在asp.net mvc项目中使用datatable插件,而绑定数据则呈现错误的日期时间值
数据库中的实际日期时间值是05-5月19日2:43:33 PM,运行显示的值是/Date(1557060213477)/
它显示数据库中存在的日期时间值的预期结果。
这是我的模型
public int Id { get; set; }
[Required]
public string Name { get; set; }
Display(Name ="Upload File")]
public string FileUrl { get; set; }
public DateTime AddedOn { get; set; }这是我的看法
<table id="DDR" class="table table-striped table-bordered dt-responsive nowrap">
<thead>
<tr>
<th>Id</th>
<th>Name</th>
<th>Uploaded File</th>
<th>Uploaded At</th>
<th>Edit</th>
<th>Delete</th>
</tr>
</thead>
</table>
@section scripts {
<link href="https://cdn.datatables.net/1.10.19/css/dataTables.bootstrap4.min.css" rel="stylesheet" />
<script src="//cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/1.10.19/js/dataTables.bootstrap4.min.js"></script>
<script>
$(document).ready(function () {
debugger;
$("#DDR").DataTable({
"ajax": {
"url": "/DomesticDocRepositories/GetData",
"type": "GET",
"datatype": "json"
},
"columns": [
{
"data": "Id",
render: function (data, type) {
return '<a href="/DomesticDocRepositories/Details/' + data + '">'+data+"</a>";
}
},
{ "data": "Name" },
{
data: "FileUrl",
render: function (data, type) {
return "<a href='/DomesticFiles/" + data + " 'target='_blank''>" + data + "</a>";
}
},
{
"data": "AddedOn",
render: function (data, type) {
return '<span "title='+ data +"'>" + data +"</span>";
}
},
{
"render": function (data, type, full, meta) { return '<a class="btn btn-info" href="/DomesticDocRepositories/Edit/' + full.Id + '">Edit</a>'; }
},
{
data: null, render: function (data, type, row) {
return '<a class="btn btn-danger" href="/DomesticDocRepositories/Delete/' + row.Id + '">Delete</a>';
}
},
]
});
});
</script>
}https://stackoverflow.com/questions/56011365
复制相似问题