This is a migrated thread and some comments may be shown as answers.
Getting error : Sequence contains no elements
1 Answer 84 Views
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Craig Tarp
Top achievements
Rank 1
Craig Tarp asked on 02 Jun 2010, 08:40 PM
hi all

I changed my model for a treeview to use an IEnumerable list of Course ( bascially am emulating the MVC treeview DEMO for model binding with treeview ) I get the error that the Sequence contains no elements

System.Web.Mvc.ViewPage<IEnumerable<XP.Models.CustomClasses.Course>>



<%

= Html.Telerik().TreeView().Name("TreeView")

 

.ClientEvents(events => events

 

.OnNodeDragStart(

"onNodeDragStart")

 

.OnNodeDragCancelled(

"onNodeDragCancelled")

 

.OnNodeDragging(

"onNodeDragging")

 

.OnNodeDrop(

"onNodeDrop")

 

.OnNodeDropped(

"onNodeDropped")

 

)

.DragAndDrop(

true)

 

.DragAndDrop(settings => settings

.DropTargets(

".drop-container")

 

)



 
.BindTo(Model, mappings => 
                {  
                    mappings.For<XP.Models.CustomClasses.Unit>(binding => binding                  
                   .ItemDataBound((item, unit) =>   
                                      {                                           
                                          item.Text = unit.Title;  
                                          item.Value = unit.Id.ToString();         
                                          item.ImageUrl = "../../Images/unit32.png";                                              
                                      })  
                    );  
 
                    mappings.For<XP.Models.CustomClasses.Lesson>(binding => binding                      
                   .ItemDataBound((item, lesson) => 
                                      {  
                                          item.Text = lesson.Title;  
                                          item.Value = lesson.Id.ToString();  
                                          item.ImageUrl = "../../Images/lesson32.png";  
                                      })  
                    );  
 
                    mappings.For<XP.Models.CustomClasses.Section>(binding => binding                    
                   .ItemDataBound((item, section) => 
                                   {  
                                       item.Text = section.Title;  
                                       item.Value = section.Id.ToString();  
                                       item.ImageUrl = "../../Images/section32.png";  
                                   })  
               );  
                }).HtmlAttributes(new { @class = "t-group" }) 

jQuery(

'#TreeView').tTreeView({ onLoad: onLoad, dragAndDrop: { "dropTargets": ".drop-container" }, onNodeDrop: onNodeDrop, onSelect: onSelect, onNodeDropped: onNodeDropped });

 



Prior to this I was just passing in the model (complex) and it worked fine with the exception that the textValue was not b
eing populated with the appropriated ID     (course ID  or section ID   etc)  ...Without the ID , I can't edit or Delete so I have to have the ID......All googling has let me to believe that there could be an issue with LINQ find a null mapping ....as the some lessons may not have sections..... Should I or can I specifiy where the Child of the Unit is Not NULL....would that fix this situation???   .Children(unit => unit.Lessons)  

thanks in Advance...you guys are great resource...

Craig T

BTW: error is on this line

 

System.InvalidOperationException: Sequence contains no elements
Line 182: <%= Html.Telerik().TreeView().Name("TreeView")

1 Answer, 1 is accepted

Sort by
0
Rockey
Top achievements
Rank 1
answered on 16 Aug 2010, 03:56 PM
Hello,

That means your not getting the necessary items from the table..so child values shouldn't be null.. make sure on debug u r getting all items from table.. 

because similar problem I faced it before that time my child items are null values.. 

thanks 
Tags
TreeView
Asked by
Craig Tarp
Top achievements
Rank 1
Answers by
Rockey
Top achievements
Rank 1
Share this question
or