当字段值为“是/否”时隐藏表单上的字段

时间:2018-10-11 15:17:48

标签: c# html razor

下面是我的edit.cshtml

中的代码

如果SubClient_ID中的值为“是”,则我需要按Group_Rollup_Flag字段隐藏,如果Group_Rollup_Flag为空,则取消隐藏。

我该怎么做?我将如何为此写if语句?

<div>
    <div class="form-group col-xs-4">
        @Html.LabelFor(model => model.MasterClient_ID, htmlAttributes: new { @class = "control-label col-md-2 required-label" })
        <div class="col-md-10">
            @Html.DropDownList("MasterClient_ID", null, htmlAttributes: new { @class = "form-control input-block-level" })
            @Html.ValidationMessageFor(model => model.MasterClient_ID, "", new { @class = "text-danger" })
        </div>
    </div>

    <div class="form-group col-xs-4">
        @Html.LabelFor(model => model.SubClient_ID, htmlAttributes: new { @class = "control-label col-md-2" })
        <div class="col-md-10">
            @Html.DropDownList("SubClient_ID", null, "--Select--", htmlAttributes: new { @class = "form-control input-block-level" })
            @Html.ValidationMessageFor(model => model.SubClient_ID, "", new { @class = "text-danger" })
        </div>
    </div>

    <div class="form-group col-xs-4">
        @Html.LabelFor(model => model.RebateClient_ID, htmlAttributes: new { @class = "control-label col-md-2 required-label" })
        <div class="col-md-10">
            @Html.DropDownList("RebateClient_ID", null, "--Select--", htmlAttributes: new { @class = "form-control input-block-level" })
            @Html.ValidationMessageFor(model => model.RebateClient_ID, "", new { @class = "text-danger" })
        </div>
    </div>
</div>

0 个答案:

没有答案