public void CopyList(SPList src)
{
//Copy items from source List to Destination List
foreach (SPListItem item in src.Items)
{
if(isUnique(item.UniqueId))
{
newDestItem = DestinationList.Items.Add();
foreach (SPField field in src.Fields)
{
try
{
if ((!field.ReadOnlyField) && (field.InternalName!="Attachments"))
newDestItem[field.InternalName] = item[field.InternalName];
}
catch (Exception ex)
{
//you should save the "ex" somewhere to see its outputs
ex.ToString();
}
}
newDestItem.Update(); //only now you call update!
}
}
}
{
//Copy items from source List to Destination List
foreach (SPListItem item in src.Items)
{
if(isUnique(item.UniqueId))
{
newDestItem = DestinationList.Items.Add();
foreach (SPField field in src.Fields)
{
try
{
if ((!field.ReadOnlyField) && (field.InternalName!="Attachments"))
newDestItem[field.InternalName] = item[field.InternalName];
}
catch (Exception ex)
{
//you should save the "ex" somewhere to see its outputs
ex.ToString();
}
}
newDestItem.Update(); //only now you call update!
}
}
}
No comments:
Post a Comment