Mark Tabor

Mark Tabor

  • 587
  • 2k
  • 459.9k

How to bind listing view with view model in asp.net core

Aug 1 2024 2:08 PM

Dear All I would like to ask a question I have a view in which i am creating the records and in same view I have one partial view in which I am showing my listing my create view is working fine and it saves the records as well , but my partial view as it need to show the listing when I iterate through the model listing it says model does not exists , basically I dont have model I have one VIEWMODEL in which I have all models Like 
public class NewinformationVm

{

public int id,

public person person{get;set;} //here person itself is a class with properties 

public student students{get;set;}//here student itself is a class with having properties 

public NewinformationVm()

{

students=new students()//initializing me model which are in view model
person=new person()//initializing my model which are in view model 
 

 

}

}
my partial view is like this 

@model myprojectname.ViewModels.NewinformationVm
when i tried 
@foreach(var item in model)
it says model does not exists can someone help me 


Answers (1)