TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Abhilash J A
536
2.4k
597k
IList does not contain a definition for where, treeview MVC
Jan 6 2017 12:25 AM
Hello everyone,
In MVC 4, How can I generating a treeview with recursive partial view ?
This is the sql database treeview structure.
I have tried,
namespace
Reboxwebapp.Models.ViewModel
{
public
class
ProductCategoryVM
{
public
int
idProductCategory {
get
;
set
; }
public
string
ProductCategoryName {
get
;
set
; }
public
string
ProductCategoryDescription {
get
;
set
; }
public
Nullable<
int
> idParentCategoryProduct {
get
;
set
; }
public
string
AlternateNamesToSearch {
get
;
set
; }
public
Nullable<
int
> LevelID {
get
;
set
; }
public
string
CompletePathName {
get
;
set
; }
public
byte
[] PCImage {
get
;
set
; }
}
public
class
SeededProductCategies
{
public
int
? Seed {
get
;
set
; }
public
IList<ProductCategoryVM> Categories {
get
;
set
; }
}
}
[HttpGet]
public
ActionResult GetSearchProduct()
{
ProductsBIL objProduct =
new
ProductsBIL();
IList<ProductCategoryBL> lsRes =
new
List<ProductCategoryBL>();
lsRes = objProduct.GetProductCategoryTree();
IList<ProductCategoryVM> categories =
new
List<ProductCategoryVM>();
// ProductCategoryVM objProductCategoryVM = new ProductCategoryVM();
// categories = lsRes;
foreach
(var item
in
lsRes)
{
categories.Add(
new
ProductCategoryVM {idProductCategory =item.idProductCategory,idParentCategoryProduct = item.idParentCategoryProduct,ProductCategoryDescription = item.ProductCategoryDescription });
}
SeededProductCategies objSeededProductCategies =
new
SeededProductCategies { Seed =
null
, Categories = categories };
return
View(objSeededProductCategies);
}
GetSearchProduct
actionresult go to view is shown below,
@model Reboxwebapp.Models.ViewModel.SeededProductCategies
@Html.Partial("_TreeCategories", Model)
then partial view,
@model Reboxwebapp.Models.ViewModel.SeededProductCategies
@if (Model.Categories.Where(
s
=
>
s.idParentCategoryProduct
== Model.Seed).Any()) /*But here is occurring error : ilist does not contain a definition for where cause*/
{
<
ul
>
@foreach (var node in Model.Categories)
{
if (
node.idParentCategoryProduct
== Model.Seed)
{
Reboxwebapp.Models.ViewModel.SeededProductCategies
inner
=
new
Reboxwebapp.Models.ViewModel.SeededProductCategies {
Seed
=
node
.idProductCategory,
Categories
=
Model
.Categories };
<
li
>
<
a
href
=
"
[email protected]
"
>
@node.ProductCategoryDescription
</
a
>
@Html.Partial("_TreeCategories", inner)
</
li
>
}
}
</
ul
>
}
How can I do this? Please help me.
Reply
Answers (
3
)
grid view controls
How to Pass Eval value to if statement in aspx page?