Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/asp.net-mvc-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 是否可以使用mvc3显示具有动态列的表记录_Asp.net_Asp.net Mvc 3_C# 4.0_Dynamic Programming_Data Access Layer - Fatal编程技术网

Asp.net 是否可以使用mvc3显示具有动态列的表记录

Asp.net 是否可以使用mvc3显示具有动态列的表记录,asp.net,asp.net-mvc-3,c#-4.0,dynamic-programming,data-access-layer,Asp.net,Asp.net Mvc 3,C# 4.0,Dynamic Programming,Data Access Layer,我正在与asp合作。Net mvc3,我使用sql server 2008作为后端。我必须在前端显示一个表,该表将具有动态列。例如,在c中是否有可能在第一次执行存储过程时,它将返回4列值,下次它将返回5列值,当向后端中的表在asp.NETMVC3中是否可能?你们中有人遇到过这样的情况吗?首先,我认为如果使用类似ORM的实体框架,而不是ADO.NET,可能会更容易 对于前端,我建议使用Grid.MVC。这里有一个简单的例子让你开始 对于前端,您可以在cshtml文件中使用if,例如: @{

我正在与asp合作。Net mvc3,我使用sql server 2008作为后端。我必须在前端显示一个表,该表将具有动态列。例如,在c中是否有可能在第一次执行存储过程时,它将返回4列值,下次它将返回5列值,当向后端中的表在asp.NETMVC3中是否可能?你们中有人遇到过这样的情况吗?

首先,我认为如果使用类似ORM的实体框架,而不是ADO.NET,可能会更容易

对于前端,我建议使用Grid.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。

如果我在后端表中添加新列,是否可以在前端添加而不添加其属性?例如,如果在部署代码后添加的列,是否可以在前端添加相同的列而不进行任何代码更改?如果模型没有映射列,它将不会显示在前端。另一方面,如果您想显示它,EF可以非常轻松地执行SQL查询。此外,您还可以从操作返回网格的html作为ContentResult,并在后端生成html。