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
480.8k
How to save List value to a database in ActionResult?
Sep 11 2020 6:17 AM
Hi Team
I am struggling to save List<SelectedIte> eNtsaDashboard = new List<SelectedItem>(); to db. Anyone can help me below logic?
public
ActionResult SaveCourse(RegCoursesViewModel regCoursesView)
{
try
{
List<SelectListItem> eNtsaDashboard =
new
List<SelectListItem>();
var courseName = regCoursesView.Dashboard.CourseName;
var courseLicence = regCoursesView.eCourses.CourseLicence;
cb.Courses.Add(regCoursesView.Courses);
cb.SaveChanges();
}
catch
(Exception ex)
{
var error = ex.Message.ToString();
}
return
RedirectToAction(
"AllCourses"
);
}
// eNtsaRegCourses.
public
class
RegCoursesViewModel
{
public
eNtsaCourses Courses {
get
;
set
; }
public
eNtsaCourseList eCourses {
get
;
set
; }
public
eNtsaDashboardViewModel Dashboard {
get
;
set
; }
public
IEnumerable<SelectListItem> eNtsaDashboard {
get
;
set
; }
public
RegCoursesViewModel MainModel {
get
;
set
; }
}
Reply
Answers (
7
)
display all data from gridview column
Regular expression expression modification required