使用按钮编辑列值,而不是手动键入

时间:2015-06-08 08:06:38

标签: asp.net asp.net-mvc

我有一个问题。从下面的图片中,哇我只需点击验证按钮即可将状态从CREATED更改为VERIFIED。我不想点击单选按钮来编辑它。我想使用“已验证”按钮编辑该值。谢谢。目前,要编辑状态,我需要单击单选按钮并进行更改。我想通过点击“验证”按钮来更改它。

enter image description here

下面是我的按钮

                <input type="submit" name="submit" value="Save" class="btn btn-default" />
                <input type="submit" name="submit" value="Verified" class="btn btn-default" />

以下是我的控制器

public ActionResult Edit(ListOfItems objGetListOfItems)
        {
            if (objGetListOfItems == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            ListOfItems LOIEdit = ARSharedDAL.Find(objGetListOfItems);
            if (LOIEdit == null)
            {
                return HttpNotFound();
            }
            return View(LOIEdit);
        }

这是它链接到存储过程

的地方
    public static ListOfItems Find(ListOfItems objGetListOfItems)
    { //
        SqlDataReader rdrDataAccess = null;

        ListOfItems objListOfItems = null;

        SqlConnection database = new SqlConnection(MyCOODataConn.MyCOOConnectionString);

        database.Open();
        SqlCommand databaseCmd = new SqlCommand("SP_APP_SUI_ListOfItemsDetails", database);
        databaseCmd.CommandType = CommandType.StoredProcedure;

        databaseCmd.Parameters.Add(new SqlParameter("@idShared", objGetListOfItems.idshared));

        rdrDataAccess = databaseCmd.ExecuteReader();

        objListOfItems = new ListOfItems();

        while (rdrDataAccess.Read())
        {
            objListOfItems = new ListOfItems();

            objListOfItems.idshared = GeneralUtil.GetDBInt(rdrDataAccess, "idshared");
            objListOfItems.reftab = GeneralUtil.GetDBString(rdrDataAccess, "reftab", "");
            objListOfItems.codeShared = GeneralUtil.GetDBString(rdrDataAccess, "code", "");
            objListOfItems.abbreviation = GeneralUtil.GetDBString(rdrDataAccess, "abbreviation", "");
            objListOfItems.description = GeneralUtil.GetDBString(rdrDataAccess, "description", "");
            objListOfItems.remarks = GeneralUtil.GetDBString(rdrDataAccess, "remarks", "");
            objListOfItems.effectivedate = GeneralUtil.GetDBString(rdrDataAccess, "effectivedate", "");
            objListOfItems.Status = GeneralUtil.GetDBString(rdrDataAccess, "Status", "");


        }

        return objListOfItems;
    }

编辑查看代码

    @using (Html.BeginForm())
{
    @Html.AntiForgeryToken()

    <div class="widgetbox">
        <h4 class="widgettitle">Manage Reference Table</h4>

        <div class="widgetcontent">

            <div>
                @Html.ValidationSummary(true, "", new { @class = "text-danger" })
                <table>
                    <tr>
                        <td>
                            @Html.Label("No :", htmlAttributes: new { style = "width: 70px; " })
                        </td>
                        <td>
                            <div class="col-md-10">
                                @Html.DisplayFor(model => model.idshared, new { htmlAttributes = new { @class = "form-control" } })
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <div class="form-group">
                                @Html.Label("Ref Tab :", htmlAttributes: new { @class = "control-label col-md-2" })

                            </div>
                        </td>
                        <td>
                            <div class="col-md-10">
                                @Html.EditorFor(model => model.reftab, new { htmlAttributes = new { @class = "form-control" } })
                                @Html.ValidationMessageFor(model => model.reftab, "", new { @class = "text-danger" })
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <div class="form-group">
                                @Html.Label("Code :", htmlAttributes: new { @class = "control-label col-md-2" })

                            </div>
                        </td>
                        <td>
                            <div class="col-md-10">
                                @Html.EditorFor(model => model.codeShared, new { htmlAttributes = new { @class = "form-control" } })
                                @Html.ValidationMessageFor(model => model.codeShared, "", new { @class = "text-danger" })
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            @Html.Label("Abbreviation :", new { style = "padding-right: 10px; " })
                        </td>
                        <td>
                            <div class="col-md-10">
                                @Html.EditorFor(model => model.abbreviation, new { htmlAttributes = new { @class = "form-control" } })
                                @Html.ValidationMessageFor(model => model.abbreviation, "", new { @class = "text-danger" })
                            </div>
                        </td>

                    </tr>
                </table>

                <table style="text-align:left;">
                    <tr>
                        <td>
                            @Html.Label("Description :", new { style = "padding-right: 10px; " })
                        </td>
                        <td>
                            <div class="col-md-10">
                                @Html.EditorFor(model => model.description, new { style = "width: 150px;" })
                                @Html.ValidationMessageFor(model => model.description, "", new { @class = "text-danger" })
                            </div>
                        </td>
                    </tr>
                </table>

                <table>
                    <tr>

                        <td>
                            <div class="form-group">
                                @Html.Label("Remarks :", htmlAttributes: new { @class = "control-label col-md-2" })
                            </div>
                        </td>
                        <td>
                            <div class="col-md-10">
                                @Html.EditorFor(model => model.remarks, new { @class = "form-control" })
                                @Html.ValidationMessageFor(model => model.remarks, "", new { @class = "text-danger" })
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <div class="form-group">
                                @Html.Label("Effective Date:", htmlAttributes: new { @class = "control-label col-md-2" })
                            </div>
                        </td>
                        <td>
                            <div class="col-md-10">
                                @Html.EditorFor(model => model.effectivedate, new { htmlAttributes = new { @class = "form-control" } })
                                @Html.ValidationMessageFor(model => model.effectivedate, "", new { @class = "text-danger" })
                            </div>
                        </td>

                    </tr>
                    <tr>
                        <td>
                            <div class="form-group">
                                @Html.Label("Status:", htmlAttributes: new { @class = "control-label col-md-2" })
                            </div>
                        </td>
                        <td>
                            <div class="col-md-10">
                                @Html.RadioButtonFor(x => x.Status, "CREATED", new {  }) CREATED
                                @Html.RadioButtonFor(x => x.Status, "VERIFIED", new { }) VERIFIED

                            </div>
                        </td>

                    </tr>
                </table>
                <br />

                <div class="col-md-offset-2 col-md-10">
                    <input type="submit" name="submit" value="Save" class="btn btn-default" />
                    <input type="submit" name="submit" value="Verified" class="btn btn-default" />
                </div>

            </div>

        </div>

    </div>


}

<div>
    @Html.ActionLink("Back to List", "Index")
</div>

3 个答案:

答案 0 :(得分:1)

为您的帖子调用写一个成功处理程序,并将其放入您的成功处理程序

 matrix.setRotate(rotationAngle, (float) bm.getWidth() / 2, (float) bm.getHeight() / 2);
 Bitmap rotatedBitmap = Bitmap.createBitmap(bm, 0, 0, bounds.outWidth, bounds.outHeight, matrix, true);

Here是一个简单的小提琴。与此小提琴不同,您可能希望将该代码置于验证调用的成功处理程序中,以确保数据实际上是从db验证的。 此外,如果您不想让用户选择单选按钮,您可能希望禁用它们。

只是一个建议。从用户体验的角度来看,如果

会更好看
  1. 您可以选中一个复选框来显示数据是否已经过验证(已验证:[检查])
  2. 显示一些经过验证的绿色标签,在验证数据后显示。

答案 1 :(得分:0)

我设法做到了。多谢你们。如果我的问题不清楚,我很抱歉。

我需要的是在不使用单选按钮的情况下将状态从CREATED更改为VERIFIED。我做的是,我只是使用jquery来改变状态。而不是使用单选按钮,我创建了一个隐藏的文本框,其值为'VERIFIED'。单击按钮VERIFIED后,它将带有'VERIFIED'值。下面是我隐藏的文本框和jquery代码

   <div class="col-md-10" hidden>

        @Html.TextBoxFor(m => m.Status, new { id = "Statusd", name = "Testname1" })
        @Html.ValidationMessageFor(model => model.Status, "", new { @class = "text-danger" })




</div>

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script>
    $(document).ready(function(){
        $("#Verified").click(function(){
            $('#Statusd').val('ENDORSED');
        });
    });
</script>

非常感谢你们这些时间。

答案 2 :(得分:-1)

public ActionResult Edit(ListOfItems objGetListOfItems)
        {
            if (objGetListOfItems == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            ListOfItems LOIEdit = ARSharedDAL.Find(objGetListOfItems);
            if (LOIEdit == null)
            {
                return HttpNotFound();
            }
            return View(LOIEdit);
        }