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

Server Binding

1 Answer 233 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Sylvain
Top achievements
Rank 1
Sylvain asked on 20 Jun 2012, 10:02 AM
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

1 Answer, 1 is accepted

Sort by
0
Sylvain
Top achievements
Rank 1
answered on 20 Jun 2012, 10:34 AM
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
Tags
ComboBox
Asked by
Sylvain
Top achievements
Rank 1
Answers by
Sylvain
Top achievements
Rank 1
Share this question
or