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();
   }
}

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

ninest123 said...

replica watches, louis vuitton, air jordan pas cher, longchamp pas cher, ray ban sunglasses, nike air max, oakley sunglasses, ugg boots, oakley sunglasses, nike free, nike roshe run, louboutin shoes, michael kors, louboutin, longchamp outlet, louis vuitton outlet, polo ralph lauren outlet, longchamp outlet, tiffany jewelry, tiffany and co, jordan shoes, tory burch outlet, ugg boots, air max, louis vuitton, replica watches, nike free, louis vuitton, uggs on sale, sac longchamp, burberry, chanel handbags, oakley sunglasses, polo ralph lauren outlet, louboutin outlet, longchamp, louis vuitton outlet, prada outlet, cheap oakley sunglasses, oakley sunglasses, christian louboutin outlet, louboutin pas cher, ralph lauren pas cher, ray ban sunglasses, kate spade outlet, ray ban sunglasses, nike air max, prada handbags, gucci outlet, nike outlet

ninest123 said...

burberry outlet online, nike air max, coach purses, nike air max, michael kors, timberland, new balance pas cher, true religion jeans, kate spade handbags, nike free run uk, north face, true religion jeans, ralph lauren uk, air force, hollister pas cher, ray ban uk, converse pas cher, lacoste pas cher, michael kors outlet, michael kors outlet, ugg boots, michael kors outlet, michael kors outlet, coach outlet, vans pas cher, hollister, burberry, coach outlet, nike blazer, oakley pas cher, vanessa bruno, mulberry, ugg boots, lululemon, hermes, tn pas cher, ray ban pas cher, sac guess, hogan, true religion jeans, abercrombie and fitch, true religion outlet, michael kors, nike air max, michael kors outlet, replica handbags, michael kors, nike roshe, north face, michael kors

ninest123 said...

longchamp, iphone 5s cases, hollister, ferragamo shoes, herve leger, jimmy choo shoes, giuseppe zanotti, north face outlet, vans shoes, mont blanc, nike huarache, celine handbags, iphone cases, iphone 6s cases, nike trainers, lululemon, louboutin, ralph lauren, iphone 6 cases, babyliss, s5 cases, hollister, north face outlet, nfl jerseys, bottega veneta, soccer shoes, oakley, baseball bats, abercrombie and fitch, ghd, chi flat iron, valentino shoes, beats by dre, asics running shoes, wedding dresses, reebok shoes, timberland boots, ipad cases, mac cosmetics, mcm handbags, nike roshe, nike air max, insanity workout, iphone 6s plus cases, birkin bag, p90x workout, hollister, instyler, iphone 6 plus cases, soccer jerseys, new balance

ninest123 said...

barbour jackets, toms shoes, lancel, supra shoes, juicy couture outlet, moncler, moncler, louis vuitton, thomas sabo, hollister, canada goose uk, canada goose, louis vuitton, doudoune canada goose, converse outlet, canada goose outlet, replica watches, bottes ugg, canada goose outlet, nike air max, gucci, moncler, pandora jewelry, canada goose, karen millen, marc jacobs, converse, moncler, ray ban, wedding dresses, montre pas cher, ugg,ugg australia,ugg italia, moncler, pandora charms, canada goose, moncler, canada goose, ugg,uggs,uggs canada, moncler, vans, swarovski crystal, sac louis vuitton pas cher, pandora jewelry, juicy couture outlet, louis vuitton, louis vuitton, moncler outlet, coach outlet, swarovski, ugg boots uk, links of london, ugg pas cher, pandora charms

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