Monday, November 19, 2007

Creating Hidden field in sharepoint.

In sharepoint developement, we might require to create column which should not display while adding an item/or editing an item.
for example, Current status is the column which is not required to show this column when end user while editing or adding an item.we can achieve this by using the below code.
you can create this type of field by using below sample code.

SPSite objSite = new SPSite("http://portal/");
SPWeb objWeb = objSite.OpenWeb();
SPFieldCollection fields = objWeb.Lists["Oppurtunites"].Fields;
string newField = "";
fields.AddFieldAsXml(newField, true, SPAddFieldOptions.Default);
Current Status is field created which doesnt appear while adding an item/editing an item thru sharepoint UI.

No comments: