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无线电控件?
答案 0 :(得分:0)
尝试
@Html.RadioButtonFor(o => o.TradeOrder.Exchange, "US", new {id = "exchangeUS"},new { Checked = (o.TradeOrder.Exchange=="X" ? "Checked" : string.Empty) )