views:

46

answers:

2

Hello everybody

With a sharepoint list, is it possible to calculate a column value basing on other columns of the list value using a C# Method ?

My list contains start and end dates and i want to show business days of these dates intervals by using an home made c# method. I would prefer to do that in real time when showing the list, but if it is not possible, is it possible to call my c# method while creating a new row ?

Thank's by advance ^^

+2  A: 

Hi Eka808

You can put your code into an Event Receiver which fires on the item being added/updated.

Here is one example: Developing an Event Receiver for a Document Library

Per Jakobsen
Ok, with your link and this one (http://msdn.microsoft.com/en-us/library/ms437502.aspx), i've created an event receiver who work but with all the custom lists ! Is it possible to match only the list i want ?
eka808
Per Jakobsen
A: 

If you want the value to be updated every time the list is displayed, you should create your own custom field. This way you can calculate the intervals at the time of rendering and display the value you want. As the field can't be edited, you only need to provide your own variants of the GetFieldValue methods. You won't need to create a special rendering control or provide an XSLT stylesheet.

You will have to provide properties for the other fields names, so your field can be configured when it's added to a list.

Panagiotis Kanavos