How to Migrate DropDownLists's DBContext to MVC5 using Latest UI for MVC bits

2 posts, 0 answers
  1. Sid
    Sid avatar
    18 posts
    Member since:
    Oct 2007

    Posted 03 Feb 2015 Link to this post


    I'm migrating an MVC3 application to MVC5 which includes heavy use of the Kendo library.  My new solution includes the bits from UI for MVC.  I'm seeing an issue with defining the DBContext for a particular view.  My code is as follows:
    01.var ctx = System.Web.HttpContext.Current.GetDataContext;
    04.            dataValueField: "id",
    05.            dataTextField: "name",
    06.            dataSource:$jqInt.merge([{ id:'', name:'Select Country'}], @Html.Raw(Json.Encode(ctx.AFCountries.Select(x => new {, })))),
    07.            change: function(e){
    08.                quote.set("toCountry", e.sender.value());
    09.                $jqInt("#to-city").data("kendoDropDownList");
    10.            }
    11.        });

    Since I'm now using Entity Framework and have a Model AFCountry, what must I do to ensure that the DropDownList pulls from this particular table?  Is there a new/different approach that must be taken?

    Thanks much for your help and guidance.
  2. Georgi Krustev
    Georgi Krustev avatar
    3687 posts

    Posted 05 Feb 2015 Link to this post

    Hello Sid,

    In general, context defining is not related to Kendo UI widget. What I would suggest you is to remove the DropDownList list from the page and just output the raw version of the data you would like to display. If the rendered data is the correct JSON, then there should be no reason why it shouldn't work with the dropdownlist.

    Georgi Krustev
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top