Different approaches to Bind Multiple Models on a View (MVC)
Nakul Chaudhari
Different ways to achieve it:1. View Model ViewModel is a class which contains the properties which are represented in view or represents the data that you want to display on your view/page.2. View Bag We use view Bag to pass data from controller to view.ViewBag use the property that takes advantage of the new dynamic features in C# 4.0.There is no typecasting needed in case of ViewBag. So we can take help of ViewBag to pass multiple data from controller to View. ViewBag is a property of ControllerBase class.View Bag scope is only during the current request.3. View Data ViewData is used to pass data from controller to view.View Data scoper is only during the current request.View Data needs typecasting for getting data.ViewData is a property of ControllerBase class.ViewData is a derivative of the ViewDataDictionary class, so we can access with “key/value”4. Temp Data TempData is also a dictionary derivative from TempDataDictionary class. TempData stored in short lives session. We can pass multiple models through TempData also.