3
Answers

Help me find the problem

Schleid Alex

Schleid Alex

4y
438
1
@using System.Data
@model DataSet
@{
    Layout = null;
}
@{
    ViewBag.Title = "Index";
}

<h2>Index</h2>


<!DOCTYPE html>



<table table-striped >
    <tr>
        @foreach (DataColumn dc in Model.Tables[0].Columns)
        {

            <th>
                @dc.ColumnName
            </th>
        }
    </tr>
       
    @foreach (DataRow dr in Model.Tables[0].Rows)
    {
        <tr>
            @for (int i = 0; i <= Model.Tables[0].Rows.Count + 1; i++)
            {
                <td>
                    @dr[Model.Tables[0].Columns[i]]
                </td>
            }
        </tr>
    }
</table>

The above code is supposed to show value from a dataset in a table where I use the column name as table header.
But this is far from showing me the result in a table, I dunno why.
 
 
 
Thank in advance
 
Alex
Answers (3)