Server Binding

2 posts, 0 answers
  1. Sylvain
    Sylvain avatar
    1 posts
    Member since:
    Apr 2012

    Posted 20 Jun 2012 Link to this post

    Dear all,

    I have a problem with a server binding (I also try a ajax() binding without success).

    Here is my model:
    public class PlaceModel
    {
        public Guid Id { get; set; }
        public string Name { get; set; }
     
        public PlaceModel()
        {
        }
    }
    Here is mycontroller
    namespace Noolibee.Presentation.Web.SandBox.Controllers
    {
        public class InventoryController : Controller
        {
            //
            // GET: /Inventory/
     
            public ActionResult Inventory()
            {
                //Get all places in the database
                IInventoryService serviceRepo = ServiceBusinessFactory.Create<IInventoryService>();
                List<INV_Place> places = serviceRepo.GetAllPlaces();
     
                //Convert the places to a placeModel (for testing purpose)
                List<PlaceModel> placesModel = new List<PlaceModel>();
                foreach (INV_Place item in places)
                {
                    placesModel.Add(new PlaceModel() { Id = item.Id, Name = item.Name });
                }
     
                //Return the view with the list of placeModel for the combobox
                return View(placesModel.AsEnumerable<PlaceModel>());
            }
        }
    }
    End finally, my webpage:
    @model IEnumerable<Noolibee.Presentation.Web.SandBox.Models.PlaceModel>
    @{
        ViewBag.Title = "Inventory";
        Layout = "~/Views/Shared/_Layout.cshtml";
    }
     
    <h2>Inventory (size = @Model.Count())</h2>
     
    <div>
            @(Html.Kendo().ComboBox()
                .Name("placesDropDownList")
                .DataTextField("Name")
                .DataValueField("Id")
                .BindTo(Model)
                .SelectedIndex(0)
            )
     
             
    </div>
    So, the value @Model.Count tells me that there's 1 item, but the combobox is empty.
    I should have miss something, but what ?

    Thanks for your help
    Sylvain
  2. Sylvain
    Sylvain avatar
    1 posts
    Member since:
    Apr 2012

    Posted 20 Jun 2012 Link to this post

    Ok ... I found. It was actually a problem in the layout.chtml in the script section ..

    more precisely :
    <script src="@Url.Content("~/Scripts/Kendo/jquery.min.js")"></script>

    I forgot to add the '/Kendo' path !

    Sylvain
  3. UI for ASP.NET MVC is VS 2017 Ready
Back to Top