I want create Dropdownlist using Jquery but I am not able to get Result
- public JsonResult GetPipeNo(string MyStageCode)
- {
- db.Configuration.ProxyCreationEnabled = false;
- if (MyStageCode == "P3")
- {
- List<PipeAl> PipeList = db.PipeAls.ToList();
- return Json(PipeList, JsonRequestBehavior.AllowGet);
- }
- else
- {
- List<Process> PipeList = db.Processes.Where(x => x.NextStageID == MyStageCode).ToList();
- return Json(PipeList, JsonRequestBehavior.AllowGet);
- }
-
- }
View Code is
- @model EasyApp.Models.Process
- @{
- ViewBag.Title = "Create";
- }
-
- <html>
- <head>
-
- <script src="~/Scripts/jquery-1.10.2.min.js"></script>
- <script src="~/Scripts/jquery-ui-1.12.1.js"></script>
- <link href="~/Content/jquery-ui.css" rel="stylesheet" />
- <script>
- $(document).ready(function () {
- $("#StageID").change(function () {
- $.get("/Dailyproduction/GetPipeNo", { MyStageCode: $("#StageID").toString() }, function (data) {
- $("#PIPENO").empty();
- $.each(data, function (index, row) {
- $("#PIPENO").append("<option value='" + row.PIPENO + "'>" + row.PIPENO + "</option>")
- });
-
- });
- });
- $(function () {
- $("#datepicker").datepicker({
- dateFormat: 'dd/mm/yy'
- });
- });
- });
- </script>
-
- </head>
- <body>
- <h2>Add Daily Production</h2>
- <div class="EasyViewDiv">
- @using (Html.BeginForm())
- {
- @Html.AntiForgeryToken()
-
- <div class="form-horizontal">
-
- @Html.ValidationSummary(true, "", new { @class = "text-danger" })
- <div class="form-group">
- @Html.LabelFor(model => model.StageID, "Stage Name", htmlAttributes: new { @class = "control-label col-md-2" })
- <div class="col-md-10">
- @if (ViewBag.StageID != null)
- {
- @Html.DropDownListFor(model=>model.StageID, ViewBag.StageID as SelectList, "-----Select Stage ID---", new { @class="form-control"})
- }
- @Html.ValidationMessageFor(model => model.StageID, "", new { @class = "text-danger" })
- </div>
- </div>
-
- <div class="form-group">
- @Html.LabelFor(model => model.PRDate, "Production Date", htmlAttributes: new { @class = "control-label col-md-2" })
- <div class="col-md-10">
- @Html.TextBoxFor(model => model.PRDate, new { id = "datepicker", @class = "form-control" })
- @Html.ValidationMessageFor(model => model.PRDate, "", new { @class = "text-danger" })
- </div>
- </div>
-
-
-
- <div class="form-group">
- @Html.LabelFor(model => model.PIPENO, "Pipe No", htmlAttributes: new { @class = "control-label col-md-2" })
- <div class="col-md-10">
- @*@Html.DropDownList("PIPENO", null, htmlAttributes: new { @class = "form-control" })*@
-
- @Html.DropDownListFor(model => model.PIPENO, new SelectList(""), "--Select PipeNO--", new { @class = "form-control" })
- @Html.ValidationMessageFor(model => model.PIPENO, "", new { @class = "text-danger" })
- </div>
- </div>
-
- <div class="form-group">
- @Html.LabelFor(model => model.ATTNSYSID, "Operator Name", htmlAttributes: new { @class = "control-label col-md-2" })
- <div class="col-md-10">
- @*@Html.TextBoxFor(model => model.ATTNSYSID, new { id = "txtUserSearch", @class = "form-control" })*@
- @*@Html.DropDownListFor(model => model.ATTNSYSID, new SelectList(""), "--Select Operator--", new { @class = "form-control" })*@
- @Html.DropDownList("ATTNSYSID", null, htmlAttributes: new { @class = "form-control" })
- @Html.ValidationMessageFor(model => model.ATTNSYSID, "", new { @class = "text-danger" })
- </div>
- </div>
-
- <div class="form-group">
- @Html.LabelFor(model => model.Status, "Status", htmlAttributes: new { @class = "control-label col-md-2" })
- <div class="col-md-10">
- @Html.EditorFor(model => model.Status, new { htmlAttributes = new { @class = "form-control" } })
- @Html.ValidationMessageFor(model => model.Status, "", new { @class = "text-danger" })
- </div>
- </div>
-
-
- <div class="form-group">
- @Html.LabelFor(model => model.NextStageID, "Next Production Stage", htmlAttributes: new { @class = "control-label col-md-2" })
- <div class="col-md-10">
- @if (ViewBag.StageID != null)
- {
- @Html.DropDownListFor(model => model.NextStageID, ViewBag.StageID as SelectList, "-----Select Stage ID---", new { @class = "form-control" })
- }
- @*@Html.DropDownList("NextStageID", null, htmlAttributes: new { @class = "form-control" })
- @Html.DropDownListFor(model => model.NextStageID, ViewBag.NextStageList as SelectList, "-----Select Next Stage ID---", new { @class = "form-control" })*@
- @Html.ValidationMessageFor(model => model.NextStageID, "", new { @class = "text-danger" })
- </div >
- </div>
- <div class="dropdown-menu"></div>
- <div class="form-group">
- <div class="col-md-offset-2 col-md-10">
- <input type="submit" value="Create" class="btn btn-default" />
- </div>
- </div>
- </div>
- }
-
- <div>
- @Html.ActionLink("Back to List", "Index")
- </div>
- </div>
- </body>
- </html>