Loading Data into Dropdownlist...

1 posts, 0 answers
  1. Dennis
    Dennis avatar
    38 posts
    Member since:
    Aug 2012

    Posted 16 Jul 2012 Link to this post

    Can someone please help me figure out how to load data into my dropdown and also trigger an event and pass the text value into the method so I can update my grid. I'm using KendoUI along with MVC3.

    here is what I came up with but obviously I need some tweaking.

    dropdownlist.
    @(Html.Kendo().DropDownList()
              .Name("CodeManager")
              .DataTextField("ClassificationText")
              .DataValueField("ClassificationText")
    .Events(e => e.Change("change"))
              .BindTo(ViewData["ClassificationItems"] as SelectList) //Not sure where the binding to my controller goes to or how it gets called
            )

    Controller:
    public ActionResult Change(string someValue = "")
            {
                ViewData["Category"] = "Types";
                ViewData["Classifications"] = new SelectList(Classifications.List, "ClassificationText", "ClassificationText", someValue );
                var codModels = new List<CodeModel>();
                ViewBag.SelectedCatgory = someValue ?? "Type";

                if (Request.HttpMethod == "POST")
                {
                    var model = _codeRepository.Search(someValue ).ToModel();
                    return View(model);
                }
                return View(codModels);
            }

    Thanks
    Dennis
Back to Top