Click here to Skip to main content
16,011,870 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have created Two classes in model as follows:
C#
public partial class Town
   {
       [Key]
       public string TnCode { get; set; }
       public string TnName { get; set; }
       public string TnDscode { get; set; }
       public string TnSpFlag { get; set; }
       public virtual ICollection<District> Districts { get; set; }

   }

and
C#
public partial class District
   {
       [Key]
       public string DsCode { get; set; }
       public string DsName { get; set; }
       public string DsSpFlag { get; set; }
       public virtual ICollection<Town> Towns { get; set; }
}

and
public MUContext db = new MUContext();// Database Context

I want to create a class(TnDs) with TnCode,TnName,DsCode,DsName,TnDsCode
so as to use Class(TnDs) in a view to List,Add,Modify,Delete
Posted

1 solution

Hi,

you can not pass multiple class to the view
you need to create a new model as follow
Ex:

C#
public class State{
   Town town;
  District district;
}
 
Share this answer
 
v2
Comments
priyankavm 10-Aug-13 1:17am    
thanks... but How do I call State in view & How do I display fields?
vyas_pratik20 12-Aug-13 0:23am    
hi ,

http://francorobles.wordpress.com/2011/05/03/returning-multiple-models-in-1-view-in-asp-net-mvc3/

will help you out
priyankavm 13-Aug-13 2:47am    
Thanks.............a lot

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900