I have created a data table in my razor.cs file with C# and filled it with data. I want to show this datable in my razor page on screen in html table format. How can I do that? Is it possible to show the data table in total, or do I have to show the elements one by one? I have tried in this way but get always the error: System.Data.DuplicateNameException: A column named '---' already belongs to this DataTable. The table comes empty/
public DataTable Programs_WMI_total = new DataTable();
for(int m=1; m< Programs_WMI_total.GetLength(1);m++)
{
Programs_WMI_name_sorted[m] = WMI_Programs_table.Rows[m][0].ToString();
Programs_WMI_publisher_sorted[m] = WMI_Programs_table.Rows[m][1].ToString();
Programs_WMI_installdate_sorted[m] = WMI_Programs_table.Rows[m][2].ToString();
Programs_WMI_installlocation_sorted[m] = WMI_Programs_table.Rows[m][3].ToString();
}
on the razor side:
@{if (@Programs_WMI_name[0] != null && Programs_number!=0)
{
<tr>
<td class=table_header>Program name</td>
<td class=table_header>Publisher</td>
<td class=table_header>Install. date</td>
<td class=table_header>Install. path</td>
</tr>
for (var i = 0; i < Programs_number; i++)
{
if (@Programs_WMI_name[i] != "")
{
<tr>
<td>@Programs_WMI_name_sorted[i]</td>
<td>@Programs_WMI_publisher_sorted[i]</td>
<td>@Programs_WMI_installdate_sorted[i]</td>
<td>@Programs_WMI_installlocation_sorted[i]</td>
</tr>
}
}
}
}