0
我有這樣的代碼在我的控制器:搜索數據庫並顯示.cshtml頁
public ActionResult Search(String searchstring)
{
var number = from n in db.UCountInfoes
select n;
if (!String.IsNullOrEmpty(searchstring))
{
number = number.Where(i => i.IDNumber.Equals(searchstring));
}
return View(number);
}
和我.cshtml
頁面上我有這個,我用它來搜索:
<div class="form-group">
@Html.LabelFor(model => model.ID_Number, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.ID_Number, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.ID_Number, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" name="SearchButton" value="Search" class="btn btn-inverse" />
</div>
</div>
點擊後搜索按鈕我想返回在另一個.cshtml
頁面上找到的記錄。