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
Sagar Bandkar
1.4k
347
48.9k
2 View not call from first one in mvc using ViewModel
Dec 10 2016 6:25 AM
ViewModel:-
public class ProductPageViewModel
{
public string Message { get; set; }
public List<ProductViewModel> ProductsList { get; set; }
}
public class ProductViewModel
{
public bool Selected{ get; set; }
public int inCosId { get; set; }
public string vcCosCode { get; set; }
public string vcCosName { get; set; }
public string vcCosDesc { get; set; }
}
View 1:
@model EditorForSample.Models.ProductPageViewModel
@{
ViewBag.Title = "Select Products Page";
}
<table class="table table-bordered table-striped" id="example">
<thead>
<tr>
<th style="width:50px"><input type="checkbox" id="chkSelectAll"/></th>
<th><input type="text" class="search" hidden>Code</th>
</tr>
</thead>
<tbody>
@Html.EditorFor(m => m.ProductsList)
</tbody>
</table>
View 2:-
@model EditorForSample.Models.ProductViewModel
<tr>
<td class="text-nowrap">@Html.CheckBoxFor(m => m.Selected, new { @class = "chkSelect" })</td>
<td colspan="3">
@Model.vcCosCode
@Html.HiddenFor(m => m.inCosId)
</td>
</tr>
Controller
public ActionResult Index()
{
ProductPageViewModel model = new ProductPageViewModel();
var data = from cos in db.tblMstCostCenter_COS select cos;
model.ProductsList = new List<ProductViewModel>();
ProductViewModel product = null;
foreach (var u in data)
{
product = new ProductViewModel();
product.inCosId = u.inCosId;
product.vcCosName = u.vcCosName;
product.vcCosCode = u.vcCosCode;
product.Selected = false;
model.ProductsList.Add(product);
}
//string JSONresult;
//JSONresult = JsonConvert.SerializeObject(model.ProductsList);
//Response.Write(JSONresult);
return View(model);
}
Reply
Answers (
4
)
Bind Recourse in Full schedular Calendar from EntityFramewor
Piramid Program