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
vergel aranas
NA
70
17k
Display records
Jan 21 2013 2:54 AM
Hi, I really need help for this, I am new to mvc asp.net. My problem is how display the records that i query from different table into the editor view.
public ActionResult Edit(int id = 0)
{
SecurityGroup securitygroup = db.SecurityGroups.Single(s => s.Id == id);
if (securitygroup == null)
{
return HttpNotFound();
}
//collection of records I want to display.
var sql = from a in db.SecurityDetails
join b in db.SecurityGroups on a.SecurityGroupId equals b.Id
join m in db.Menus on a.MenuId equals m.Id
join d in db.Departments on b.DepartmentId equals d.Id where a.SecurityGroupId == id
select new
{
menu = m.MenuName,
name = b.Name,
dept = d.DepartmentName,
desc = b.Description,
view = a.CanView,
add = a.CanAdd,
edit = a.CanEdit,
active = a.IsActive
};
//How can I display these records into the Edit view? Please help me! Thanks
ViewBag.DepartmentId = new SelectList(db.Departments, "Id", "DepartmentName", securitygroup.DepartmentId);
return View(securitygroup);
}
//
// POST: /SecurityGroup/Edit/5
[HttpPost]
public ActionResult Edit(SecurityGroup securitygroup)
{
if (ModelState.IsValid)
{
db.SecurityGroups.Attach(securitygroup);
db.ObjectStateManager.ChangeObjectState(securitygroup, EntityState.Modified);
db.SaveChanges();
return RedirectToAction("Index");
}
ViewBag.DepartmentId = new SelectList(db.Departments, "Id", "DepartmentName", securitygroup.DepartmentId);
return View(securitygroup);
}
Reply
Answers (
2
)
How to canecl,and stop the progressbar using cancel button,stop button? in window application using c# language
how to canecel and stop the progressbar using stop button and cancel button with example and code in c# language with window application?