Click here to Skip to main content
15,907,392 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

i have created model with properties of
C#
public int Marital_Id { get; set; }
public IList<MaritalStatus> Maritalstatus { get; set; }
  public int Spousestatus_Id { get; set; }
public IList<RelationStatus> Spousestatus { get; set; }


here Marital am having separate table named as MaritalStatus
and for Spouse_status am having separate table named as RelationStatus

so how how i can load this in Drop down

can anyone tell how to write this in View Razor Engine and Controller how can i load this

Thanks
Posted

1 solution

Here is a high-level example:

C#
@model App.YourModelName

@using(Html.BeginForm())
{
<div>
   @Html.DropDownListFor(m => m.Marital_ID, Model.MaritalStatus)
</div>

<input type="button" value="Go" />
}

In your controller's action method, you can read back the selected id like this:

C#
public ActionMethod(YourModelName yourModel)
{
   // get the selected id from yourModel.Marital_ID
   return View(...);
}


Hope this helps!
 
Share this answer
 

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