sách gpt4 ai đã đi

asp.net-mvc - MVC 帖子未填充模型

In lại 作者:行者123 更新时间:2023-12-04 23:29:25 hai mươi bốn 4
mua khóa gpt4 Nike

我无法弄清楚为什么我的模型没有被填充。所有发布的数据都在 Request.Form 中,但模型实际上是 vô giá trị .

theo this answer on model with collection not populating on postback

In other words, (...) If any required fields are missing, or if the values are submitted in such a way that they cannot be converted to the type of a required field, then the entire object will be left null



我更改了几种值类型,但无法使其正常工作。

这是我的模型:

public class AddModel
{
//Get properties
public Vehicle vehicle;

//Post properties
[Required(ErrorMessage = "Please enter a start date")]
public DateTime StartDate;
public int? StatusCode;

public SelectList StatusCodes()
{
...
}
}

你能想到为什么它没有被填充吗?

1 Câu trả lời

制作 AddModel成员(member)Properties - 添加 get; set;到字段应该可以解决您的问题

关于asp.net-mvc - MVC 帖子未填充模型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7335035/

hai mươi bốn 4 0
行者123
Hồ sơ cá nhân

Tôi là một lập trình viên xuất sắc, rất giỏi!

Nhận phiếu giảm giá Didi Taxi miễn phí
Mã giảm giá Didi Taxi
Giấy chứng nhận ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com