SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

SPWeb web = SPContext.Current.Web;

            SPList oList = web.Lists["MyList"];
            SPListItem oListItem = oList.Items[1];

            oListItem["Name"] = TextBox_Name.Text;

//my list wont get updated why?

share|improve this question
what's the problem you are facing? any error? or just it does not get updated, can you please debug your code and provide debug information/error log – Diptarag Nov 30 '12 at 10:12
Maybe he don't change the name of list or nameof field. I think that is main problem here. – Grzegorz Z Nov 30 '12 at 11:29
The code you provided should work fine unless u have incorrect list name or internal name of the field in your code. – Ishan Nov 30 '12 at 12:15

I presume this is in a webpart if so try the following to see if it works :)

        SPWeb web = SPContext.Current.Web;

        web.AllowUnsafeUpdates = true;

        SPList list = Web.Lists["MyList"];

        SPListItem oListItem = List.Items[1];

        oListItem["Name"] = TextBox_Name.Text;

        web.AllowUnsafeUpdates = false;

more info on AllowUnsafeUpdates:

full example

also like others have noted that you need to check your list name is called "MyList" and its "Name" that you want to update ;)

hope it helps :)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.