嗨我有2个字段,每个字段包含两个单选按钮。当我选择单选按钮并尝试在Db中保存单选按钮的值但它始终保存该值为零。它无法正常工作。
这是我的字段 PaymentReceived 和 PaymentType 。在这里我写了j查询代码。如果我选择 POVisit 作为付款,则会显示 PaymentReceived 单选按钮,如果我选择 PaymentReceived 为是它将显示 PaymentType 单选按钮字段,如果我选择Cash in PaymentType,它将显示相应字段,否则全部处于隐藏模式。
我的观看代码
<div id ="PaymentReceived">
<div class="col-sm-4">
<div class="form-group">
@Html.LabelFor(model => model.PaymentReceived, new { @class = "control-label" })
@Html.RadioButton("PaymentReceived", 1) Yes
@Html.RadioButton("PaymentReceived", 0) No
</div>
</div>
</div>
<div id ="PaymentType">
<div class="col-sm-4">
<div class="form-group">
@Html.LabelFor(model => model.PaymentType, new { @class = "control-label" })
@Html.RadioButton("PaymentType", 1) Cash
@Html.RadioButton("PaymentType", 0) Cheque
</div>
</div>
</div>
我的控制器代码
if (visitorviewmodel.PaymentReceived == true)
visitorviewmodel .PaymentReceived = true;
else
visitorviewmodel.PaymentReceived = false;
if (visitorviewmodel.PaymentType == true)
visitorviewmodel.PaymentType = true;
else
visitorviewmodel.PaymentType = false;
var VisitorsViewObj = new VisitorsForm()
{
PaymentReceived = Convert.ToBoolean(visitorviewmodel.PaymentReceived),
PaymentType= Convert.ToBoolean(visitorviewmodel.PaymentType),
};
如果我在收到付款时选择是,它将在中显示值为假 如果(visitorviewmodel.PaymentReceived == true),如果我在PaymentReceived中选择否,则会在if语句中将值显示为false,类似于支付类型,我会选择单选按钮中的值,它始终显示值为false。现在我想要的是我想按照单选按钮中的选择保存值。也就是说,如果我选择是,则表示如果我选择该值,它将在DB中将值保存为1,否则必须将值保存为0。请任何人帮我解决这个问题。