嗨我有一个需要日期的报表模型。他的日期可以是今天,昨天或日期范围。将模型绑定到单选按钮
public class DateModel
{
public bool Today { get; set; }
public bool Yesterday { get; set; }
public bool DateRange { get; set; }
public DateTime StartDate { get; set; }
public DateTime EndDate { get; set; }
}
此模型必须为视图。 “今天”,“昨天”,“日期范围”的单选按钮以及“开始”和“结束”日期的文本框。
<tr>
<td>
@Html.RadioButton("SelectedDate", "Yes", true, new { postData= "Today" }) Today
</td>
</tr>
<tr>
<td>
@Html.RadioButton("SelectedDate", "No", false, new { postData= "Yesterday" }) Yesterday
</td>
</tr>
<tr>
<td>
@Html.RadioButton("SelectedDate", "No", false, new { postData= "CallDateRange" }) Call Date Range
</td>
</tr>
当视图回传时,我怎样才能得到什么单选按钮被选中?
这将很大程度上取决于你如何”重新发送您的单选按钮,以及视图如何绑定。你可以用你的单选按钮的区域编辑你的文章吗? –
@StevenVondruska更新。 –