コード例 #1
0
        private List <DropDownListViewModel> GetProductDropDownList(string lookupTypeName, int?lookupCodeId)
        {
            var _list = new List <DropDownListViewModel>();

            ProductService          productService   = new ProductService();
            List <LookupCodeMaster> lookUpCategories = new List <LookupCodeMaster>();

            if (lookupTypeName != null)
            {
                lookUpCategories = productService.GetProductDropDownList(lookupTypeName);
            }
            else if (lookupCodeId != null)
            {
                lookUpCategories = productService.GetProductDropDownList(lookupCodeId ?? 0);
            }


            foreach (LookupCodeMaster cat in lookUpCategories)
            {
                DropDownListViewModel ddl = new DropDownListViewModel();

                ddl.Id   = cat.LookupCodeId;
                ddl.Name = cat.LookupCodeName;
                _list.Add(ddl);
            }


            return(_list);
        }
コード例 #2
0
        private DropDownListViewModel AllTypeItems(string[] selectedValues = null)
        {
            var ddList = new DropDownListViewModel();

            // Add the values to be used in the checkbox list
            // The values can come from anywhere
            var selectListItems = new List <SelectListItem> {
                new SelectListItem {
                    Text = "Computer", Value = "Computer"
                },
                new SelectListItem {
                    Text = "Mobile", Value = "Mobile"
                },
                new SelectListItem {
                    Text = "Electronic", Value = "Electronic"
                }
            };

            // Concatenating with our DefaultItem so we have that classic "- SELECT -"
            ddList.SelectListItems = new SelectList(DefaultItem.Concat(selectListItems), "Value", "Text");

            if (selectedValues != null)
            {
                ddList.SelectedValues = selectedValues;
            }

            return(ddList);
        }
コード例 #3
0
        public IActionResult DropDownList(DropDownListViewModel model)
        {
            this.ViewBag.AllMonths = this.GetAllMonths();

            if (this.ModelState.IsValid)
            {
                return(this.View("DropDownListResult", model));
            }

            return(this.View(model));
        }
コード例 #4
0
        public JsonResult GetLevelCategory(int levelID)
        {
            DropDownListViewModel model = new DropDownListViewModel();

            try
            {
                var endpoint = url + "/LevelCategory/" + levelID;
                model = Utilities.RestAPIHelper <DropDownListViewModel> .Submit("", Method.GET, endpoint, Request);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(Json(model));
        }
コード例 #5
0
        // GET: Category
        public ActionResult Index()
        {
            DropDownListViewModel viewModel = new DropDownListViewModel();

            viewModel.categoryList.Add(new SelectListItem {
                Text  = "İstanbul",
                Value = "1"
            });
            viewModel.categoryList.Add(new SelectListItem
            {
                Text  = "Ankara",
                Value = "2"
            }); viewModel.categoryList.Add(new SelectListItem
            {
                Text  = "İzmir",
                Value = "3"
            });
            return(View(viewModel));
        }
コード例 #6
0
        public static MvcHtmlString CustomDropDownList(this HtmlHelper htmlHelper, string id, string label,
                                                       string dataBindingValue, int col = 6, string readUrl = "", bool required    = false, object currentValue = null,
                                                       bool readOnly = false, string eventChange            = "", string moreClass = "")
        {
            var viewModel = new DropDownListViewModel
            {
                Id               = id,
                Label            = label,
                DataBindingValue = dataBindingValue,
                Col              = col,
                Required         = required,
                CurrentValue     = currentValue,
                ReadUrl          = readUrl,
                ReadOnly         = readOnly,
                EventChange      = eventChange,
                MoreClass        = moreClass
            };

            return(htmlHelper.Partial("~/Views/Shared/Input/DropDownList.cshtml", viewModel));
        }