2011-11-17 67 views
1

我有一个调查列表在sharepoint中,我想添加一个答案使用C#代码调查,这我想可以解释为添加一个项目到列表中,所以我尝试了下一个但没有工作。将项目添加到Sharepoint调查列表

这怎么办?

using (SPSite site = new SPSite("http://user-pc")) 
{ 
    using (SPWeb web = site.RootWeb) 
    { 
     try 
     { 
      SPList olist = web.Lists["JobSchedulle"]; //<- Name of the survey in sharepoint 2010 
      SPListItem item = olist.Items.Add(); 
      item[5] = "good";// <- this survey only has one question, and is a text option .. 
      item.Update(); 

     } 
     catch { 
      Console.ReadLine();   
     }  
    } 
} 

回答

0

我发现错误 - 代码工作,但我访问item[5](使用错误的指数)。