SharePoint 2010: Event Receiver ItemAdding and ItemUpdating How To Set AfterProperties DateTime Field Value

If you are receiving this error “Invalid date/time value. A date/time field contains invalid data. Please check the value and try again.”. This is because the assigning value for the AfterProperties DateTime field in the ItemAdding or ItemUpdating event in the Event Receiver was not formatted correctly.

To resolve this issue you need to format the DateTime value to an ISO8601 string format:

properties.AfterProperties["StartDate"] = DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ssZ");

or by using the SPUtility.CreateISO8601DateTimeFromSystemDateTime method:

properties.AfterProperties["StartDate"] = Microsoft.SharePoint.Utilities.SPUtility.CreateISO8601DateTimeFromSystemDateTime(DateTime.Now);

 

Ubuntu 13.04: How To Fix Realtek r8168 Network Driver

Just a couple of days ago Ubuntu 13.04 was released, so I decided to upgrade from 12.10 and realised that my network card is not working with the new 3.8.0-19 kernel. So I tried re-installing the Realtek driver which I had downloaded from their web site and it failed to install! So I did some searching over the Internet and found that someone had written a patch file to fix the driver.

First you will need to download the current r8168-8.035.00 driver from Realtek and extract it to your local folder:

$tar -xjf r8168-8.035.00.tar.bz2

Now download the r8168-8.035.00.patch file and save it the r8168-8.035.00 folder.

From the terminal change to the directory where you have extracted the folder:

$ cd r8168-8.035.00

In the driver’s folder enter the following command run the patch file:

r8168-8.035.00$ patch -p1 < r8168-8.035.00.patch

After the patch is complete, run the shell script to install the patched driver:

r8168-8.035.00$ sudo ./autorun.sh

That’s it you’re all done!

Ubuntu 13.04: Social Media Lens

I have been playing with the new release of Ubuntu 13.04 aka Raring Ringtail, one of the new feature I have been testing out is the Social Media Lens or Gwibber Lens. Now Gwibber no longer exists on the menu with the envelope icon on the top right of the desktop, I hardly use it because it was slow on my computer and if I wanted to post something I will go directly to the web site like Facebook or Twitter.

ubuntu_13-04_social_media_lens

To access the Social Media Lens holding down the Super + G key, the Super is also known as the Windows key on the keyboard. Now you will see the the lens appear before your eyes!

The other way to to access it is by pressing on the Dash icon on the launcher which is located on the top left with the Ubuntu logo.

dash_icon

Then below you can see the lens bar with several icons, home, application, documents, social media, music, photo and video. Select the social media icon you will see all you Facebook friends, Twitter tweets and so on.

lens_filter_bar

 

Ubuntu Command Line Upgrade to New Release

Just recently there was a new release for Ubuntu and I have a few Ubuntu installed on virtual machines. I normally telnet to the machines to perform updates, and upgrades. To upgrade via the command line open your terminal and enter the following command:

$sudo do-release-upgrade -d

The switch -d checks if upgrading to the latest release version is possible.

SharePoint 2010: Add, Update and Delete List Items Using The Server Side Object Model

In this blog post I will explain and demonstrate how to Add, Update and Delete a SharePoint List Item using the server side object model.

Adding a New Item
In the code sample below I obtain the current context and the web and get the list I would like to add the new item to. After I have assigned values to my fields I call an update method from the item.

SPWeb spWeb = SPContext.Current.Web;
SPList spList = spWeb.Lists["MyList"];
SPListItem item = spList.Items.Add();
item["Title"] = "Hello, world!";
item.Update();

 
Update an Existing Item

Updating an existing item from a SharePoint List is very similar to adding a new item, but the only difference is instead of calling Add() from the SPListItemCollection, I now call the GetItemById(int) from the SPList object. There are other ways of getting an item from a list and another one is GetItemByTitle.

SPWeb spWeb = SPContext.Current.Web;
SPList spList = spWeb.Lists["MyList"];
SPListItem item = spList.GetItemById(1);
item["Title"] = "Hello, world!";
item.Update();

 
Deleting an Existing Item
Deleting an existing item from a SharePoint List all I need to do is get the item I want from this list and then call the Delete method from the item object. That’s how easy it is.

SPWeb spWeb = SPContext.Current.Web;
SPList spList = spWeb.Lists["MyList"];
SPListItem item = spList.GetItemById(1);
item.Delete();

I hope the information I have provided in this post is useful to you.

Shares