Note that there are some explanatory texts on larger screens.

plurals
  1. POMultiple Models Binding Falied (MVC 4)
    text
    copied!<p>i'm trying to get data to my view from multiple models but every time I got an error, I tried a lot to fix this but I was failed...plz help me with this..i am posting my code..n I have created view-models for this</p> <p>this is a index view</p> <pre><code>@model Stubify.Models.ViewModels.TimeLine &lt;div class="media social-box social-composer "&gt; &lt;a class="pull-left social-users-avatars" href="#"&gt; &lt;img class="media-object" width="55" height="55" src="../Content/assets/img/avatar-55.png" alt="Julio Marquez"&gt; &lt;/a&gt; &lt;div class="media-body social-body"&gt; @foreach (var item in Model.User.Take(1)) { &lt;textarea id="new_message" name="new_message" class="textarea span12" placeholder="What's happening, @item.FullName?" cols="10"&gt;&lt;/textarea&gt; } &lt;div class="social-footer"&gt; &lt;div class="btn-group"&gt; &lt;a class="btn" data-original-title=""&gt;&lt;i class="icon-map-marker"&gt;&lt;/i&gt;&lt;/a&gt; &lt;a class="btn" data-original-title=""&gt;&lt;i class="icon-camera"&gt;&lt;/i&gt;&lt;/a&gt; &lt;/div&gt; &lt;button class="btn btn-primary pull-right" type="button"&gt;Post&lt;/button&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;div id="NewsFeeds"&gt; @Html.Partial("_NewsFeeds", Model) &lt;/div&gt; &lt;div id="loading"&gt;&lt;/div&gt; </code></pre> <p>this is a view model</p> <pre><code>public class TimeLine { public virtual IEnumerable&lt;Users&gt; User { get; set; } public virtual IEnumerable&lt;UsersPosts&gt; UsersPost { get; set; } } </code></pre> <p>this is a partial view</p> <pre><code> @model Stubify.Models.ViewModels.TimeLine @foreach(var item in Model) { &lt;div class="social-share-image"&gt; &lt;img src="../Content/assets/img/gallery/sunset.jpg" alt="Sun Set"&gt; &lt;div class="social-share-image-text"&gt; &lt;h4&gt;@item.UserId&lt;/h4&gt; &lt;p&gt;&lt;strong&gt;@item.PostContent!&lt;/strong&gt;&lt;small&gt; @item.Date &lt;i class="icon-globe"&gt;&lt;/i&gt;&lt;/small&gt;&lt;/p&gt; &lt;/div&gt; &lt;/div&gt; } </code></pre> <p>this is a controller </p> <pre><code>public ActionResult Index(string searchTerm = null, int? id = 0) { var viewModel = new TimeLine(); var page = id ?? 0; viewModel.User = db.Users.OrderByDescending(u =&gt; u.Id) .Where(u =&gt; searchTerm == null || u.FullName.ToLower().Contains(searchTerm)).Take(records); if (Request.IsAjaxRequest()) { return PartialView("_NewsFeeds", GetPaginatedProducts(page)); } return View(viewModel); } </code></pre> <p>please help me plzzz</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload