我已经创建了一个模板位置图模板,其中包含两个字段,如下所示:
Field 1-->
Name: Value
DataType: Integer
Field 2-->
Name: CP_Value
DataType: Integer现在,我已经在sitecore节点下创建了文件夹位置图列表,并在该文件夹下添加了5个包含其值的项(即在以下输入的值字段中显示的值,而不是CP_Value字段中的值):
East-5
Midwest-11
South-13
West-2
International-9现在,我希望通过ajax调用在Sample.aspx页面上获取这些位置项集合,并在文件后面的代码中写下以下代码:
List<Item> locationChartsDesc = new List<Item>();
var valueFieldName = "Value" //Value OR CP_Value
var parentItem = SampleSitecoreHelper.GetItemByPath("/sitecore/content/Global Items/Location Chart List");
List<Item> locChild = new List<Item>();
if (valueFieldName != string.Empty)
{
locationChartsDesc = parentItem.GetChildren().OrderByDescending(x => x.Fields[valueFieldName].Value).ToList();
}在这个步骤中,我得到的项目顺序是:
International-9
East-5
West-2
South-13
Midwest-11,这是错误的
这一步的项目顺序必须是:
South-13
Midwest-11
International-9
East-5
West-2这个代码有什么问题吗?
谢谢
发布于 2014-09-23 06:50:38
我得到了答案,我必须做以下几件事:
Convert.ToInt16(x.Fields[valueFieldName].Value) https://stackoverflow.com/questions/25969441
复制相似问题