Skip to content

Instantly share code, notes, and snippets.

@davidsonsousa
Created July 15, 2019 21:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidsonsousa/b50ef39eca1836e389de5bc67a5e9ab4 to your computer and use it in GitHub Desktop.
Save davidsonsousa/b50ef39eca1836e389de5bc67a5e9ab4 to your computer and use it in GitHub Desktop.
@model List<string>
@using System.Text
@section Styles {
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.19/css/jquery.dataTables.css">
}
@{
var tableHeader = new StringBuilder();
@foreach (var item in Model)
{
tableHeader.Append("<th>");
tableHeader.Append(item);
tableHeader.Append("</th>");
}
}
<div>
<table id="table-list" class="table table-striped table-bordered">
<thead>
<tr>
@Html.Raw(tableHeader.ToString())
</tr>
</thead>
<tfoot>
<tr>
@Html.Raw(tableHeader.ToString())
</tr>
</tfoot>
</table>
</div>
@section Scripts{
<script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.js"></script>
<script type="text/javascript" src="~/js/index.js"></script>
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment