iT邦幫忙

0

想請問我這個問題 是不是該改成這樣?

  • 分享至 

  • xImage

https://ithelp.ithome.com.tw/upload/images/20190123/20110132DAD1F8F3Q4.jpg

這是我表單的其中一個欄位,我的問題是,進入新增資料功能將資料送出後,

我剛溝選的選項就不見,然後進入編輯模式時也看不到編輯前的資料,我的送出是

用Html.BeginForm將資料送出,請問我是不是該改成Ajax.BeginForm的方式來處理?

還是說要用別種的方式來做?我開啟偵錯模式我編輯前的資料是有抓取到的,是前端

沒顯示出來。

這是我的html

<div class="row">
    <div class="col-md-12">
        @using (Html.BeginForm("AddOrUpdate", "OpdEval", new { area = "PDNurse" }, FormMethod.Post, new { @class = "form-inline", id = "HdRecordForm" }))
        {

            @Html.HiddenFor(m => m.OpdEval.GUID)
            @Html.HiddenFor(m => m.OpdEval.CID)
            @Html.HiddenFor(m => m.OpdEval.PatGUID)
            @Html.HiddenFor(m=>m.OpdEval.CreUid)
                   
            <div class="box box-primary">
                <div class="box-header">
                    <h3 class="box-title">門診評估</h3>
                    <button type="submit" class="btn btn-primary pull-right">儲存</button>
                    <button type="button" class="fn-cancel btn btn-default pull-right btn-right-margin">取消/返回</button>
                </div><!-- /.box-header -->
                <div class="box-body">
                    <div class="form-flex-container">                     
                        <div class="row-flex">
                            <div class="col-label">
                                <label class="control-label">導管出口處情形(exit site)</label>
                            </div>
                            <div class="col-input">
                                <table class="es-table">
                                    <tr>
                                        <td>狀況</td>
                                        @for (int i = 0; i < Model.EsStatusOptions.Count; i++)
                                        {
                                            NCODE option = Model.EsStatusOptions[i];
                                            string radioId = "OpdEval.EsStatus_" + option.NC_CODE;
                                            string radioName = "OpdEval.EsStatus";
                                            string radioValue = option.NC_CODE;
                                            <td>
                                                <label>
                                                    <input id="@radioId" name="@radioName" type="radio" value="@radioValue">
                                                    @option.NC_NAME
                                                </label>
                                            </td>
                                        }
                                    </tr>
                                    <tr>
                                        <td>顏色</td>
                                        @for (int i = 0; i < Model.EsColorOptions.Count; i++)
                                        {
                                            NCODE option = Model.EsColorOptions[i];
                                            string radioId = "OpdEval.EsColor_" + option.NC_CODE;
                                            string radioName = "OpdEval.EsColor";
                                            string radioValue = option.NC_CODE;
                                            <td>
                                                <label>
                                                    <input id="@radioId" name="@radioName" type="radio" value="@radioValue">
                                                    @option.NC_NAME
                                                </label>
                                            </td>
                                        }
                                    </tr>
                                    <tr>
                                        <td>痂皮</td>
                                        @for (int i = 0; i < Model.EsEscharOptions.Count; i++)
                                        {
                                            NCODE option = Model.EsEscharOptions[i];
                                            string radioId = "OpdEval.EsEschar_" + option.NC_CODE;
                                            string radioName = "OpdEval.EsEschar";
                                            string radioValue = option.NC_CODE;
                                            <td>
                                                <label>
                                                    <input id="@radioId" name="@radioName" type="radio" value="@radioValue">
                                                    @option.NC_NAME
                                                </label>
                                            </td>
                                        }
                                    </tr>
                                    <tr>
                                        <td>結痂</td>
                                        @for (int i = 0; i < Model.EsScabOptions.Count; i++)
                                        {
                                            NCODE option = Model.EsScabOptions[i];
                                            string radioId = "OpdEval.EsScab_" + option.NC_CODE;
                                            string radioName = "OpdEval.EsScab";
                                            string radioValue = option.NC_CODE;
                                            <td>
                                                <label>
                                                    <input id="@radioId" name="@radioName" type="radio" value="@radioValue">
                                                    @option.NC_NAME
                                                </label>
                                            </td>
                                        }
                                    </tr>
                                    <tr>
                                        <td>分泌物</td>
                                        @for (int i = 0; i < Model.EsSecretionOptions.Count; i++)
                                        {
                                            NCODE option = Model.EsSecretionOptions[i];
                                            string radioId = "OpdEval.EsSecretion_" + option.NC_CODE;
                                            string radioName = "OpdEval.EsSecretion";
                                            string radioValue = option.NC_CODE;
                                            <td>
                                                <label>
                                                    <input id="@radioId" name="@radioName" type="radio" value="@radioValue">
                                                    @option.NC_NAME
                                                </label>
                                            </td>
                                        }
                                    </tr>
                                    <tr>
                                        <td>腫</td>
                                        @for (int i = 0; i < Model.EsSwollenOptions.Count; i++)
                                        {
                                            NCODE option = Model.EsSwollenOptions[i];
                                            string radioId = "OpdEval.EsSwollen_" + option.NC_CODE;
                                            string radioName = "OpdEval.EsSwollen";
                                            string radioValue = option.NC_CODE;
                                            <td>
                                                <label>
                                                    <input id="@radioId" name="@radioName" type="radio" value="@radioValue">
                                                    @option.NC_NAME
                                                </label>
                                            </td>
                                        }
                                    </tr>
                                    <tr>
                                        <td>肉芽組織</td>
                                        @for (int i = 0; i < Model.EsGranOptions.Count; i++)
                                        {
                                            NCODE option = Model.EsGranOptions[i];
                                            string radioId = "OpdEval.EsGran_" + option.NC_CODE;
                                            string radioName = "OpdEval.EsGran";
                                            string radioValue = option.NC_CODE;
                                            <td>
                                                <label>
                                                    <input id="@radioId" name="@radioName" type="radio" value="@radioValue">
                                                    @option.NC_NAME
                                                </label>
                                            </td>
                                        }
                                    </tr>
                                </table>
                            </div>
                        </div><!-- /.row -->

                      
                    </div><!-- /.form-flex-container -->
                </div><!-- /.box-body -->
                <div class="box-footer">
                    <button type="submit" class="btn btn-primary pull-right">儲存</button>
                    <button type="button" class="fn-cancel btn btn-default pull-right btn-right-margin">取消/返回</button>
                </div><!-- /.box-footer -->
            </div><!-- /.box -->
        }<!-- /.form -->
    </div><!-- /.col -->
</div><!-- row -->

屬性

        public List<NCODE> EsStatusOptions { get; set; }
        public List<NCODE> EsColorOptions { get; set; }
        public List<NCODE> EsEscharOptions { get; set; }
        public List<NCODE> EsScabOptions { get; set; }
        public List<NCODE> EsSecretionOptions { get; set; }
        public List<NCODE> EsSwollenOptions { get; set; }
        public List<NCODE> EsGranOptions { get; set; }
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 個回答

0

如果是 HtmlHelper 的 raido button ,他會偷偷幫你在加一組 hidden 去存你選定的值。
不然你就需要在你的 input type="radio" tag 上面用 Razor 語法判斷 checked。

tenno081 iT邦研究生 4 級 ‧ 2019-01-23 11:14:34 檢舉

你好,我的看起來不像是用htmlhelper的radiobutton

我知道你用的不是 htmlhelper 的 radiobutton
所以你可能要在你的input type="radio" 裡面加類似  @(Model.IsCheck ? "checked" : "") 這樣的判斷,讓他打勾。

我要發表回答

立即登入回答