我正在使用asp。 net mvc3和我使用sql server 2008作为后端。我必须在前端显示一个表,它将有一个动态列是否可以在c#中例如第一次执行存储过程时它将返回带有值的4列,下次返回带有值的5列当我在后端的表中添加一列时,我不应该更改任何代码更改是否可以在asp .net mvc3中?您是否遇到过这样的情况?
答案 0 :(得分:0)
首先,我认为如果你使用像Entity Framework这样的ORM而不是ADO.NET可能会更容易。
对于前端,我建议使用Grid.MVC。这是一个简单的例子,可以帮助您入门 http://www.codeproject.com/Tips/597253/Using-the-Grid-MVC-in-ASP-NET-MVC
对于前端,您可以在cshtml文件中使用if,例如:
@{
if(Model.Property != null) //Receives 4 columns, 1 Property is initialized with NULL
{
//Render grid with 4 columns
}
else // Receives 5 columns, all properties !=null
{
//Render grid with 5 columns
}
}
如果您对javascript感觉更舒服,可以使用jqgrid。