This question is locked. New answers and comments are not allowed.
Hello,
I'm implementing the treeview of telerik in an MVC3 ASP.NET application.
Im' getting this error :
Exception Details: System.InvalidOperationException: Sequence contains no elements
Source Error:
the view is there :
the action in the controller is there :
and the model is there :
thank you for help.
I'm implementing the treeview of telerik in an MVC3 ASP.NET application.
Im' getting this error :
Exception Details: System.InvalidOperationException: Sequence contains no elements
Source Error:
Line 7:
Line 8: @model IEnumerable<MyProject.Models.MyTable>
Line 9: @(Html.Telerik().TreeView()
|
the view is there :
@{ ViewBag.Title = "MyPageTelerik"; Layout = "~/Views/Shared/_Layout.cshtml";}<h2>MyPage Telerik</h2>@model IEnumerable<MyProject.Models.MyTable>@(Html.Telerik().TreeView() .Name("TreeView") .BindTo(Model, mappings => { mappings.For<MyProject.Models.TABLE>(binding => binding .ItemDataBound((item, MyTable) => { item.Text = MyTable.Parent; }) .Children(MyTable=> MyTable.Alias_Child)); mappings.For<MyProject.Models.MyTable>(binding => binding .ItemDataBound((item, child) => { item.Text = child.Alias_Child; })); }))the action in the controller is there :
public ActionResult MyActionTelerik(){ return View(MyTable.GetParents());}and the model is there :
using System;using System.Collections.Generic;using System.Linq;using System.Web;using Oracle.DataAccess.Client;using System.Collections;using System.Data.Linq;namespace MyProject.Models{ public class MyTABLE { private string CHILD_ID; private string PARENT; private string ALIAS_CHILD; public FIC_AXE_MOT(string child_id, string parent, string alias_child) { this.Child_Id = Child_id; this.Parent = parent; this.Alias_Child = alias_Child; } public virtual string Child_Id { get { return CHILD_ID; } set { CHILD_ID = value; } } public virtual string Parent { get { return PARENT; } set { PARENT = value; } } public virtual string Alias_Child { get { return ALIAS_Child; } set { ALIAS_CHILD = value; } } public static IEnumerable<MyTABLE> GetParents() { IEnumerable<FIC_AXE_MOT> monIEnumerable = null; ArrayList monArray = new ArrayList(); string _CHILD_ID; string _PARENT; string _ALIAS_CHILD; string connString = "Data Source = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = muhost.fr)(PORT = 1531)))(CONNECT_DATA = (SERVER = DEDICATED)(SERVICE_NAME = MySERV))); User Id=admin;Password=admin;"; OracleConnection connOracle = new OracleConnection(connString); connOracle.Open(); OracleCommand cmdObj = connOracle.CreateCommand(); cmdObj.CommandText = "SELECT * FROM MyTable"; OracleDataReader rdrObj = cmdObj.ExecuteReader(); if (rdrObj.HasRows) { while (rdrObj.Read()) { _CHILD_ID = rdrObj.GetString(rdrObj.GetOrdinal("CHILD")); _PARENT = rdrObj.GetString(rdrObj.GetOrdinal("PARENT")); _ALIAS_CHILD = rdrObj.GetString(rdrObj.GetOrdinal("ALIAS_CHILD")); MyTable objMyTable = new MyTable(_CHILD_ID,_PARENT,_ALIAS_CHILD); monArray.Add(objMyTable ); }; }; monIEnumerable= monArray.Cast<MyTable>(); return monIEnumerable; } }}thank you for help.