Create a web part which takes input from a tasklist
I'开发者_如何学运维m in need of creation of a web part which takes input from a task list and changes the color of the tasklist based on the data in the task list. Can anyone help me with this problem? I can write code in visual studio 2005. My question is how do I take input data from the list?
Sample code here. This should get you started. (source)
using Microsoft.SharePoint;
class SPTest {
public void ReadList() {
// Use using to make sure resources are released properly
using(SPSite oSite = new SPSite(pathToSite)) {
using(SPWeb oWeb = oSite.AllWebs[nameOfWeb]) {
// Alternately you can use oSite.RootWeb if you want to access the main site
SPList oList = oWeb.Lists[listName]; // The display name, ie. "Calendar"
foreach(SPListItem oItem in oList.Items) {
// Access each item in the list...
DateTime startTime = (DateTime)oItem["Start Time"];
// etc....
}
}
}
}
}
精彩评论