gpt4 book ai didi

asp.net-mvc - ASP.NET MVC 2 中的 RadioButtonFor

转载 作者:行者123 更新时间:2023-12-03 15:21:06 25 4
gpt4 key购买 nike

有人可以提供一个如何正确使用 Html.RadioButtonFor 的简单示例吗?假设这是一个简单的场景,我的模型有一个名为 Gender 的字符串属性。我想显示两个单选按钮:“男”和“女”。

在“编辑” View 中保留所选值的同时实现此目的的最简洁方法是什么?

最佳答案

Male: <%= Html.RadioButtonFor(x => x.Gender, "Male") %>
Female: <%= Html.RadioButtonFor(x => x.Gender, "Female") %>

关于asp.net-mvc - ASP.NET MVC 2 中的 RadioButtonFor,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2588699/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com