Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/15.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 mvc 我想构建asp.net mvc应用程序,我不想依赖ID_Asp.net Mvc - Fatal编程技术网

Asp.net mvc 我想构建asp.net mvc应用程序,我不想依赖ID

Asp.net mvc 我想构建asp.net mvc应用程序,我不想依赖ID,asp.net-mvc,Asp.net Mvc,我有一个名为country的表,它有3列: ID: generated primary key Country_Code : not primary key but it is Unique and in most of the time I will use it Instead of ID. Country_Name : the long name of the country 我不能从上面更改任何东西,这是业务要求 我使用asp.net mvc生成了CURD功能,然后我更改了代码,使其依

我有一个名为country的表,它有3列:

ID: generated primary key
Country_Code : not primary key but it is Unique and in most of the time I will
use it Instead of ID.
Country_Name : the long name of the country
我不能从上面更改任何东西,这是业务要求

我使用asp.net mvc生成了CURD功能,然后我更改了代码,使其依赖于国家代码而不是ID,因此示例中我的详细信息页面url如下所示:

something.com/country/detail/ss

我读、写和删除成功,但在编辑中我未能通过验证语句(ModelState.IsValid)。问题是,当数据来自我的编辑页面时,ID始终为0。

在将ID发布到控制器时,您可以创建一个HiddenFor来保存ID。

您能提供一些代码片段吗?控制器操作是什么样子的?路由表是什么样子的?