This is a migrated thread and some comments may be shown as answers.

Loading Data into Dropdownlist...

0 Answers 103 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Dennis
Top achievements
Rank 1
Dennis asked on 16 Jul 2012, 06:08 PM
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

No answers yet. Maybe you can help?

Tags
DropDownList
Asked by
Dennis
Top achievements
Rank 1
Share this question
or