mvc html 文本,访问文本字段的MVC Html.DropDownList

我在访问Html.DropdownList的选定值中的文本字段时遇到问题。

我的ViewModel是

public class UserViewModel

{

public List SupportedCurrency

{

get;

set;

}

public string DefaultCurrency

{

get;

set;

}

}

我的控制器将下拉列表填充为下方。

public List GetSupportedCurrencies(string setupValue)

{

List items = new List();

try

{

IList currencyList = Helper.GetFormattedCurrenciesList(CurrenciesService.GetSupportedCurrencies());

foreach (Currency c in currencyList)

{

if (!string.IsNullOrEmpty(setupValue) && c.CurrencyCode.Equals(setupValue))

{

items.Add(new SelectListItem

{

Text = c.CurrencyDescription,

Value = c.CurrencyCode,

Selected = true

});

}

else

{

items.Add(new SelectListItem

{

Text = c.CurrencyDescription,

Value = c.CurrencyCode

});

}

}

}

catch (Exception ex)

{

throw ex

}

return items;

}

[AcceptVerbs(HttpVerbs.Get)]

public ActionResult Index()

{

userViewData.SupportedCurrency = GetSupportedCurrencies(userModelData.DefaultCurrency);

SelectList SupportedCurrencyList = new SelectList(userViewData.SupportedCurrency, "CurrencyCode", "CurrencyDescription");

.........

}

在视图索引中

<%= Html.DropDownList(“userViewModel.DefaultCurrency”,Model.SupportedCurrency)%>

......................

不,当我发布/更新时,我调用不同的操作(比如更新),我想访问Currencycode以及CurrencyDescription。我可以获得Currencycode但我无法访问CurrencyDescription。

任何帮助非常感谢。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值