如何获取成员打印到页面的下拉数据类型?

How do I get the dropdown datatype for members to print to the page?

我想知道如何根据数据类型中的值制作 html 下拉列表?需要以prevalue为name,关联的ID号为value。

这可以通过以下代码实现:

@using System.Xml.XPath
@{ 
  XPathNodeIterator iterator = umbraco.library.GetPreValues(1124);
  iterator.MoveNext();
  XPathNodeIterator preValues = iterator.Current.SelectChildren("preValue", "");
}

    <select name="codeTheme">
        @while (preValues.MoveNext())
        {
            string preValue = preValues.Current.Value;
            string id = preValues.Current.GetAttribute("id", "");

            <option value="@id" @(member.GetValue("codeTheme").ToString() == id ? "selected" : "")>@preValue</option>
        }
    </select>

您只需将 GetPreValues(xxxx) 中的 ID 编号更改为您要定位的数据类型的 ID。要找到它,请在 Umbraco 后端导航到数据类型并从 URL.

中获取数字

"codeTheme"需要在会员区改成属性的名字