【发布时间】:2018-08-16 22:11:00
【问题描述】:
我正在创建表单,用户将在其中输入一些信息。我正在使用 EF 将此信息存储到数据库中。我想在这里实现 3 个单选按钮。当用户选择名为“其他”的第三个单选按钮时,我想显示一些文本框,然后将此文本从文本框存储到数据库。我怎样才能做到这一点?
我尝试了一些东西,但它只从第三个单选按钮存储到 DB 值,而不是从文本框中。
@Html.RadioButtonFor(model => model.Type,"Material Master")
@Html.Label("Material Master")
@Html.RadioButtonFor(model => model.Type, "Packaging Master")
@Html.Label("Packaging Master")
@Html.RadioButtonFor(model => model.Type, "Other")
@Html.Label("Other")
@Html.EditorFor(m => m.Type, new { @disabled = "disabled", @class = "form-control" })
谁能给我指路,怎么做?我不知道我能做什么。
型号:
public class RequisitionHeader
{
[Key]
public int RequisitionId { get; set; }
public string Applicant { get; set; }
public string Type { get; set; }
public DateTime? Date { get; set; }
public string ReasonOfChange { get; set; }
public DateTime? ValidityOfChangeFrom { get; set; }
public string Notes { get; set; }
}
【问题讨论】:
-
你的模特是什么样子的?
-
我添加了模型。你可以看看
-
我会将 model.type 从“其他”的单选按钮移动到用户键入“其他”的文本框中。
标签: c# asp.net-mvc razor