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
Sumon Sumon
NA
77
4.4k
Nested foreach in C# MVC?
Sep 21 2018 3:08 AM
I'm New to C# MVC and I'm failed to implement following situation, I have a database and it's table Data like below
Company
Branch
Section
Employee_ID
abc ltd.
branch11
section1
111001
abc ltd.
branch11
section2
221001
xyz ltd.
branch11
section1
551001
xyz ltd.
branch22
section1
551001
Each Company has separate Branch, Each Branch has Separate Section Each Section has Separate Employee_ID
I need a Model Class and A Razor View to represent the Data with a nested foreach loop like below.
foreach(var company in model.Company)
{ foreach ( var branch in company)
{ foreach (var section in branch)
{ foreach ( var empid in section)
}
}
}
Is it possible? How I write the model class? Data needs to be looked like
abc ltd.
branch11
section1
111001
section2
221001
xyz ltd.
branch11
section1
551001
branch22
section1
661001
Reply
Answers (
1
)
How to scan QR code image and get result in C# web input?
How to link JavaScript with mvc 5