0

我正在尝试使用 Visual Studio 2008 和 SharePoint API 将新任务添加到现有的 SharePoint 任务列表中,我的代码是:

using System;
using System.Collections;
using System.Configuration;
using System.Runtime.InteropServices;
using System.Xml.Serialization;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Utilities;
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint.WebPartPages;

  void button1_Click(object sender, EventArgs e)
        {
            SPWeb curr = SPContext.Current.Web;
            SPListCollection lsts = curr.Lists;
            SPList myList = lsts["testfin"];
            SPListItem item = myList.Items.Add();
            item["Title"] = mytext.Text;
            item["Description"] = mytext.Text;
            item["Status"] = "Not Started";
            item.Update();
            mytext.Text = "";
        }

当我单击按钮时,页面被刷新,没有发生任何事情,当我检查任务列表时,它是相同的,没有添加新任务。

有人可以帮忙吗?

4

2 回答 2

0

you miss myList.Update()

于 2010-10-21T12:39:02.923 回答
0

我假设您在页面中的代码有更多内容,因为我没有看到按钮以及它如何连接到该事件处理程序,但我假设您已经弄清楚了。

调试是个好主意。它不仅可以帮助您确定问题所在,还可以帮助您了解正在使用的各种对象。要调试 Sharepoint,需要附加到 w3wp.exe 进程, http: //msdn.microsoft.com/en-us/library/dd206929.aspx

Andrew Connell 不久前写了一篇关于如何设置 VisStudio 以使用宏附加到 IIS 的文章。谷歌上去找出如何让你的调试生活更轻松......然后你可以在 VisStudio 中创建一个按钮来运行宏并附加到适当的进程,然后你就可以开始运行了。

于 2009-11-25T21:03:03.390 回答