Asp.net mvc 2 我正在将模型传递给radiobutton,如何将其设为默认值?

Asp.net mvc 2 我正在将模型传递给radiobutton,如何将其设为默认值?,asp.net-mvc-2,defaultbutton,html.radiobuttonlist,Asp.net Mvc 2,Defaultbutton,Html.radiobuttonlist,例如,将模型传递给具有三个不同值的radiobutton model.Country,model.Countries,新的{@class=“countrytype”})%> 这些国家有三种价值观:美国、加拿大和其他。但我希望默认情况下选择U.S。我的朋友怎么能做到 我的结果是: 公共行动结果选择(CountryModel m) {…返回视图(新的CountryModel(countrytype.AsQuicklist()); } 如何在返回视图中添加模型参数?RadioButtonListFor

例如,将模型传递给具有三个不同值的radiobutton

model.Country,model.Countries,新的{@class=“countrytype”})%>

这些国家有三种价值观:美国、加拿大和其他。但我希望默认情况下选择U.S。我的朋友怎么能做到

我的结果是:

公共行动结果选择(CountryModel m) {…返回视图(新的CountryModel(countrytype.AsQuicklist()); }


如何在返回视图中添加模型参数?

RadioButtonListFor
不是ASP.NET MVC中包含的标准帮助程序。因此,此问题的答案将取决于您从何处获得此帮助程序及其实现方式

因此,在黑暗中拍摄:您可以尝试将控制器操作中的相应模型属性设置为要预选的按钮的值:

public ActionResult Index()
{
    SomeModel model = ...
    model.Country = "Canada";
    return View(model);
}

我的actionresult是:public actionresult Select(CountryModel m){…返回视图(new CountryModel(countrytype.AsQuicklist());}如何在返回视图中添加模型参数?@软件,如下尝试:
var model=new CountryModel(countrytype.AsQuicklist());model.Country=“Canada”;返回视图(model);