0

MVC 4:

我有以下无线电控件

@Html.RadioButtonFor(o => o.TradeOrder.Exchange, "CA", new {id = "exchangeCA"})
@Html.RadioButtonFor(o => o.TradeOrder.Exchange, "US", new {id = "exchangeUS"})

o.TradeOrder.Exchange是一个字符串,但不一定包含“CA”或“US”,所以我们覆盖如图所示。

如果o.TradeOrder.Exchange=="X",我将如何设置 CA 无线电控制检查?

4

1 回答 1

0

尝试

@Html.RadioButtonFor(o => o.TradeOrder.Exchange, "US", new {id = "exchangeUS"},new { Checked = (o.TradeOrder.Exchange=="X" ? "Checked" : string.Empty) )
于 2013-10-23T22:47:59.547 回答