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

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

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

Posted By:      Posted Date: September 01, 2010    Points: 0   Category :SharePoint
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.

View Complete Post

More Related Resource Links

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?


Inserting List Item values from a Visual web part

Hi Geeks, I am struck here with one situation that is: 1) I created a enquiry list. 2) Then I created a visual web part it contains the same fields as enquiry list  as textboxes for entry. If any body enters the data and click submit. Those data must be reflected into the enquiry list. Please enlighten me how can I do this.   Thanking you.

Updating list item values in SharePoint Designer using code

Is it possible to programmatically modify the SharePoint objects using SharePoint Designer Object Model. By that I mean coding in SharePoint Designer (not Visual Studio). For example, can we access the list items of a list programmatically and change their values? I can do all this in Visual Studio using SharePoint Object Model but I don’t find a way of achieving this by using programming in SharePoint Designer. I searched through http://msdn.microsoft.com/en-us/library/bb208639(office.12).aspx but no success. If the answer is yes. Can someone please give example(s) or point to some articles etc? Thanks in advance.

New item insertion validation through event handler

My requirement is.... I have a list in SharePoint 2007. When I will add a new item into that list it will check the with the previous list item in the list (only title column). If the  same is available it should not allow to insert in the list and cutom error should through. If the same title name is not in the list it should insert in the list. As far my knowledge it will be done by event receiver. But I am unable to do it. Plaese help me....... Thanks in advance Rajesh.

event handler - item adding and updating..example



I am a beginner to event handlers..I need to create something like..items created in List A should appear in List B, and when it is updated, it should appear in List B as well..are there like free samples that I can work on..I am not really good at programming

event handler - how to add item from listA in SiteA to listB in SiteB


hi..is there a way to add items from one list to another..


Is it possible to update a list item in the ItemUpdating event receiver?


i need to add a property (SPListItem.Properties) to the SPListItem being updated in my ItemUpdating event receiver. is there any way to do that?

SPListItem.Update() doesnt seem to be an option, so the obvious answer is probably trying to use the SPItemEventProperties object called properties by calling properties.AfterProperties.ChangedProperties.Add(key, value) and letting sharepoint do the rest, but it turns out it actually deals with fields and not properties. it's a little misleading. so is there another way? some kind of painful work around maybe?

Event Receiver für WorkflowCompleted event - How to get list item?



I'm using an event receiver, which reacts on the WorkflowCompleted event (which is new in SharePoint 2010). In general the event is fired, when an associated workflow has been completed. The question is: how to get the list item the workflow is running against? The WorkflowCompleted event handler has a parameter of type SPWorkflowEventProperties, but via those properties I can't access the specific list item.

Any Idea how to achieve this?




Binding an event handler to a list



I am trying to bind an event handler to a list using the following code. I have the same code before with success, but I am not sure why it is not binding it anymore. Also I am getting no error, but the event is not firing when I bind the event handler using the following code:


static void Main(string[] args)
      int check = 1;
        SPSite collection = new SPSite("https://fullsitepathhere");
        Console.WriteLine("Working - 1");
        check = 3;
        SPWeb site = collection.OpenWeb();
        Console.WriteLine("Working - 2");
        check = 4;
        SPList temp = site.Lists["Data Storage"];
        Console.WriteLine("Working - 3");
        check = 2;

        string assname = "NewSaas, Version=, Culture=neutr

Cannot get values of a SPFieldMultiChoice value selected in an Event Handler


I have a document Library in SharePoint that I am trying to setup a After Update event handler. The event handler should do the following:

  • When a user assigns a technician to do an update, then an email is sent to the tech. The tech is selected by a Multiple Choice field.
  • When a user changes the status to Closed, an email is sent. The status is a drop-down field.

What I would like to be able to do is to check if the status = "open", "working" or "on hold", and if it is one of these statuses, I need to check to see who is assigned and send that tech an email.

I'd also like to check to see if the status = "closed" and then send only the user an email.

They work separately, but when I try to add the logic together, I get an error in my Application log as follows:

Windows SharePoint Services 3, General, Event ID 6875.  The parameter 'to' cannot be an empty string. Parameter name: to

Here's my code:

Prevent duplicate values to be entered into list


Hi, my scenario is that I got a list of Candidate details, This list i edited in Infopath 2010 and created a user interface, I am filling the candidate details list through this interface,

my problem is that I dont want to enter duplicate values to be entered into the list, i want to show a message in the form that when ever duplicate values are entered I watn to show a message

normally it is easy to prevent this by using workflow, but i dont understand how can i do this with the form,

is there any way that once i run the workflow i can pass the value to the form and check there and show a message


List<> Shows Different Values entered in the textbox


Good Day All

i have 20 Textboxes i am not sure what did i touch by i normally dont play with VS Settings i dont understand. So those textbox are normally defined like this

<asp:TextBox ID="txtUnitLen20" onKeyUp="Jump()"   runat="server" 
TabIndex="19" AutoPostBack="True"></asp:TextBox>

and i am adding the value of a Textbox to a List<string>


but if the value that is entered is "1" , there i will get this as a Value hex like this

[0x00000001] = "1"

Please note that the Textbox gives me "1" but the List gives me those Numbers. I have attached a screenshot below


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


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,



Creating Event Handler in Code behind


Hi, so I have a control that is created in the code behind and generates fine but I can't figure out how to create an event handler for it.  I've found plenty of examples for it in C sharp, but none of them seem to apply to VB.  What I want to do is essentially this:

myDropDownList.SelectedIndexChanged = "Event to do here"

but it doesn't seem to work for me.

Any suggestions are appreciated.

problem...i want a list item to populate all data in gridview!!!


i have a dropdownbox and a gridview

what I want is to have a list item which populates all data in a gridview.

I have tried using list item selected value=0 but to no avail.

what is the easiest way to achieve this?

want to launch modal Popup from created User Event handler




I have a create user wizard on my page and in the event handler (Created User) I get extra information from the user

via textboxes within the aspx etc.


I then do a response.redirect to another page.

What I want to happen is this


When the CreatedUser Event is fired, I  want a Modal Popup to show up with a message Processing your registration.

once the registration code is processed it will close and the users get redirected.


On my ASPX I have the Modal PopUp and a Panel.

In the code behind in the handler I put ModalPop.show()


but this does not work.


thanks for any suggestions



Attach Workflow to Task List, don't get option to manually start workflow via dropdown on task item



I am running WSS 3.0 with other workflows which are functioning correctly.  I created a new workflow in Visual Studio 2008 and was able to successfully run it in my dev environment.  I attached the workflow to a task list in my dev environment and was able to manually start the workflow by using the drop down workflow option and using the menus to manually start it.  I installed this workflow in our production environment and attached it to the task list (which had a SPD workflow attached to it which stopped working about a month ago).  I made sure that the option to manually start the workflow was checked.  When I tried to manually start the workflow, (hover mouse over title, drop down) there isn’t a workflow option.  The workflow also will not start automatically when a task is changed.


I attached this same workflow to a different task list in production and get the option to start it.


I have tried creating a small workflow in SPD 2007 and attaching it to the task list.  It shows that it is attached, when I look at the workflows that are attached to the task list, but I still don’t get the option to manually start it.


I have checked my security and I have fu

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