Thursday, June 14, 2012

How to hide and show the fileds or controls in sharepoint 2010

Here i wanna show how to hide the control in editable form in share point at server side.Here i have requirement to show the salesperson name and hide the salesperson id when the form in edit mode.For this there is pretty simple property used in share point to hide controls or Field i:e ShowInEditForm.I just set the property to true for salesperson name field to show and false for id field to hide
SPSite ss = new SPSite(url)
SPWeb sw = ss.OpenWeb())
SPList slist = sw.Lists["Orders"];  
SPField salespname = slist.Fields["salesPerson"];
SPField salesid = slist.Fields["SID"];
//show the salesperson name field in edit mode   
salespname.ShowInEditForm = true;
//to hide the sales person field in edit mode  
salesid.ShowInEditForm = false;  
salesid.Update(); 
salespname.Update();
Post a Comment

Bel