Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sharepoint 2007 如何[以编程方式]在SharePoint任务列表中添加新任务_Sharepoint 2007_Sharepoint Api - Fatal编程技术网

Sharepoint 2007 如何[以编程方式]在SharePoint任务列表中添加新任务

Sharepoint 2007 如何[以编程方式]在SharePoint任务列表中添加新任务,sharepoint-2007,sharepoint-api,Sharepoint 2007,Sharepoint Api,我正在尝试使用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; us

我正在尝试使用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 = "";
        }
当我点击按钮时,页面被刷新,没有任何事情发生,当我检查任务列表时,它是相同的,没有添加新任务


有人能帮忙吗?

我想您在页面中的代码有更多的内容,因为我没有看到按钮以及它是如何连接到事件处理程序的,但我想您已经解决了所有问题

调试是一个好主意。它不仅能帮助你确定问题所在,还能帮助你理解游戏中的各种物体。要调试Sharepoint,您需要附加到w3wp.exe进程


安德鲁·康奈尔(Andrew Connell)不久前写了一篇关于如何设置VisStudio以使用宏连接到IIS的文章。用谷歌搜索一下,看看如何让你的调试生活更轻松。。。然后,您可以在VisStudio中创建一个按钮,运行宏并连接到相应的进程,然后您就可以关闭并运行了。

您错过了myList.Update()

您尝试过调试它吗?我看不出代码有什么问题。代码应该可以正常工作。我假设您正在SharePoint的上下文中运行此页面,我的意思是该页面已部署到SharePoint?是的,我正在将其部署到SharePoint,如何调试它?你是说设定一个断点并观察数值吗?或者其他什么?myList.Update()不是必需的。我相信item.Update()足以更新列表项。