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.
精彩评论