title: Kendo TreeView sequence contains no elements error
body: <p>While using kendo treeview with server side data there is an issue while binding data in mvc</p>
  
  <p>my controller action is:</p>
  
  <pre><code>public ActionResult DayPart(long storeid)
          {
  
  
  
  
              IEnumerable&lt;TreeViewMapModel&gt; objDaypart = from item in new DayPartService().GetAll().ToList()
                                                         select new TreeViewMapModel
                                                         {
                                                             Id = item.Id,
                                                             Name = item.Name,
                                                             Items = (from map in new DayPartMappingService().GetByStoreId(storeid)
                                                                      where item.Id == map.DayPartId
                                                                      select new MasterModel() { Id = int.Parse(map.SourceId), Name = map.SourceLabel }).ToList(),
  
                                                         };
  
   var ret = objDaypart.Select(x =&gt; new TreeViewMapModel
             {
                 HasChildren = x.Items.Count() &gt; 0,
                 Id = x.Id,
                 Items = x.Items ?? Enumerable.Empty&lt;MasterModel&gt;(),
                 Name = x.Name
             });
  @ViewBag.storename = new StoreService().GetById(storeid).Name;
            return View(ret);
          }
  </code></pre>
  
  <p>and in the view</p>
  
  <pre><code>@model IEnumerable&lt;Apis.Web.MvcPortal.Areas.Setups.Models.TreeViewMapModel&gt;
   @(Html.Kendo().TreeView()
  .Name("right-treeview")
  .BindTo(Model.ToList(), (Kendo.Mvc.UI.Fluent.NavigationBindingFactory&lt;TreeViewItem&gt; mappings) =&gt;
  {
      mappings.For&lt;Apis.Web.MvcPortal.Areas.Setups.Models.TreeViewMapModel&gt;(bound =&gt; bound.ItemDataBound((node, structure) =&gt;
      {
          node.HasChildren = structure.HasChildren;
          node.Id = structure.Id.ToString();
          node.Text = structure.Name;
          })
  
      .Children(structure =&gt; structure.Items));
  })
          )
  </code></pre>
  
  <p>But i am getting error sequence contain no elements.Can anyone tell what m i doing wrong.</p>
  
  <p>My stack trace is:
     at System.Linq.Enumerable.First[TSource](IEnumerable<code>1 source)
     at Kendo.Mvc.UI.NavigationItemContainerExtensions.Bind[TNavigationItem](TNavigationItem component, Object dataItem, NavigationBindingFactory</code>1 factory)
     at Kendo.Mvc.UI.NavigationItemContainerExtensions.Bind[TNavigationItem](TNavigationItem component, Object dataItem, NavigationBindingFactory<code>1 factory)
     at Kendo.Mvc.UI.NavigationItemContainerExtensions.BindTo[TNavigationItem](INavigationItemContainer</code>1 component, IEnumerable dataSource, Action<code>1 factoryAction)
     at Kendo.Mvc.UI.Fluent.TreeViewBuilder.BindTo(IEnumerable dataSource, Action</code>1 factoryAction)
     at ASP._Page_Areas_Setups_Views_Mapping_DayPart_cshtml.Execute() in d:\APISBI_MVC\APISBI\Main\SRC\Apis.Web.MvcPortal\Areas\Setups\Views\Mapping\DayPart.cshtml:line 47
     at System.Web.WebPages.WebPageBase.ExecutePageHierarchy()
     at System.Web.Mvc.WebViewPage.ExecutePageHierarchy()
     at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage)
     at System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance)
     at System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer)
     at System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context)
     at System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult)
     at System.Web.Mvc.ControllerActionInvoker.&lt;>c_<em>DisplayClass1a.b</em>_17()
     at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation)</p>
  
  <p>Thanks in advance.</p>