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
Guest User
Tech Writer
2.1k
466.7k
Dropdownlistfor On your View return null, how to fix it?
Sep 7 2020 3:16 AM
Hi Team
I need some help, i want to create list of values using dropdownlist for, now on the view i am getting a null object when accessing them.
@
using
(Html.BeginForm(
"SuperAdmin"
,
"Home"
, FormMethod.Post))
{
<div
class
=
"form-group row"
>
<label
for
=
"Content-Licence"
class
=
"col-sm-3 col-form-label"
>Content Licence</label>
<div
class
=
"col-sm-5"
>
@Html.DropDownListFor(model => model.Dashboard.CourseLicence,
new
SelectList(Model.lsteNtsaDashboard))
</div>
</div>
}
public
ActionResult SuperAdmin() {
var list =
new
List<
string
>() {
"Private(Copyrighted)"
,
"Public Domain"
,
"Creative Commons Licences"
,
"CC Attribution"
,
"CC Attribution Share ALike"
,
"CC Attribution Non-Commercial"
,
"CC Attribution Non-Commercial Share Alike"
,
"CC Attribution Non Directive"
,
"CC Attribution Non-Commercial No Directives"
};
ViewBag.list = list;
return
View(list);
}
public
class
eNtsaDashboardViewModel
{
public
string
CourseName {
get
;
set
; }
public
List<eNtsaCourses> CourseLicence {
get
;
set
; }
}
Reply
Answers (
2
)
Autocomplete Text box Ajax
System.InvalidOperationException: 'There is no ViewData item of type '