我有一个模型类,如下所示
public class AddKeyModel
{
public int Count { get; set; }
/// <summary>
/// 0 - Trial
/// 1 - License
/// </summary>
public bool LicenseType { get; set; }
/// <summary>
/// 0 - Lite
/// 1 - Pro
/// </summary>
public int ProductType { get; set; }
}
我正在使用DevExpress MVC扩展,但在视图上显示此数据时遇到问题。任何人都可以告诉我显示单选按钮的确切代码,并在将数据提交给控制器时将数据设置为模型。
此代码无效
@Html.DevExpress().RadioButton(
settings =>
{
settings.Name = "Trial";
settings.GroupName = "LicenseType";
}).Bind(Model.LicenseType).GetHtml()
@Html.DevExpress().Label(
settings =>
{
settings.ControlStyle.CssClass = "label";
settings.Text = "License";
settings.AssociatedControlName = "License";
}).GetHtml()
@Html.DevExpress().RadioButton(
settings =>
{
settings.Name = "License";
settings.GroupName = "LicenseType";
}).Bind(Model.LicenseType).GetHtml()
答案 0 :(得分:0)
您可以改用RadioButtonList。
请参阅How to use the CheckBoxList and RadioButtonList editors to edit Model fields示例。