Click here to Skip to main content
16,016,678 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
Hi!, i have created a solution in SharePoint from visual studio C#. I want to create a Job Timer so i have created a c# class too. but now I'm adding a new row to task list
but what i want really to do is to update a specific row not to add new one. the code belongs as follow:
C#
 public override void Execute(Guid targetInstanceId)
{
    SPWebApplication webApp = this.Parent as SPWebApplication;
        SPList taskList = webApp.Sites[0].RootWeb.Lists["Tasks"];
        SPListItem newTask = taskList.Items.Add();
        newTask["Title"] = "New Task" + DateTime.Now.ToString();
        newTask.Update();
}

I repeat again instead of add new row i want to update. Could anyone help me please.
Posted

1 solution

To update a listItem you'll first need to fetch it. There are many ways to fetch it but it depends on the information or criteria you have to fetch.
You can use list.getItem() or you can even write a query to fetch items.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900