1
我在表中包含此值「American | African | Asian」的字段。我想從字段中獲取值並拆分文本並將其綁定到下拉列表中。我使用MVC 3創建一個htmlhelper來分割文本
到目前爲止,我有這樣一條:
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))
[你有什麼嘗試?](http://mattgemmell.com/2008/12/08/what-have-you-tried/) – Iridio
請看看更新的一個。 – user335160