Hi All,
Although this might be a very simple post to blog but just for information i want to share it.
May times you require to add data into choice column of list.
Let's say you have 5 languages in the list choice column
you have C#, VB.NET, ASP.NET, JAVA, COBOL in the column and you want C# and JAVA to be selected, then here is a simple way to do it.
using(SpSite objsite = new SPSite("<your_site>");
{
using(SPWeb objWeb = objsite .OpenWeb())
{
SPList objList = objWeb.Lists["<your_list>"];
SPListItem objItem = objList .Items.Add();
objItem["Languages"] = ";#C#;#Java";
objItem .Update();
}
}
That's it. Very simple.
Thursday, July 10, 2008
Subscribe to:
Post Comments (Atom)
Share your SharePoint Experiences with us...
As good as the SharePointKings is, we want to make it even better. One of our most valuable sources of input for our Blog Posts comes from ever enthusiastic Visitors/Readers. We welcome every Visitor/Reader to contribute their experiences with SharePoint. It may be in the form of a code stub, snippet, any tips and trick or any crazy thing you have tried with SharePoint.
Send your Articles to sharepointkings@gmail.com with your Profile Summary. We will Post them. The idea is to act as a bridge between you Readers!!!
If anyone would like to have their advertisement posted on this blog, please send us the requirement details to sharepointkings@gmail.com

4 comments:
how can i add item to choice fild(dropdown list)of list programmaatically using objlistitem.Add()of sharepoint object model
Hi yelina,
suppose options in your dropdown field is 1,2,3,4
you can add or set value in dropdown field by.
SPListItem item=list.Itesm.Add();
item["DropdownField"]="2";
this way you can set value of 2 in your dropdown field.even you can set value which is not in dropdown field suppose you want value 50 to set you can set it but while you edit this list item in edit mode will not appear in dropdown option.
item["DropdownField"]="50";
so you can't change schema of dropdown but still you can change value.
hello,
sorry, but I am a complete newbie to Sharepoint ..
Where do you put this code ? In which file?
thx,
Finally! THANK YOU both. Yelina for asking the question, and Jayesh for answering. I've been trying to find this answer for ever. Thinking that it had to do with indexers or something crazy of that nature. But you can just set the text option. Thank You!
Post a Comment