mvc的视图中显示DataTable的方法

mvc的视图中显示DataTable的方法:

不断的循环画出table

@{
    ViewBag.Title = "ShowDataTable";
}
@using System.Data;
@model Models.ConModel

@{
    var table = Model.ExcelTable as DataTable;
}

<script src="~/Scripts/My97DatePicker/WdatePicker.js"></script>
<table border=1 cellspacing=0 cellpadding=2>
    <thead>
        <tr>
            @foreach (DataColumn dc in table.Columns)
            {
                <th>
                    @dc.ColumnName
                </th>
            }
        </tr>
    <tbody>
        @foreach (DataRow dr in table.Rows)
        {
            <tr>
              
                @foreach (DataColumn d in table.Columns)
                {
                    <td>
                        @dr[d.ColumnName]
                    </td>
                }

            </tr>
        }
    </tbody>
    </thead>
</table>



<script type="text/javascript">

 

posted @ 2016-04-15 20:45  Percy宣森  阅读(1821)  评论(0编辑  收藏  举报