我有問題。從下面的圖片中,我只需點擊VERIFIED BUTTON,就可以將狀態從CREATED更改爲VERIFIED。我不想單擊單選按鈕來編輯它。我想通過使用「驗證」按鈕來編輯值。謝謝。目前,要編輯狀態,我需要單擊單選按鈕並更改它。我想通過點擊驗證按鈕來改變它。使用按鈕編輯列值,而不是手動輸入
是我的按鈕
<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>
你能分享整個視圖代碼嗎? –
@MirzaDanishBaig here mirza。 – abcd
你將需要JavaScript來做到這一點。如果您使用jQuery,請使用$ .ajax,並在成功回調函數中使用$('input [value =「CREATED」)。attr('checked','checked'); 也刪除Html.BeginForm() – Irshu