本文转自:http://stackoverflow.com/questions/2243898/displaying-standard-datatables-in-mvc

Controller action:

public ActionResult Index()
{
ViewData["Message"] = "Welcome to ASP.NET MVC!"; DataTable dt = new DataTable("MyTable");
dt.Columns.Add(new DataColumn("Col1", typeof(string)));
dt.Columns.Add(new DataColumn("Col2", typeof(string)));
dt.Columns.Add(new DataColumn("Col3", typeof(string))); for (int i = ; i < ; i++)
{
DataRow row = dt.NewRow();
row["Col1"] = "col 1, row " + i;
row["Col2"] = "col 2, row " + i;
row["Col3"] = "col 3, row " + i;
dt.Rows.Add(row);
} return View(dt); //passing the DataTable as my Model
}
View: (w/ Model strongly typed as System.Data.DataTable) <table border="">
<thead>
<tr>
<%foreach (System.Data.DataColumn col in Model.Columns) { %>
<th><%=col.Caption %></th>
<%} %>
</tr>
</thead>
<tbody>
<% foreach(System.Data.DataRow row in Model.Rows) { %>
<tr>
<% foreach (var cell in row.ItemArray) {%>
<td><%=cell.ToString() %></td>
<%} %>
</tr>
<%} %>
</tbody>
</table>

[转]Displaying standard DataTables in MVC的更多相关文章

  1. Mvc.JQuery.Datatables

    1.NuGet安装Mvc.JQuery.Datatables.Mvc.JQuery.Datatables.Templates和JQuery.Datatables https://github.com/ ...

  2. Swagger+Spring mvc生成Restful接口文档

    简介 Swagger 是一个规范和完整的框架,用于生成.描述.调用和可视化 RESTful 风格的 Web 服务.总体目标是使客户端和文件系统作为服务器以同样的速度来更新.文件的方法,参数和模型紧密集 ...

  3. Swagger+ springfox +Spring mvc

    简介 Swagger 是一个规范和完整的框架,用于生成.描述.调用和可视化 RESTful 风格的 Web 服务.总体目标是使客户端和文件系统作为服务器以同样的速度来更新.文件的方法,参数和模型紧密集 ...

  4. 向现有mvc程序中加入devexpress report

    Open your ASP.NET MVC project. In the main menu of Visual Studio, click the DEVEXPRESS submenu and s ...

  5. ASP.NET MVC- VIEW Creating Page Layouts with View Master Pages Part 4

    In this tutorial, you learn how to create a common page layout for multiple pages in your applicatio ...

  6. .Net Core 系列:2、ADO.Net 基础

    目录: 1.环境搭建 2.ADO.Net 基础 3.ASP.Net Core 基础 4.MD5.Sha256.AES 加密 5.实现登录注册功能 6.实现目录管理功能 7.实现文章发布.编辑.阅览和删 ...

  7. ABP框架系列之十二:(Audit-Logging-审计日志)

    Introduction Wikipedia: "An audit trail (also called audit log) is a security-relevant chronolo ...

  8. Websocket @serverendpoint 404

    今天写一个前后端交互的websocket , 本来写着挺顺利的,但测试的时候蒙了,前端websocket发的连接请求竟然连接不上 返回状态Status 报了个404 ,然后看后台onError方法也没 ...

  9. Datatables 在asp.net mvc中的使用

    前言 最近使用ABP(ASP.NET Boilerplate)做新项目,以前都是自己扩展一个HtmlHelper来完成同步/异步分页,但是有个地方一直不满意,排序太费劲. 以前接触过一点点的Datat ...

随机推荐

  1. 《Java程序员修炼之道》

    原子类:java.util.concurrent.atomic 线程锁:java.util.concurrent.locks 对付死锁:boolean acquired = lock.tryLock( ...

  2. Gartner:Hype Cycle for Emerging Technologies-2013

      The “Hype Cycle for Emerging Technologies” report is the longest-running annual Hype Cycle, provid ...

  3. css 精灵的用法

    (从已经死了一次又一次终于挂掉的百度空间人工抢救出来的,发表日期2014-02-12) 是指将多个图整合到一张图上,避免多次请求服务器下载. 主要使用CSS background-position 属 ...

  4. IOS学习经验总结--来自知乎网友

    转自知乎:http://www.zhihu.com/question/20016551 我当时刚学iOS开发的时候一样的感觉 总想知道原理 内部怎么回事 感觉在像在雾里但是iOS开发就是这样 他是封闭 ...

  5. windows无法搜索新更新 80072ee2

      http://windows.microsoft.com/zh-cn/windows/windows-update-error-80072ee2#1TC=windows-7    

  6. 导入word数据

    public static List<FL> ImportDOC(object fileName,out StringBuilder meg)        { List<FL> ...

  7. Fitness training

    2014-01-14 第一次跑步,结束后大腿酸. 2014-01-15 第二次跑步,跑的过程中臀部酸痛,结束后大腿酸痛. 已经进行跑步8次了,后6次,每次3000米 2014-02-06  plank ...

  8. Maven实战之Quick Start

    Introduction Maven是一个异常强大的构建工具,能够帮我们自动化构建过程,从清理.编译.测试到生成报告,再到打包和部署.通过Maven,我们只需要输入简单的命令(如mvn clean i ...

  9. Swift - 本地消息的推送通知(附样例)

    使用UILocalNotification可以很方便的实现消息的推送功能.我们可以设置这个消息的推送时间,推送内容等. 当推送时间一到,不管用户在桌面还是其他应用中,屏幕上方会都显示出推送消息. 1, ...

  10. ACM-最短路(SPFA,Dijkstra,Floyd)之最短路——hdu2544

    ***************************************转载请注明出处:http://blog.csdn.net/lttree************************** ...