SPWeb web = SPContext.Current.Web;
SPSiteDataQuery query = new SPSiteDataQuery();
query.Lists = "<Lists>" +
"<List ID=\"" + web.Lists.TryGetList("StaffNews").ID.ToString() + "\" />"+
"<List ID=\"" + web.Lists.TryGetList("CompanyNews").ID.ToString() + "\" />"+
"<List ID=\"" + web.Lists.TryGetList("ManagementNews").ID.ToString() + "\" />" +
"</Lists>";
Guid listItemId = new Guid(HiddenFieldID.Value);
DataTable dt = web.GetSiteData(query);
list["Nickname"] = TextBoxName.Text;
list["_Comments"] = TextBoxComment.Text;
list.Update();
|
|
|||||
|
|
Possibly, in addition to C.Marius answers you should wrap ID with " marks. So instead of
write
|
||||
|
|
|
I'm sorry but your code is quite faulty. You do a list loop (all Lists in the current Web) and then try to update one particular SPListItem by with what ID??
You should really review what are you trying to achieve, because the code it doesn't entirely make sense. [EDIT] - As it seems you are trying to update all result across the 3 specified list after retrieving results using SPSiteDataQuery. In order to achieve that you need:
See here to get you started up to the point where DataTable is populated http://chakkaradeep.com/index.php/retrieving-an-item-from-the-rootweb-and-subwebs-using-its-uniqueid |
|||||||||||
|
|
Adding a Stacktrace to the output will help to find the error. Just add
See: http://msdn.microsoft.com/en-us/library/system.exception.stacktrace(v=vs.90).aspx for more information on the StackTrace property. |
|||
|
|
