I have a profile page in which i have an education section for that i have created a partial view and on button click i am opening the partial view and then saving the data but after saving it is not loading the grid with latest data i need to refresh the page . check the below code
- [HttpPost]
- [ValidateAntiForgeryToken]
- public ActionResult Create([Bind(Include = "ID,Degree_Level,Degree_Name,Institution_Attended,User_Id,BoardORUniversity,MarksObtained,TotalMarks,Year_Passed,Active,Date_Started,Date_End,Date_Created,Date_Modified")] Student_Experience student_Experience)
- {
- ViewBag.Colleges = _IEducation.PopulateColleges();
- if (ModelState.IsValid)
- {
- db.Student_Experience.Add(student_Experience);
- db.SaveChanges();
- return RedirectToAction("Index");
- }
- return View(student_Experience);
- }
My Partial view is below
- @model CMS_Monitoring.Models.Student_Experience
- @{
- /**/
- Layout = null;
- }
- "viewport" content="width=device-width" />
Create - @using (Html.BeginForm())
- {
- class="form-horizontal">
- @*
Add Qualification
*@- @Html.ValidationSummary(true, "", new { @class = "text-danger" })
class="form-group">- @Html.LabelFor(model => model.Degree_Level, htmlAttributes: new { @class = "control-label col-md-2" })
class="col-md-10">- @Html.DropDownListFor(model=>model.Degree_Level, new List
- {
- new SelectListItem{ Text="Select Degree", Value = "0" },
- new SelectListItem{ Text="High School", Value = "1" },
- new SelectListItem{ Text="Intermediate", Value = "2" },
- new SelectListItem{ Text="Bechelor's", Value = "3" },
- new SelectListItem{ Text="Master's", Value = "4" },
- new SelectListItem{ Text="Doctorate (PhD)", Value = "5" },
- new SelectListItem{ Text="Vocational", Value = "6" },
- new SelectListItem{ Text="Associate Degree", Value = "7" },
- new SelectListItem{ Text="Certification", Value = "8" },
- }, new { @class = "btn form-text", @id = "myid" })
- @Html.ValidationMessageFor(model => model.Degree_Level, "", new { @class = "text-danger" })
class="form-group">- @Html.LabelFor(model => model.Degree_Name, htmlAttributes: new { @class = "control-label col-md-2" })
class="col-md-10">- @Html.EditorFor(model => model.Degree_Name, new { htmlAttributes = new { @class = "form-control" } })
- @Html.ValidationMessageFor(model => model.Degree_Name, "", new { @class = "text-danger" })
class="form-group">- @Html.LabelFor(model => model.Institution_Attended, htmlAttributes: new { @class = "control-label col-md-2" })
class="col-md-10">- @Html.EditorFor(model => model.Institution_Attended, new { htmlAttributes = new { @class = "form-control" } })
- @Html.ValidationMessageFor(model => model.Institution_Attended, "", new { @class = "text-danger" })
- @*
class="form-group">*@- @Html.LabelFor(model => model.User_Id, htmlAttributes: new { @class = "control-label col-md-2" })
class="col-md-10">- @Html.EditorFor(model => model.User_Id, new { htmlAttributes = new { @class = "form-control" } })
- @Html.ValidationMessageFor(model => model.User_Id, "", new { @class = "text-danger" })
class="form-group">- @Html.LabelFor(model => model.BoardORUniversity, htmlAttributes: new { @class = "control-label col-md-2" })
class="col-md-10">- @Html.EditorFor(model => model.BoardORUniversity, new { htmlAttributes = new { @class = "form-control" } })
- @Html.ValidationMessageFor(model => model.BoardORUniversity, "", new { @class = "text-danger" })
class="form-group">- @Html.LabelFor(model => model.MarksObtained, htmlAttributes: new { @class = "control-label col-md-2" })
class="col-md-10">- @Html.EditorFor(model => model.MarksObtained, new { htmlAttributes = new { @class = "form-control" } })
- @Html.ValidationMessageFor(model => model.MarksObtained, "", new { @class = "text-danger" })
class="form-group">- @Html.LabelFor(model => model.TotalMarks, htmlAttributes: new { @class = "control-label col-md-2" })
class="col-md-10">- @Html.EditorFor(model => model.TotalMarks, new { htmlAttributes = new { @class = "form-control" } })
- @Html.ValidationMessageFor(model => model.TotalMarks, "", new { @class = "text-danger" })
class="form-group">- @Html.LabelFor(model => model.Year_Passed, htmlAttributes: new { @class = "control-label col-md-2" })
class="col-md-10">- @Html.EditorFor(model => model.Year_Passed, new { htmlAttributes = new { @class = "form-control" } })
- @Html.ValidationMessageFor(model => model.Year_Passed, "", new { @class = "text-danger" })
class="form-group">- @Html.LabelFor(model => model.Active, htmlAttributes: new { @class = "control-label col-md-2" })
class="col-md-10">class="checkbox">- @Html.EditorFor(model => model.Active)
- @Html.ValidationMessageFor(model => model.Active, "", new { @class = "text-danger" })
class="form-group">- @Html.LabelFor(model => model.Date_Started, htmlAttributes: new { @class = "control-label col-md-2" })
class="col-md-10">- @Html.EditorFor(model => model.Date_Started, new { htmlAttributes = new { @class = "form-control" } })
- @Html.ValidationMessageFor(model => model.Date_Started, "", new { @class = "text-danger" })
class="form-group">- @Html.LabelFor(model => model.Date_End, htmlAttributes: new { @class = "control-label col-md-2" })
class="col-md-10">- @Html.EditorFor(model => model.Date_End, new { htmlAttributes = new { @class = "form-control" } })
- @Html.ValidationMessageFor(model => model.Date_End, "", new { @class = "text-danger" })
- @*
class="form-group">- @Html.LabelFor(model => model.Date_Created, htmlAttributes: new { @class = "control-label col-md-2" })
class="col-md-10">- @Html.EditorFor(model => model.Date_Created, new { htmlAttributes = new { @class = "form-control" } })
- @Html.ValidationMessageFor(model => model.Date_Created, "", new { @class = "text-danger" })
class="form-group">*@- @Html.LabelFor(model => model.Date_Modified, htmlAttributes: new { @class = "control-label col-md-2" })
class="col-md-10">- @Html.EditorFor(model => model.Date_Modified, new { htmlAttributes = new { @class = "form-control" } })
- @Html.ValidationMessageFor(model => model.Date_Modified, "", new { @class = "text-danger" })
class="form-group">class="col-md-offset-2 col-md-10">- "submit" id="sbmtInput" value="Create" class="btn btn-default" />
- @*@{Html.RenderAction("Index", "Student_Experience");}*@
- @Html.ActionLink("Cancel", "Index", "Student_Experience", null, new { @class = "btn btn-dark active" })
- @*
- }
- @**@
- @Html.ActionLink("Back to List", "Index")
- @Scripts.Render("~/bundles/jquery")
- @Scripts.Render("~/bundles/bootstrap")
Sagar MaldePosted Oct 14, 2019, 12:35 AM