我在表中有一个字段包含这个值“美国|非洲|亚洲”。我想从字段中获取值并拆分文本并将其绑定到下拉列表中。我正在使用 MVC 3。
到目前为止,我有这个:
public static SelectList SplitText(this HtmlHelper html, string texttosplit, string seperator)
{
return new SelectList(texttosplit.Split('|'));
}
但我不知道如何在下拉列表中绑定它
@Html.DropDownListFor(model => model.EM_opt1Values, @Html.SplitText(this will have an error it will not accept model => model.EM_opt1Values) )