开发者

I want to get the maximum number in a particular column of sharepoint 2010 list

Below is the query that I am trying

 SPQuery query = new SPQuery();
 query开发者_运维问答.RowLimit = 1;
 query.Query = "<Query><OrderBy><FieldRef Name='Identifier' Ascending='False' /></OrderBy></Query>";
 SPListItemCollection Items = list.GetItems(query);
 if (Items.Count > 0)
 {
 SPListItem item = Items[0];
 maxValue = (int)item["Identifier"];
 }

This is the error that I am getting *strong text*Specified cast is not valid.


What type is the "Identifier" column? It's not a field of SPListItem so I'm assuming it is the name of a column in your list.

Try:

var tempVal = item["Identifier"];

then put a breakpoint there and see what Visual Studio tells you about the structure and type of that item.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜