0
我尝试了几种方法来获取这个元组列表,在我的cshtml视图中显示为uploadModel.ErrorsList,但没有运气,这只显示对象的类型Errorslist(元组列表int,string,string)是,ErrorMessages(字符串)在屏幕上显示正确的值。这是我的观点:中在C#中显示元组列表的列表
@using Custom.Website.Areas.Custom.Models
@model Custom.Website.Areas.Custom.Models.ExcelUploadModel
<style type="text/css">
#ExcelUploadForm {
text-align: center;
}
</style>
<div id="ExcelUploadForm" title="Excel Upload Results">
<h2 id="requireReUpload" style="color:darkred">Please fix the following errors and reupload:</h2>
<h2 id="uploadSuccess" style="color:green">Your Upload was successful. @Model.UploadedRowCount tickets updated.</h2>
<div>Editable fields: Transporter Ticket #,Transporter, Driver, Truck, AFE #, Water Type, Quantity, Operator Job #, Lease.</div>
<div>
<ul id="uploadErrors"></ul>
</div>
<button class="backButton">Back</button>
</div>
<script type="text/javascript">
document.getElementById("requireReUpload").style.display = 'none';
document.getElementById("uploadSuccess").style.display = 'none';
$(document).ready(function() {
$('#uploadErrors').append('<li>@Model.ErrorMessage</li>');
$('#uploadErrors').append('<li>@Model.ErrorsList</li>');
//This function checks if the Error list contains any value.
function excelUploadMessage() {
// If Error List has nothing, display Success
if ($('ul#uploadErrors:not(:has(li)')) {
document.getElementById("uploadSuccess").style.display = 'block';
} // Otherwise, display reupload message
else {
document.getElementById("requireReUpload").style.display = 'block';
}
}
excelUploadMessage();
});
$('.backButton').click(function() {
window.history.back();
});
</script>
完美工作。非常感谢mymo! –