Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
3
Reply
Recursive Parent Child hierarchy with checkbox MVC 5
Mani Kandan
Feb 23 2017 6:58 AM
475
Reply
Hello everyone,
I want to bind Html like recursive Parent Child hierarchy with checkbox.
I have tried by foreach loop but showing only one productcategoryname.
@model List
<
Rebox.BIL.DataModel.ProductCategoryDM
>
@{
Layout
=
"~/Views/Shared/_Layout.cshtml"
;
}
<!DOCTYPE html
>
<
html
>
<
body
>
<
div
class
=
"board-canvas m-t-20"
>
@foreach (var item in Model)
{
if (
item.idParentCategoryProduct
== 0)
{
<
div
id
=
"board"
class
=
"u-fancy-scrollbar js-no-higher-edits js-list-sortable ui-sortable"
>
<
div
class
=
"js-list list-wrapper list-padding u-fancy-scrollbar"
>
<
ul
class
=
"offered-list"
>
<
li
>
<
div
class
=
"checkbox "
>
<
label
class
=
"hd-txt"
>
<
input
type
=
"checkbox"
value
=
""
>
@item.ProductCategoryName
</
label
>
</
div
>
</
li
>
@if (item.idParentCategoryProduct != 0)
{
<
li
>
<
div
class
=
"checkbox "
>
<
label
>
<
input
type
=
"checkbox"
value
=
""
>
@item.ProductCategoryName
</
label
>
</
div
>
@Html.Partial("_productOffered", item)
</
li
>
}
</
ul
>
</
div
>
</
div
>
}
}
</
div
>
</
body
>
</
html
>
It is the child partial view page,
@model Rebox.BIL.DataModel.ProductCategoryDM
@{
}
@foreach (var item in Model.productCategory)
{
<
ul
class
=
"offered-sub-list"
>
@if (item != null)
{
<
li
>
<
div
class
=
"checkbox "
>
<
label
>
<
input
type
=
"checkbox"
value
=
""
>
@item.ProductCategoryName
</
label
>
@if (item.productCategory.Count
>
0)
{
@Html.Partial("_productOffered", item)
}
</
div
>
</
li
>
}
</
ul
>
}
And this table structure. I want to show 0 idparentcategoryproduct name at top heading by each seperated coloums like above image showing.
How can I manage foreach loop at View page?
Please help me...
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
3
)
Next Recommended Forum
Onclick Button hide row forever in GridView ASP.NET
'Oracle.DataAccess.Client.OracleCon threw an exception.