Showing posts with label SPList Item inserting. Show all posts
Showing posts with label SPList Item inserting. Show all posts

Monday, January 17, 2011

SPListItem updating programmatically

After multiple attempts of opening the site using SPSite class,I could not make it happen.But searching of these topics i learned many tips and idea to resolve my task.
My requirement was having on webpart there I must create the Form to be filled by end user.These will be inserted into SharePoint List.
In Visual webpart I used the below code
 SPSite site = SPContext.Current.Site;
               SPWeb web = site.OpenWeb();
                SPList myList = web.Lists["List OF Employee"];
                SPListItem Item = myList.Items.Add();
                Item["Title"] = TextBox1.Text;
                Item["Name"] = TextBox2.Text;
                Item.Update();