protected Dictionary<string, string> dtErrors = new Dictionary<string, string>();
string strKey = string.Empty;
string strValue = string.Empty;
foreach (int intError in Enum.GetValues(typeof(ArticleCategory)))
{
strKey = intError.ToString();
strValue = Enum.GetName(typeof(ArticleCategory), intError);
dtErrors.Add(strKey, strValue);
}
前台绑定
<select id="selType">
<option value="0">-请选择分类-</option>
<% foreach (KeyValuePair<string, string> oneKeyValue in dtErrors)
{%>
<option value="<%=oneKeyValue.Key %>">
<%=oneKeyValue.Value%></option>
<%} %>
</select>
上面这种绑定好球麻烦
<select id="selType">
<option value="0">-请选择分类-</option>
<% foreach (int intError in Enum.GetValues(typeof(ArticleCategory)))
{%>
<option value="<%= intError.ToString() %>">
<%=Enum.GetName(typeof(ArticleCategory), intError)%></option>
<%} %>
</select>
但是 这里面的select不能有server 否则就会显示上下文不支持此代码块。。。。