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
RAHUL NATH
NA
23
467
Pass viewmodel (contain List<ModelClass>) data to controller
Aug 20 2018 8:12 AM
In my application there is an edit page, which contains a list of data through a viewmodel. this viewmodel contains two list, i.e. List<ModelClass1> and List<ModelClass2>.
In the view, there are multiple row of data from the lists, and i want to edit the rows and send to the controller to save the data. For this, i am usuing - @using (Html.BeginForm("Submit", "ControllerName", FormMethod.Post)) {-----}
however, on submit button press, when the control moves to the action method, there i found, the data is retrieving as null. below is the action method -
public ActionResult Submit(ViewModel _ViewModel)
{
//
}
with a debug point, i found the view model is null for both the list.
below is the view model class -
public class ViewModel
{
public List<Model1> Model1List { get; set; }
public List<Model2> Model2List { get; set; }
}
could anyone let me know the way to pass the data to controller?
Reply
Answers (
2
)
Multiselect listbox
Please explain When to use CTE(Common Table Expression)?