It's took me 3 hours to update a value in list item . 3 hours to query update a list item in Sharepoint.
What I was trying simple
items[0]["InternalListItemColumnNameToUpate"] = "True";
but this does not work....
To query update a list item in Sharepoint...use below
SPListItem spListItem = items[0];
spListItem["InternalListItemColumnNameToUpate"] = "True";
web.AllowUnsafeUpdates = true;
spListItem.Update();
web.AllowUnsafeUpdates = false;
sample code...
list = web.Lists.TryGetList("ListName");
SPQuery query = new SPQuery();
query.Query =
@"
";
SPListItemCollection items = list.GetItems(query);
SPListItem spListItem = items[0];
spListItem["InternalListItemColumnNameToUpate"] = "True";
web.AllowUnsafeUpdates = true;
spListItem.Update();
web.AllowUnsafeUpdates = false;
No comments:
Post a Comment