views:

681

answers:

2

Hi guys,

I'm making a checklist for people to do tasks on our company website. The feature I'm working on right now is that once they complete a task and mark it as done, I want our sharepoint webpart to send an email to them containing a list of what they still need to finish.

Since the powers that be want to be able to add and subtract items to the list at will, it needs to be modular, therefore checking the list needs to be modular and written in modular terms as well.

The problem that I have is that all the tasks are stored in a SPList on the existing code. I'm not exactly sure how to iterate over the list to find out whether that person has the done the following task already. I'm not seeing any next, previous, head or tail operations (as I would expect from a list). Since indexing uses a string, it behaves more like an associative data structure (map) or primary key from a DB.

Help please and thanks everyone!

Cheers,

-Jeremiah Tantongco

+3  A: 

Hi Jeremiah

A SharePoint list is not a list in the Computer Science way, but is what an End-User would expect a list to be: a listing of things

You should more look at a list as being similar to a database table. If you want to find records (Items) in a table (List) based on conditions then you should use a query.

So the right way to find SPListItems in a SPList is to use an SPQuery where you specify your criteria in a nice XML syntax (CAML), then pass the SPQuery to SPList.GetItems and thereby get a collection of SPListItems back.

This should give you some terms to google for. If you need more help with the syntax of the query then use U2U Caml Query Builder or give us some more specific infomations.

Per Jakobsen
Adding to this, you can also query a SPList using LINQ: http://linqtosharepoint.codeplex.com/
Magnus Johansson
A: 

This may solve your problem

SPList interviewList = myWeb.Lists["listtoiterate"]; foreach (SPListItem interview in interviewList) { // Do Something }

Tejas Desai