Question

I added a checkbox to my list, just like there is a checkbox in a People and Groups list:alt text http://img8.imageshack.us/img8/605/ss20090528093906.png

However in my list I want to save the selected value to database. But I have no idea how. I was figuring i could add javascript to onClick event, but neither I know where do I put that javascript (or can I use C# code?), neither I have an idea how update a database from javascript.

Maybe you could help me, please? What are the other options? And how would I implement one?

Thank you!

In case if someone else wants to add checkbox, then this article did help me (but it is not detailed one)

Was it helpful?

Solution

Use jQuery and the SharePoint web services - attach a click handler to the checkboxes and include code that finds the item id from the same row - easy enough to locate in firebug.

There's some sample code for the web service part on my blog:

http://tqcblog.com/2009/05/04/sharepoint-discussion-with-jquery

OTHER TIPS

YOu could use jQuery, add a click event to all checkboxes with jQuery, and have the click event perform an AJAX call to webservice you write and deploy to Sharepoint. You can use the Content Editor Webpart to inject Javascript in the page. Deploy the webservice as a feature.

you could implement an ItemEventReceiver that does the database stuff for you and attach it to your list. The ItemEventReceiver should listen onto the ItemAdded, ItemUpdated and ItemDeleted event so you can react on these different situations and write the information into your database.

For more information about event receivers you should have a look at Brian Wilson's blog posts about that topic or at MSDN.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top