Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I'm very new to sharepoint and well to development...And I could use a little help !

I have a document library wich contains a multiple choice field (drop down with 3 choices), I've added 3 columns containing buttons. When a user click on a button, the value of the choice field is to be updated.

I know it's very simple but what is the best way to proceed? Could you provide me code snippet?

Thanks in advance !

share|improve this question
1  
Can you more clarify your task? I don't understand what's the need to update SharePoint choice field with buttons. –  Alex Boev Mar 7 '12 at 9:23
    
Of course, basically the library contains mails and the multiple choice field indicates 3 states : not read, in progress and processed. The employee should be able by clicking on the button to indicate wich state he's at. –  Pandorum Mar 7 '12 at 9:42
    
Did you add your buttons in SharePoint designer to list view webpart? –  Alex Boev Mar 7 '12 at 10:13
    
yes, there are basic html buttons. –  Pandorum Mar 7 '12 at 10:18
    
So you want to update automatically the choice field int he item where the button is clicked? But i don't understand the idea to allow the user to mark the items as read in that way because only one value can be saved per item and the second user will see the value saved by the first user. Is it desirable behaviour? –  Alex Boev Mar 7 '12 at 10:47
show 1 more comment

2 Answers 2

up vote 2 down vote accepted

So if I understand the task right and if we don't touch Visual Studio the solution will require the following steps:

  1. create an event handler in javascript for the button and get the target item id in it
  2. update the item via client object model (How to: Create, Update, and Delete List Items Using JavaScript)
  3. refresh the current list view web part to reflect changes.

UPDATE: If you want to go the C# path and do the work on the server side there's one well known way. To do the same you need:

  1. still create an event handler to your button
  2. create a custom application page with no UI - it will receive the update parameters via query string - and implement the update logic there. You need to redirect to that page from your handler and send as params the target item id, the desired update values and the url to return
  3. after the update item in your custom page do redirect back to the list view page and it will contain updated data of course.
share|improve this answer
    
Ok guys, thank you for your answers. Javascript is ok but I'm curious though, how would I proceed in C#? –  Pandorum Mar 7 '12 at 13:24
    
@Pandorum See the update. –  Alex Boev Mar 7 '12 at 14:23
    
thanks a lot, I'll code both way, good way to learn :) –  Pandorum Mar 7 '12 at 16:32
add comment

Completely sidestepping your question, but you can set up Choice columns to show up as a group of radio buttons instead of a dropdown, that would take care of the edit form.

If you want to display those buttons in the list views and update the corresponding line's item, it could be done but it depends if you are using SP2007 or 2010?

However as Alex pointed out, those values will be per-user. If you really want user-specific values, you would need to maintain a second, separate list with read flags per item/per user, and keeping both lists in sync (deleting flags when mails get deleted) will add a good level of complexity unless again you are on SP2010 (which can enforce relationships with lookup fields)

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.