Hi @akhter hussain,
I remember you asking the same question, but with a different database.
You asked a lot of questions, but in fact some questions are very similar, I think you should learn to infer other cases from one instance.
<div>
<div class="row">
<div style="display: inline-block;">
<div>
@Html.LabelFor(model => model.Prdno, "Barcode", htmlAttributes: new { @class = "control-label col-md-4" })
@Html.EditorFor(model => model.Prdno, new { htmlAttributes = new { @class = "form-control col-md-10", @id = "Search_Prdno" } })
@Html.ValidationMessageFor(model => model.Prdno, "", new { @class = "text-danger" })
</div>
</div>
<div style="display: inline-block;">
<div>
@Html.LabelFor(model => model.Codeitem, "Select Item", htmlAttributes: new { @class = "control-label col-md-3" })
@Html.DropDownList("codeitemId", (SelectList)ViewBag.Codeitem, "Select", htmlAttributes: new { @class = "form-control", @id = "select2-3" })
@Html.ValidationMessageFor(model => model.Codeitem, "", new { @class = "text-danger" })
</div>
</div>
</div>
</div>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$("#Search_Prdno").change(function () {
var prdno = $("#Search_Prdno").val();
if (prdno != "") {
GetSections(prdno);
}
else {
$("#select2-3").empty();
}
});
});
function GetSections(prdno) {
$.ajax({
async: true,
type: 'GET',
dataType: 'JSON',
contentType: 'application/json; charset=utf-8',
url: '/Home/GetBarcodeSB',
data: { prdno: prdno },
success: function (data) {
$('#select2-3').empty();
$(data).each(function (index, item) {
$('#select2-3').append($('<option/>', { value: item.Value, text: item.Text }))
})
},
error: function () {
alert("There is some problem to get.");
}
});
}
</script>
public ActionResult Index()
{
var orderId = 0;
ViewBag.orderId = new SelectList(DB.SalesOrder.Where(bt => bt.OrderNo > orderId ), "Orderno", "OrderTime", "0");
var codeitemId = 0;
ViewBag.codeitemId = new SelectList(DB.ItemMasterFile.Where(bt => bt.CodeItem > codeitemId ), "CodeItem", "Descriptionitem", "0");
return View();
}
[HttpGet]
public JsonResult GetBarcodeSB(int prdno)
{
int Codeitem = DB.Probale.First(a => a.Prdno == prdno).CodeItem;
var STATUS_LIST = (from s in DB.ItemMasterFile
where s.CodeItem == Codeitem
select new SelectListItem()
{
Text = s.Descriptionitem,
Value = s.CodeItem.ToString(),
}).ToList();
return Json(STATUS_LIST, JsonRequestBehavior.AllowGet);
}
Best regards,
Lan Huang
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.