Tuesday, May 14, 2024
Homepage · c#
 Popular · Latest · Hot · Upcoming
172
rated 0 times [  179] [ 7]  / answers: 1 / hits: 5946  / 2 Years ago, thu, november 17, 2022, 12:00:00

I am coding in asp.net mvc and I am trying to implement the table of DataTables.net but I get this error:
DataTables warning: table id=abc - Incorrect column count. For more information about this error, please see http://datatables.net/tn/18


This is my table:


<table id="abc" class="display table-bordered table-hover">
<tr>
<th>
@Html.DisplayNameFor(model => model.StudentID)
</th>
<th>
@Html.DisplayNameFor(model => model.FirstName)
</th>
<th>
@Html.DisplayNameFor(model => model.LastName)
</th>
<th>
@Html.DisplayNameFor(model => model.Program)
</th>
<th>
@Html.DisplayNameFor(model => model.YearGraduate)
</th>
<th>
@Html.DisplayNameFor(model => model.BoardScore)
</th>
<th>Action</th>
</tr>

@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.StudentID)
</td>
<td>
@Html.DisplayFor(modelItem => item.FirstName)
</td>
<td>
@Html.DisplayFor(modelItem => item.LastName)
</td>
<td>
@Html.DisplayFor(modelItem => item.Program)
</td>
<td>
@Html.DisplayFor(modelItem => item.YearGraduate)
</td>
<td>
@Html.DisplayFor(modelItem => item.BoardScore)
</td>
<td>
@Html.ActionLink("Edit", "Edit", new { id = item.StudentID }, new { @class = "btn btn-primary" }) &nbsp;&nbsp;&nbsp;
@Html.ActionLink("Details", "Details", new { id = item.StudentID }, new { @class = "btn btn-success" })&nbsp;&nbsp;&nbsp;
@Html.ActionLink("Delete", "Delete", new { id = item.StudentID }, new { @class = "btn btn-danger" })
</td>
</tr>
}

</table>

More From » c#

 Answers
7

Your table is incorrect you are missing <thead> and <tbody> tags.


this is a valid table:


<table>
<thead>
<tr>
<th>
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
</td>
</tr>
</tbody>
</table>

[#12] Thursday, August 11, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
samaraanandah

Total Points: 94
Total Questions: 86
Total Answers: 99

Location: Montenegro
Member since Thu, Jun 16, 2022
2 Years ago
samaraanandah questions
Mon, Jul 13, 20, 00:00, 4 Years ago
Fri, Jul 3, 20, 00:00, 4 Years ago
Thu, Aug 29, 19, 00:00, 5 Years ago
Thu, May 9, 19, 00:00, 5 Years ago
Tue, May 7, 19, 00:00, 5 Years ago
;