MVC 3: Bind View page with more than two model classes | Coding Cluster - using asp.net, c#, mvc 4, iphone, php, ios, javascript, in asp.net mvc 3 & more
 

MVC 3: Bind View page with more than two model classes

Friday

ASP.NET MVC 3: How to call two model class in to a single view(.cshtml)
                                             This is the sample code for load two  model class in to a single view in asp.net mvc 3. To do this you just create a composite class with both objects as its properties:

In Model
public class MoviePersonModel
{
public MvcContrib.Pagination.IPagination<MvcContrib.Samples.UI.Models.Person> Person{ get; set; }
public MvcContrib.Pagination.IPagination<MvcContrib.Samples.UI.Models.Movie> Movie{ get; set; }
}

initialize the class and apply to view.

In View
@model urNamespace.MoviePersonModel

//and access its properties: @Model.PersonModel

Please share this post with your friends. If it's useful to you. Thanks!.

0 comments:

Post a Comment

Share your thoughts here...

 
 
 

RECENT POSTS

Boost

 
Blogger Widgets