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
Harpreet
NA
55
3.9k
MVC
Oct 12 2015 5:14 AM
Hi Sir,
Can u plzz check this one..
i am sending my whole code can u plz check its urgent.. in post method plz check i m not getting that update query
View:
@using MyDemoProject.Models
@model DetailsList
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.Id)
</td>
<td>
@Html.DisplayFor(modelItem => item.Name)
</td>
<td>
@Html.DisplayFor(modelItem => item.OldSeq)
</td>
<td>
<input type="text" value="@item.NewSeq" />
</td>
<td>
<input type="submit" value="Update" id="btnUpdate" />
</td>
</tr>
}
model
public class EmpDetails
{
public int Id { get; set; }
public string Name { get; set; }
public int OldSeq { get; set; }
public int NewSeq { get; set; }
}
public class DetailsList
{
public int Id { get; set; }
public string Name { get; set; }
public int OldSeq { get; set; }
public int NewSeq { get; set; }
public IEnumerable<EmpDetails> EmpDetailsList { get; set; }
}
Controller
projectEntities obj = new projectEntities();
[HttpGet]
public ActionResult EmployeeDetails()
{
List<EmpDetails> c2 = new List<EmpDetails>();
EmpDetails model = new EmpDetails();
var Empdet = from x in obj.Employees
//where x.Id==model.Id
select x;
foreach(var item in Empdet)
{
model = new EmpDetails();
model.Id = item.Id;
model.Name = item.Name;
model.OldSeq = Convert.ToInt16(item.OldSeq);
model.NewSeq = Convert.ToInt16(item.NewSeq);
c2.Add(model);
}
DetailsList abc = new DetailsList();
abc.EmpDetailsList = c2;
return View(c2);
}
[HttpPost]
public ActionResult EmployeeDetails(DetailsList model)
{
List<EmpDetails> results =
(from p in obj.Employees
where p.Id == model.Id
select p).ToList();
foreach (EmpDetails p in results)
{
p.is_default = false;
}
obj.SaveChanges();
return View();
}
}
Reply
Answers (
12
)
retrieve data from database & display in div
DateTimePicker