I have a question which i think might be better to take advice on rather than starting implementing it. So i have a class which is basically Generated By entity framework and that class will be used to save the data from the User. Now i have 3 classes which will be used to implement Cascading Drop down list in my Create.cshtml.
So
public class Form
{
public int Id {get; set;}
public string Country {get; set;}
public string state {get; set;}
public string city {get; set;}
public string Name {get; set;}
public string Email {get; set;}
}
public class Country
{
public int CountId {get; set;}
public string Country {get; set;}
}
public class State
{
public int stateId {get; set;}
public string State {get; set;}
public int CountId {get; set;}
}
public class City
{
public int Id {get; set;}
public string City {get; set;}
public int stateId {get; set;}
}
As you can see their is one to many relationship between Country --> state and State --> city.
The Form class is basically used to fill the form from the user like a registeration form something of that sort.
Now i create strongly typed View against Form class but the problem is their is no way get the Country, State, City property from their Fields and i do not want to add fields to my Form Class because my database save only these fields.So i created another class ClassForRealform (What i know is this technique is called as MVVM or View model)
public class ClassForRealform
{
<pre>public int Id {get; set;}
public string Country {get; set;}
public string state {get; set;}
public string city {get; set;}
public string Name {get; set;}
public string Email {get; set;}
public virtual List<Country> countries {get; set;}
public virtual List<state> states {get; set;}
public virtual List<City> cities {get; set;}
}
Now bind my form to this class
now i add an controller action method let's say "Save"
public actionresult Save(Form form)
{
//Code to save
}
Now my question is can i do this binding my view to another class and passing data to another class and thus [populating the fields required? hope i make myself clear here
2. one more thing thats little out of line
How to place an empty label using html.label("",new {id ="label1" })
like this but above do not work