Como criar lista de seleção para país e estados / província em MVC
Oi eu sou novo no MVC e até mesmo asp ..
Eu quero criar um formulário no MVC. Com a ajuda de alguns exemplos, eu posso criar TextBoxes, mas agora eu não entendo como criar Select List./
Eu tentei pesquisar muitos exemplos para implementar Select List no MVC, mas não consigo entender.
Eu tenho um formulário que é metade codificado em HTML e metade em MVC.
Aqui está o meu código:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace MedAvail.Applications.MedProvision.Web.Models
{
public class AddressViewModel
{
public string Street1 { get; set; }
public string Street2 { get; set; }
public string City { get; set; }
public string Province { get; set; }
public string Country { get; set; }
public string PostalCode { get; set; }
public string PhoneNumber { get; set; }
}
}
<form id="locationInfo">
<h1>Location Information</h1>
<table width="80%" id="locInfo">
<colgroup>
<col width="20%" />
<col />
</colgroup>
<tr>
<th>@Html.Label("Country")</th>
<td>
<select required="">
<option>Select Country</option>
<option>Canada</option>
<option>United States</option>
</select>
<span class="required">*</span>
</td>
</tr>
<tr>
<th>@Html.LabelFor(x=>x.State)</th>
<td>
<select required="">
<option>Select State</option>
<option>State 1</option>
<option>State 2</option>
<option>State 3</option>
...............
</select><span class="required">*</span></td>
</tr>
<tr>
<th>@Html.LabelFor(x=>x.PostalCode)</th>
<td>@Html.TextBoxFor(x=>x.PostalCode)<span class="required">*</span></td>
</tr>
<tr>
<th>@Html.LabelFor(x=>x.City)</th>
<td>@Html.TextBoxFor(x=>x.City)<span class="required">*</span></td>
</tr>
<tr>
<th>@Html.LabelFor(x=>x.StreetAddress1)</th>
<td>@Html.TextBoxFor(x=>x.StreetAddress1)<span class="required">*</span></td>
</tr>
<tr>
<th>@Html.LabelFor(x=>x.StreetAddress2)</th>
<td>@Html.TextBoxFor(x=>x.StreetAddress2)</td>
</tr>
<tr>
<th>@Html.LabelFor(x=>x.PhoneNumber)</th>
<td>@Html.TextBoxFor(x=>x.PhoneNumber)</td>
</tr>
</table>
<div role="button" class="marginTop50 marginBottom">
<input type="button" id="step3Back" value="Back" class="active" />
<input type="button" id="step3confirmNext" value="Next" class="active marginLeft50" />
</div>
</form>
Por favor me guie em como criar a Select List para este tipo de formulário.