I am trying to add a new task to an existing SharePoint Tasks List using Visual Studio 2008 and SharePoint API, my code is:
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 = "";
}
when I click the button, the page is refreshed with nothing happening, when I check the Tasks list, it is the same, no new task added.
can anybody help?