如何将ENUM值从视图转换为字符串到控制器 [英] How to convert the ENUM value to String from view to a controller
本文介绍了如何将ENUM值从视图转换为字符串到控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
** Enum statecode = apsp.Customer.BillingAddress.StateCode.Value; **
Customer = new Customer()
{
FirstName = fn,
LastName = ln,
BillingAddress = new Address
{
StreetAddress1 = street1,
StreetAddress2 = street2,
City = city,
** StateCode = statecode **,
ZipCode = zipcode
}
},
所以我想插入这个的值..
Enum statecode = apsp.Customer.BillingAddress.StateCode.Value;
到此枚举
StateCode = statecode,
解决方案
Enum statecode = apsp.Customer.BillingAddress.StateCode;
Customer = new Customer()
{
FirstName = fn,
LastName = ln,
BillingAddress = new Address
{
StreetAddress1 = street1,
StreetAddress2 = street2,
City = city,
StateCode =(StateCode)statecode,
ZipCode = zipcode
}
},
So I already know how to get the string,int,decimal and now I'm struggling in this part of enum. How can I convert my enum into a string
**Enum statecode = apsp.Customer.BillingAddress.StateCode.Value;**
Customer = new Customer()
{
FirstName = fn,
LastName = ln,
BillingAddress = new Address
{
StreetAddress1 = street1,
StreetAddress2 = street2,
City = city,
**StateCode = statecode**,
ZipCode = zipcode
}
},
so I want to insert the value of this..
Enum statecode = apsp.Customer.BillingAddress.StateCode.Value;
to this enum
StateCode = statecode,
解决方案
Enum statecode = apsp.Customer.BillingAddress.StateCode;
Customer = new Customer()
{
FirstName = fn,
LastName = ln,
BillingAddress = new Address
{
StreetAddress1 = street1,
StreetAddress2 = street2,
City = city,
StateCode = (StateCode)statecode,
ZipCode = zipcode
}
},
这篇关于如何将ENUM值从视图转换为字符串到控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文