Sharepoint has a feature that allows us to migrate list data structure and content to a different site so that we do not have to re-create them. This is done through list settings -> save list as template. List template is a powerful function which can save the data structure of a list as well as its content.
I spent quite some time today fixing this problem of accessing a list item in parent web. What I had to do was to access a list item in a parent web, but strangely it kept returning no result, and I made sure the item did exist in the list.
Then I found out it’s due to permission issue. When accessing a parent web’s list items, you have to run your code under elevated privileges mode, otherwise if you debug it you will see that it crashes when trying to access them.
This is an extremely useful function, which allows you to read an Excel spreadsheet and convert its data into a DataTable in C#. With data in a DataTable, we can perform lots of things to it.
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.