tags:

views:

164

answers:

0

In stackoverflow post i found this code to copy list item .

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!
        } 
       } 
      } 

can someone tell me what all i need to do if i want to select an item and copy it using this code .

e.g do i need to create a feature.xml and element.xml ? in other words how can i build the complete solution of copying any item from any list using this code and paste it to same list or if possible other list . basically from a beginner perspective.

any help appreciated