-
July 30th, 2020, 04:21 AM
#1
change the return view fields after insert data
In my controller class,
public ActionResult Index()
{
return View(db.Schools.ToList());
}
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Create([Bind(Include = "SchoolId,SchoolType,SchoolName")] SchoolModels schoolModels)
{
schoolModels.Status = 1;
schoolModels.RegDate = DateTime.Now.ToString();
schoolModels.ModifiedDate = null;
if (ModelState.IsValid)
{
db.Schools.Add(schoolModels);
db.SaveChanges();
return RedirectToAction("Index");
}
return View(schoolModels);
}
After successfull insert, the Index page shows all the column values,
SchoolType,SchoolName,Status,RegDate,ModifiedDate
But I want to display only SchoolType,SchoolName,Status these columns. And for the value of Status it should be:
if Status = 1 display ACTIVE; if Status = 2 display HOLD if Status = 3 display COMPLETED.
How can I do this?
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|