1.通过name获取值
collection.GetValues() 返回一个数组,适用于多选等,如果是单值可以[0]
2.直接转化为实体
将Action动作中传递的FormCollection转变成对应的实体,可以使用Controller的TryUpdateModel()方法
TryUpdateModel<Student>(student, collection);
这种方法比较适合简单的模型
本文共 199 字,大约阅读时间需要 1 分钟。
1.通过name获取值
collection.GetValues() 返回一个数组,适用于多选等,如果是单值可以[0]
2.直接转化为实体
将Action动作中传递的FormCollection转变成对应的实体,可以使用Controller的TryUpdateModel()方法
TryUpdateModel<Student>(student, collection);
这种方法比较适合简单的模型
转载地址:http://gxnbl.baihongyu.com/