向sharepoint 2010 中的列添加数据 muddy

 1   string url = SPContext.Current.Web.Url;
2 Uri siteUrl = new Uri(url);
3 using (SPWeb spWeb = new SPSite("http://" + siteUrl.Host).OpenWeb())
4 {
5 spWeb.AllowUnsafeUpdates = true;
6 //获取CreateNewPro列表信息
7 SPListItemCollection SPCollCreateNewPro = spWeb.Lists["CreateNewPro"].Items;
8 SPListItem spListItem = SPCollCreateNewPro.Add();
9 spListItem["CreatePMO"] = PmoText.Text;
10 spListItem["ProName"] = ProText.Text;
11 spListItem["InputUnit"] = InputUnitText.Text;
12 spListItem["Department"] = DepartmentText.Text;
13 foreach (Control radio in this.Panel1.Controls)
14 {
15 if (radio.GetType().Name == "RadioButton")
16 {
17 if (((RadioButton)radio).Checked)
18 {
19 spListItem["ProType"] = ((RadioButton)radio).Text;
20 }
21 }
22
23 }
24 spListItem["CreateTime"] = CreateTime.Text;
25 spListItem.Update();
26 int a = spListItem.ID; //获取新插入的Item的编号
原文地址:https://www.cnblogs.com/muddy/p/2366209.html