1

How to remove a field from a List in Sharepoint 2010?

Any help please?

2 Answers2

2

I assume you mean using code. This code should do the trick.

SPWeb web = SPContext.Current.Web;
SPList list = web.Lists["List Name"];
SPField field = list.Fields["Field Name"];
field.Delete();
Rob Windsor
  • 6,744
  • 1
  • 21
  • 26
  • That is, field.DeleteObject() – Brain2000 Jan 06 '13 at 06:27
  • It's Delete(). http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spfield.delete(v=office.12).aspx – Rob Windsor Jan 07 '13 at 21:55
  • Oh, you're right. This is the SPList, not the Microsoft.Sharepoint.List. My bad. – Brain2000 Jan 08 '13 at 18:18
  • Hi @Rob, this may be very late but can you please suggest me a way to delete a custom column from a content type in csom? What I'm doing is getting the filed from the content-type and when I try to delete it using field.DeleteObject(); it throws an exception: Additional information: Site columns which are included in content types or on lists cannot be deleted. Please remove all instances of this site column prior to deleting it. Please help me with this. – Abhishek Feb 06 '15 at 11:25
  • This question has been asked a couple times in these forums. Please see http://stackoverflow.com/search?q=Site+columns+which+are+included+in+content+types+or+on+lists+cannot+be+deleted – Rob Windsor Feb 06 '15 at 13:48
  • @RobWindsor, thanks for replying. Seems like http://stackoverflow.com/questions/28319613/how-to-delete-a-site-column-reference-from-a-content-type-in-sharepoint-client-m would answer my question but there's no reply to it. Can you sugest anything? – Abhishek Feb 06 '15 at 14:49
0

just go to your list, go to List Settings (in the ribbon), scroll down to your fields (columns) and delete it.

Is not a big deal.

Best regards!

ricardordz
  • 235
  • 1
  • 6