我想在页面上显示Umbraco表单中的记录。到目前为止,我设法显示:
如何限制它只显示5条最新记录(“显示我的名字”值为TRUE)?
我的代码如下:
<ul id="formData">
@{int i = 0;}
@foreach (dynamic record in Library.GetApprovedRecordsFromPage(@CurrentPage.Id).OrderBy("Created descending"))
{
if (@record.GetField("Display my name").Values[0].ToString() == "True")
{
<li>
Name: @record.GetField("Name").Values[0]<br />
Email: @record.GetField("Email").Values[0]<br />
Display my name: @record.GetField("Display my name").Values[0]<br />
Created: @record.Created.ToString("dd MMMM yyy")<br />
</li>
}
i++;
}
</ul>
<h4>Total data: @i</h4>
答案 0 :(得分:1)
您可以将属性值检查放入.Where(...)?所以
.Where(x => x.GetField("Display my name").Values[0].ToString() == "True").OrderBy(whatevs).Take(5)
答案 1 :(得分:0)
我建议您使用此代码获取记录:
package trialprogram;
public class Interviewaskedq {
public static void main(String[] args) {
// TODO Auto-generated method stub
String S1="12SERT34";
String alpha=" ";
String num=" ";
for(int i=0;i<=S1.length()-1;i++)
{
char ch=S1.charAt(i);
if(Character.isAlphabetic(ch))
{
alpha=alpha+ch;
}
else if(Character.isDigit(ch))
{
num=num+ch;
}
}
int result = Integer.parseInt(num);
}
}