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

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

How do I add user entered item to choice list items programmatically?

Posted By:      Posted Date: April 14, 2011    Points: 0   Category :C#

Hi friends,

I have been a share point developer for five months and I have a question that how to add user specified values to choice items.

Here  I ill give you the short probelm definition.

I have the list named as "Emloyee list" with two fields, are "Name" and "Offices".

The value for the field is "Name" is to enter bye the user (E.g: Kumar)

After that the field "Offices" is the choice list with the default items("Office1,Office2,Office3..) and the user has selected the option as Office2.

Now the the list has one row of information as

Name         Offices

Kumar        Office1

Like wise we can add the list items.

In the ablove context for the field "Offices" I need to add the choice items dynamically so that the user no need to follow up the asusal strategy that.. By selecting Settings->List itemsettings->selecting column name.. add the 4th choice option like "Office4"..

I hope u understand my requirement.

Can anybody please help me in this regard.

Thanks in advance,



View Complete Post

More Related Resource Links

Creating Sites/Lists/List Items under Current User Context in SharePoint By Using SPUserToken

Usually we do this by performing the action under RunWithElevatedPrivileges method and updating the listitem using SPListItem.SystemUpdate() method (see here). but this approach has its own flaws like (RunWithElevatedPrivileges will run under system account, we cannot use SystemUpdate for SPSite,SPWeb,SPList, since it runs under system we will "CreatedBy" by as SystemAccount).

How to Set a list item's createdby or modifiedby field as a User(deleted from AD)



I have to migrate data from SQL DB to SP list. But its old data and some users who created/modified the record has been deleted from the AD. Now I need to set the CreatedBy / ModifiedBy Field of the item accordingly. How to achieve this?

And when I tried to modify the "Editor" and "Author" field through Object Model, it works. But its not working through Webservice. What is the reason behind this?

Please help me find an optimal solution for this...


Thanks and Regards,

/* John JB */

how to get values of list item being entered in ItemAdding event handler?

Hi,          i am trying to get the values being entered in a listitem in the ItemAdding eventhandler as follows, but it doesnt work. public override void ItemAdding(SPItemEventProperties properties)         {             base.ItemAdding(properties);             SPSite CurrentSite = new SPSite("http://mm-moss/np/");             SPWeb CurrentWeb = properties.OpenWeb();             SPList CurrentList = CurrentWeb.Lists[properties.ListId];             string vehicleNo = CurrentList.Items[CurrentList.Items.Count - 1]["Vehicle No"].ToString();             string  name=CurrentList.Items[CurrentList.Items.Count-1]["Name"].ToString(); } when i debug i cant get hold of the VehicleNo value. canyone help me in getting the values of the list item being entered? Thank you all.

Get related item id in task list to display all task items related to this item

this is my scenario i have a document library with customized workflow in this workflow i have 6 collect data from user all of them have description feild i need when user display any item in library to view all of its description feilds related to this document as its meta data   sooo any idea

SharePoint 2010 email enabled list with workflow has incorrect User ID when items are emailed to the

I have set up an approval workflow for a document library that has email enabled. Emails come into the document library fine, however, if an item is emailed to the library the workflow kicks off with the initiator as "System Account" rather than the person who submitted the email. This makes the error of "The e-mail message cannot be sent. Make sure the e-mail has a valid recipient." come up. If someone submits a document directly to the library (by logging into sharepoint and submitting) everything works fine. The person submitting by email is a valid sharepoint user and the profile shows the correct email address. The Created by and Modified by fields show the correct person (rather than System Account), it's only the workflow User ID that shows incorrectly if document is emailed to library. Any help or ideas would be appreciated. Thanks

Can an authenticated user add items to a list anonymously?

I have a requirement to allow authenticated users to post items to a list anonymously. The SharePoint site is not enabled to allow anonymous access, so all users will be authenticated. Given that every item that is created in a list will have a Creator, is it possible therefore to impersonate another user? e.g. create an "Anonymous" account and somehow force all new items in a particular list to be created by this account. Perhaps the best way would be to write a WebPart whose UI contains the fields required and then programatically creates the list item as another user (using SPUserToken to get an SPSite object)? If there's a way to do it without code, I'd definitely be interested... Thanks, Alex

How get the list of user's "i like" items

Hi guys, I would like to retrieve the user's "i like" item. How can I do that? tnx

How to remove 'Delete Item' from context menu of a programmatically created list?

How to remove 'Delete Item' from context menu of a programmatically created list?
I have document library which is created programmatically but now I don't want to have 'Delete Item' in context menu of that document library. Are there any possibilites?

How to delete custom list items programmatically?


Can anybody tell me how to delete custom list items programmatically?


Copy list item one to another site programmatically with


Hi Everyone,

I know that this question is asked earlier many time. but some of the thing is missed in the every answer and question.

I am using SharePoint Foundation 2010,

I have Structure of my site like


Main Site

> Site1

- Site1Sub1

> Site2

- Site2Sub1


Site1 and Site2 and their sub site List schema is same. just changes in the workflows and item forms.

I need to copy Task List from Site1Sub1 to Site2Sub1. 

I know there are solutions available at




Create list and allow only one item per user


I'm trying to create a list where each user can only create one item, and change the item he has created.

I also need the list to allow each user to view only his own item

When I create a custom list and configure it so that each user can only view and edit his items and after that I try to configure a column validation to allow only different values it gives me an error saying that a list where a user can only see his items cannot have that type of column validation.

I was trying to use this type of validation on a column because I had the column to be auto-filled by the new/edit form (customized via infopath) with the user's username, that way I could ensure that only one item per user would ever exist. However, since I am not allowed to configure the column validation this way, I can't go this route.

Is there a simple way to achieve the effect I am looking for?

Item Event Receivers or way to validate data entered for External List in SharePoint 2010?

Hi everyone,

Are there Item Event Receivers for External List in SharePoint 2010? If not, is there a way to validate the item data entered from External List UI in SharePoint site?


How to delete a list item in Sharepoint that will also delete sub-items


I have a list of user information and on the DispForm.aspx page, I also have a section to insert sub-items (assets).  I would like to know how to setup a way so that when I delete the main item, it will delete all sub-items as well.  Any information would be greatly appreciated!


how to programatically retrieve permission of a user on a list item?



            is it possible to retrieve the permission of a user on a list item programatically.? i mean if a user has the rights Contirbute on the list item can i get that programatically that he has Contribute rights?

 please help. your help is appreciated.


C#: How to Add Item to SharePoint list using web services? One of the field is a choice field.


I have a code that looks something like this:



batch.SetAttribute("OnError", "Continue");
batch.SetAttribute("ListVersion", "1");
batch.SetAttribute("ViewName", "{GUID of my View}");

batch.InnerXml = "<Method ID='1' Cmd='New'>" +
"<Field Name='Title'>Something</Field>" +
"<Field Name='Status'>Something Else</Field> </Method>";

myList.UpdateListItems("{GUID of my List}", batch);


the field name "Status" is a choice field. When i execute this code, my program doesn't add anything to my sharePoint List. However when I remove the 

"<Field Name='Status'>Something Else</Field>

which means i'm left with this code:


Display single item from List using XSLT and show total count of all items in list


I have a simple SharePoint 2010 list named "Tips". Each item consists of a Title and Description. I want to display a single item at a time in a sidebar on my site with arrows to advance to the next or previous item in the list. I've been able to accomplish this pretty easily using OOTB SharePoint XSLT list view web part settings and AJAX. However, when I tell the web part to only display 1 item at a time the pager always says it's showing item "1 of 1" or "2 of 2". It won't show the total number of items from the list. I'd like it to show something like item "1 of 25", etc. How do I get it to display the total count of items from the list?  I've looked at possibly using aggregation attributes on a FieldRef but I've not been able to get anything to work. I'm not even sure that's the right place to be looking. I'm needing to accomplish this without writing a custom web part. 


Export SharePoint List to Excel Spreadsheet Programmatically using C#

In SharePoint applications, Custom Lists are used to store business data and Document Libraries to store the documents. But for data manupulation and analysis, Microsoft Excel provides very rich features as compared to SharePoint Lists. That's why people still loves to work on Microsoft Excel Sheets.
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

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