Thursday 25 April 2013

Adding a hidden field to a Sharepoint 2010/2013 list.

Today I am celebrating 100,000 visits of my blog with this beautiful post.

The other day was trying to add some columns to a Survey list, and I noticed that every column was a particular question of the survey. I only want to keep extra data in the list without displaying it, so I add what it is called in Sharepoint a hidden field. A hidden field it is considered a system field for Sharepoint, something the user can’t see. The is a good way to find hidden fields, just open the list on Sharepoint Designer 2010 and you will be able to see them.

This code will allow you to add a hidden field called “myhiddencolumn”

using (SPSite _site = new SPSite(SPContext.Current.Web.Url))
{
  using (SPWeb _web = _site.OpenWeb())
  {
     String _sField= "<Field Hidden=\"TRUE\" Type=\"Text\" DisplayName=\"myhiddencolumn\" ResultType=\"Text\" ReadOnly=\"False\" Name=\"myhiddencolumn\"> </Field>";
     _web.AllowUnsafeUpdates = true;
     SPList _spList = _web.Lists["mysurveylist"];
     _spList.Fields.AddFieldAsXml(_sField);
     _spList.Update();
   }
}

7 comments:

Anonymous said...

If you want to improve your knowledge simply keep visiting this web page and be updated with
the latest information posted here.

Also visit my web blog :: Buy lift serum

Anonymous said...

This post is actually a nice one it assists new web visitors, who are wishing in favor of blogging.


Also visit my homepage - somanabolic muscle maximizer

Anonymous said...

I loved as much as you'll receive carried out right here. The sketch is attractive, your authored material stylish. nonetheless, you command get got an edginess over that you wish be delivering the following. unwell unquestionably come more formerly again as exactly the same nearly very often inside case you shield this hike.


Pure Garcinia Cambogia REviews

Anonymous said...

I am curious to find out what blog platform you happen to be working with?
I'm experiencing some minor security problems with my latest website and I would like to find something more risk-free. Do you have any suggestions?

Also visit my webpage :: LeParfait

Anonymous said...

Nice post. I was checking constantly this blog and I'm impressed! Very helpful information particularly the last part :) I care for such info much. I was looking for this particular information for a very long time. Thank you and good luck.

My web site - Order Garcinia Cambogia

Emil said...

Sorry newbie here, how do I add this code? Do I Add a web part and click content editor? Thanks!

chenmeinv0 said...

chanel bags
moncler coats
hermes outlet
moncler sale
rolex watches
cheap uggs
oakley sunglasses
abercrombie and fitch clothing
ralph lauren outlet
gucci handbags
2016.12.17xukaimin