.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Melody Anderson

Home >> Forum >> SharePoint >> Post New QuestionBookmark and Share Subscribe to Forum

Update sharepoint field

Posted By: William Thompson     Posted Date: April 20, 2010    Points:2   Category :SharePoint
I have a custom list named Alert Templates. It has a column named Status of type CHOICE...now i want to change the value of this field via coding.

Please help me!!!

Author: Venkat             
Posted Date: April 20, 2010     Points: 5   

Please try this one.... hope it can help :-
oWeb = SPContext.Current.Web;
oSite = SPContext.Current.Site;
Guid webGuid = oWeb.ID;
Guid siteGuid = oSite.ID;
SPWeb web = null;
using (SPSite site = new SPSite(siteGuid))
web = site.OpenWeb(webGuid);
SPList lst = web.Lists["YourCustomList"];
web.AllowUnsafeUpdates = true;
// get your custom column name here and update the value, as specified in the post above mine post.
web.AllowUnsafeUpdates = false;

hopefully it can help you ...

Mark As Answer if this solve your problem
Warm Regards,
Author: Sunil Yadav       [Moderator]      
Posted Date: May 21, 2010     Points: 5   

Hi following code will help u..

SPSite site = new SPSite("http://mossserver/");
SPWeb web = site.OpenWeb();
SPList selectedList = web.Lists["Alert Templates"];
SPFieldChoice fld = (SPFieldChoice)selectedList.Fields["Status"];
fld.Title = "New Title";

Author: bijayani             
Posted Date: June 22, 2010     Points: 5   

Choice fields are often used within SharePoint lists to display choice options like Gender, Status, etc and these choice options can be displayed using Radio Button and Dropdown formats.

Provided below is a code sample in C#.Net which describes the creation of a choice field programmatically using SharePoint API.

Hope you find this tips useful and of assistance.


Post Reply

You must Sign In To post reply
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend