如何创建Mvc4 WebGrid用于显示任何表的数据? [英] How to Create Mvc4 WebGrid for that display the data of any table?

查看:83
本文介绍了如何创建Mvc4 WebGrid用于显示任何表的数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在MVC4中创建一个Webgrid来显示表数据,并且工作正常但我想创建一个适用于任何表的webgrid意味着列的数量不应该是硬编码的,列名应该是表的列名。我怎么做?

I create a Webgrid in MVC4 to show a table data, and works perfect but i want to create a webgrid that work for any table means number of column should not be hard coded and column name should be table's column name. How i can do it?

推荐答案

在这里查看解决方案



如何在运行时创建模型? [ ^ ]
See solution here

how to create model at run time?[^]


您必须为此返回HTML帮助程序。您必须动态生成的相同html代码以及网格中的任何硬编码值将作为输入参数动态传递给帮助程序。

请查看以下链接以获取MVC中创建HTML帮助程序的参考/>
http://www.asp.net/mvc/tutorials/older-versions/views/creating-custom-html-helpers-cs [ ^ ]
You have to return the HTML helper for that. The same html code you have to generate dynamically and what ever hard coded values in your grid will be passed dynamically to helper as input parameters.
Please check the below link for reference creating HTML helper in MVC
http://www.asp.net/mvc/tutorials/older-versions/views/creating-custom-html-helpers-cs[^]


这篇关于如何创建Mvc4 WebGrid用于显示任何表的数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆