Hii Everyone..
I want to send the select item from a drop down list to the database in asp.net mvc.
my only requirement is that how can all the values of drop down list {male, female}
will get save into the database.
I m new to MVC so please suggest me simple way to solve this issue
thnx in advance
What I have tried:
This is View
@{var listItems = new List<SelectListItem>
{
new SelectListItem {Text="Select Your Gender", Value="1"},
new SelectListItem {Text="Male", Value="2"},
new SelectListItem {Text="Female", Value="3"}
};
}
This is My HomeController
public ActionResult Create(Student s)
{
Sample dbContext = new Sample();
var v = dbContext.Students.Add(s);
dbContext.SaveChanges();
return RedirectToAction("GetAllStudent");
}