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


Top 5 Contributors of the Month
david stephan

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

Responses
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;
SPSecurity.RunWithElevatedPrivileges(delegate()
{
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.
itmDummy.Update();
web.AllowUnsafeUpdates = false;
web.Dispose();
}
});

hopefully it can help you ...

Mark As Answer if this solve your problem
Warm Regards,
Venkat
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";
fld.Update();
web.Dispose();


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.

Thanks,
Bijayani
http://www.mindfiresolutions.com/Sharepoint-Support.htm



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
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

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