Lately we found a very interesting fact of Sharepoint, which I think is worth writing a post about. Although it is very rare that someone will read directly into Sharepoint database to retrieve information, but for some hardcore users, especially with my last post regarding how Sharepoint stores data in backend database, one can easily read into Sharepoint Prod_Content database and do CRUD transactions.
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");
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.
When you group list items by some fields, by default Sharepoint have the items collapsed. It’s quite annoying to have to manually expand each. There’s a way you could easily expand all list items or collapse in one click.
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.
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:
I have been playing around with LINQ in Sharepoint object model and I have to say I’m quite impressed. It does shorten the amount of code we write and works just as great or better.
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:
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=126.96.36.199, 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.
I came across this problem of wanting to add a column in the List view web part (stock standard one) with the ability to have html elements rendered properly. Unfortunately Sharepoint’s standard list view only displays text in it. However, with some guidance from Aaron and great post from PathToSharepoint, I was able to do that easily.