英文:
I'm new to ASP NET MVC 5, I'm trying to get a data from a table and display it on a textbox
问题
I'm new to ASP.NET MVC. I'm trying to get the ITEMNAME from tbl_inventorycontrol.
@model RSMI.Models.Database.tbl_STOCKCARD
@Html.LabelFor(model => model.ITEMCODE, htmlAttributes: new { @class = "control-label col-md-2" })
@Html.ValidationMessageFor(model => model.ITEMCODE, "", new { @class = "text-danger" })
It should it should get the ITEMCODE value from tbl_stockcard. Then in stockcard controller, when I click search button, it should get the itemname in tbl_inventorycoller equal to the tbl_stockcard.ITEMCODE.
英文:
I'm new to ASP.NET MVC. I'm trying to get the ITEMNAME from tbl_inventorycontrol.
@model RSMI.Models.Database.tbl_STOCKCARD
@Html.LabelFor(model => model.ITEMCODE, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.ITEMCODE, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.ITEMCODE, "", new { @class = "text-danger" })
<br />
<div class="form-group">
<div class="col-md-offset-24 col-md-12">
<input type="button" value="Search Item" onclick="location.href='@Url.Action("SearchItemCode","Stockcard")'" class="btn btn-primary btn-block" />
It should it should get the ITEMCODE value from tbl_stockcard. Then in stockcard controller, when I click search button, it should get the itemname in tbl_inventorycoller equal to the tbl_stockcard.ITEMCODE.
答案1
得分: 1
以下是已翻译的内容:
"不太清楚您想要对筛选结果进行什么操作。看起来您的 return
语句不匹配。如果找到项目,您希望返回包含该项目的视图。请考虑以下方法:"
英文:
It's not entirely clear what you want to do with the filter result. Seems you mismatched you return
statements. You want returning View with your item if found. Please consider this approach
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Searchitem(tbl_inventorycontrol tbl_Inventorycontrol )
{
if (ModelState.IsValid)
{
var item = db.tbl_inventorycontrol.Where(tbl_STOCKCARD => tbl_STOCKCARD.ITEMCODE == tbl_Inventorycontrol.SUPPLIES).FirstOrDefault();
if (item != null)
{
return View(item);
}
}
return View(tbl_Inventorycontrol);
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论