How to select distinct from SPQuery CAML

A handy way to select distinct records from SPListItemCollection set queried from CAML query. This is very useful when we want to select a number of unique records from a data table.

DataTable dtt = myWeb.Lists["LISTNAME"].GetItems(spQuery).GetDataTable();
DataView dtv = new DataView(dtt);
dtt = dtv.ToTable(true, "COLUMNNAME");

Integrating Ajax into Sharepoint 2007

Recently, I had the chance to play around with ajaxifying Sharepoint server. As you would have probably known, Ajax is a great feature in .NET 3.5 but MOSS 2007 was shipped before Ajax was out. So, to use it, we just need some configurations done. There are a lot of articles on the Internet about how to archieve this, but the very best and well explained one can be found at Mike Ammerlaan’s blog: Integrating ASP.NET AJAX with SharePoint.

Read More

List Attachments Open as Read Only

I had the problem of saving files which I uploaded programatically to Sharepoint list item. When I tried to save them, there’s pop up dialog saying the file is in read only mode, even I had all the required permissions. There’s not much info on the net about this, and luckily I found the solution.

Read More

How to duplicate a Sharepoint list item

I was trying to add a duplicate link to the list item menu dropdown context box, so that user can click and duplicate an item. It’s actually quite easy to do that.

First, what we need to do is add the C# code so that when the item is saved, we check if there is a request query string of relevant item ID. If there is, that means this is going to be duplicated. So the logic works as follow:

Read More

How to create your own custom menu/item/actions in Sharepoint?

Often times we have to customise SharePoint’s stock user interface, particularly elements such as edit block, toolbar, menus, etc. It’s possible to have our own custom items in these areas, but first it would be a lot easier to understand their names and locations respectively. These are some of the common locations we will customize:

Read More


I had the problem of page not able to redirect when in an ajax postback. It happens to be the fact that I disabled a line in web.config:

<add name=”ScriptModule” type=”System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35″ />.

This line should be added in HttpModules, so that redirection will work in Ajax postback. This class manages HttpModules for Ajax functionalities in ASP.NET.

How Sharepoint stores User Data

Lately I had fun digging into Sharepoint database and see how the monster was built and what its database schema looking like. Well, it’s pretty smart the way it was built but it’s also a pain for developers to understand and even to play with it, if they have to. With the business that I am working for, we have to create reports for corporates, which forces us to having to dig into Sharepoint database directly, even though I read a lot of posts saying that is not recommended by Microsoft.

Read More