Questions tagged [asp.net-mvc-viewmodel]

View model is a class, that represents data model used in specific view.

View model has many roles:

  • View models documents view by consisting only fields, that are represented in view.
  • View models may contain specific validation rules using data annotations or IDataErrorInfo.
  • View model defines how view should look (for LabelFor,EditorFor,DisplayFor helpers).
  • View models can combine values from different database entities.
  • You can specify easily display templates for view models and reuse them in many places using DisplayFor or EditorFor helpers.
497 questions
-1
votes
1 answer

LINQ in .NET MVC: Any advantage to creating a ViewModel vs. joining tables?

I'm working on a simple project where I have data in two tables that I need to return to my View from my controller. I'm aware of two methods to do this in .NET, the first is create a model class, add the properties you need to access in your view,…
Katherine
  • 3,318
  • 1
  • 13
  • 17
-1
votes
1 answer

How to utilize C# properties correctly in this specific ASP.NET MVC scenario?

I have properties defined in my view model like so - public string FullName { get { return FirstName + " " + LastName; } set { FirstName = FullName.Split(null)[0]; LastName =…
GilliVilla
  • 4,998
  • 11
  • 55
  • 96
-1
votes
2 answers

PartialView with a ViewModel on _Layout.cshtml

I have a layout page which has a partial view. The partial view needs to loop through a property on the view model to show a list of categories. When a category is displayed I need to show a list of documents in that category. /Home/Index works, but…
Echilon
  • 10,064
  • 33
  • 131
  • 217
-1
votes
1 answer

add item base on other item id in one to many relation

I have this razor view that contain a few items base on some condition , I need to add a comment to any of the item (just like comment here in SO). trying to pass the id to a different form didn't work , this is what I have done but i guess it's the…
Danny
  • 301
  • 1
  • 4
  • 21
-1
votes
1 answer

Asp.Net MVC 5 1 View 2 models with viewmodel The model item passed into the dictionary is of type error

I am new to Asp.Net MVC and I am coding a simple blog with using ASP.NET MVC 5 Framework. I can create edit and delete posts. You can see my code on GitHub in details. And I want to add comment property to Details page of every posts or articles. I…
Alp
  • 604
  • 2
  • 6
  • 23
-1
votes
1 answer

MVC Pass data from view to controller

I am developing a MVC application..I have a requirement where in I have 5 textboxes (user uses this to search) and a grid to display what user has searched for on the same web page..View is binded with model coming from database which has output of…
Naga
  • 88
  • 2
  • 4
  • 14
-1
votes
1 answer

Null Reference Error when directly assigning a List object to an PagedList

KeyMaster Model public class KeyMasterModel { public int KeyId { get; set; } public int TypeId { get; set; } public string TypeName { get; set;} } PagedKeyModel public class…
-1
votes
1 answer

Inserting multiple entities into many-to-many linking table

My web application has a many-to-many link between the Station and Timetable entities, and the entity that links them is called StationTimetable, which also holds data about the linkage between the two entities. When I create a new Timetable, I want…
-1
votes
2 answers

how to show already existed permission using checked checkbox in Edit page

i have to show a list of permissions attached to role. while creating the role which permissions are attached to that role using checkbox should be displayed checked in edit page. for this i have created a viewmodel. when i call the edit page all…
Reshav
  • 545
  • 3
  • 9
  • 31
-1
votes
1 answer

MVC ViewModel - Need to define viewmodel

I am storing a questionnaire which is in xml format to a string type data field called Questionnaire. The database fields are contactID and Questionannire. I am doing this in an MVC application.Can someone tell me what should the ViewModel look like…
-1
votes
3 answers

MVC4 ViewModel System String Error

This is a common Error on SO but I seem not to be able to fix the error The model item passed into the dictionary is of type 'System.String', but this dictionary requires a model item of type…
Diin
  • 565
  • 11
  • 41
-1
votes
1 answer

How to bind form with model data in MVC

here i have one model. now i want to buil form using html helper . so when index action will be called then i want to populate model data by hand and send the model to view. here is my model data but the way i want to build form not being possible…
Mou
  • 15,673
  • 43
  • 156
  • 275
-2
votes
1 answer

Binding list of nested viewmodels on post ASP.NET MVC

I have the following viewmodel structure: ItemViewModel containing a property Model of type BaseViewModel. In this concrete example, Model is of type WeekManagerWorkScheduleViewModel. This viewmodel in turns consists of an IEnumerable of type…
-2
votes
1 answer

MVC Insert row into database with dropdown from another model

I am trying to create a "Create" form to insert new Results into a table. I have one model which is mapped to this table, first of the three shown below, and another two that I want to use to display data for dropdowns, but bind the result to…
-2
votes
1 answer

One view having multiple button in asp.net mvc

I am not able to understand the flow on this page how they are doing in MVC http://demo.nopcommerce.com/onepagecheckout till now i created only one button for one page (view ) or provide me some similar link or similar code so i can understand i…
user1035814
  • 184
  • 2
  • 4
  • 14
1 2 3
33
34