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
Robbie Hegarty
NA
51
0
Iterating through a viewbag of selectlist items
Jan 24 2019 6:32 AM
Hi folks
I have the following line in a controller:
ViewBag.Assignments = new SelectList(db.class_table_Assignment, "ID", "Title");
In the view (Razor) file I'm looking to iterate through the ViewBag and pull out entries were the ID = "isok"; then populate a DropDownList.
The following line : add_Li_Node(tmp_entry); is where I'm looking to extract the values in the ViewBag. I assumed the for loop would assign the contents of one row of the ViewBag to the variable tmp_entry during each iteration. The actual output I'm getting in the DropDown is "undefined". The for-loop is iterating correctly for the number of rows in the ViewBag.
So basically, I'm asking if anyone can help me iterate through the contents of a ViewBag of SelectList items and view each entry before deciding to keep it.
Thanks in advance.
Reply
Answers (
6
)
Asp.net form validation with angularjs
Usercontrol life cycle