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
Anan Srivastava
NA
27
1.3k
Return value from function to ActionMethod in controller
Jul 20 2018 2:13 AM
[HttpPost]
public
ActionResult AddVolunteer(VolunteerInfo viewModel)
{
if
(!ModelState.IsValid)
{
return
View(
"AddVolunteer"
, viewModel);
}
var volunteer =
new
VolunteerInfo()
{
Name = viewModel.Name,
DonationForWhom = DonationValue()
//Here's the error. Expecting a parameter
};
_context.VolunteerInfos.Add(volunteer);
_context.SaveChanges();
return
RedirectToAction(
"Index"
,
"Home"
);
}
public
string
DonationValue(
string
name)
{
return
name;
//not sure how to pass this above
}
The error is in the 12th line: There is no argument given that corresponds to the required formal parameter 'name' of 'VolunteerInfoController.DonationValue(string)' VMS.
I don't know how to correct this. Please help me
Reply
Answers (
14
)
What is problem in web config asp.net error
How to publish c# application online