我是否知道如何从.NET前端控制字段中检索要存储在SharePoint列表中的值?
Field1
:TextBox type
Field2
:DropDownList type
Field3
:checkbox type
以下是我对textbox type
字段的尝试:
item["Field1"] = (Field1.ToString());
我可以知道我可以检索DDL
和CB
值吗?
CSOM将数据保存到SharePoint的示例演示。
<div>
<asp:TextBox ID="Field1" runat="server"></asp:TextBox>
<asp:DropDownList ID="Field2" runat="server">
<asp:ListItem Text="A" Value="A"></asp:ListItem>
<asp:ListItem Text="B" Value="B"></asp:ListItem>
<asp:ListItem Text="C" Value="C"></asp:ListItem>
</asp:DropDownList>
<asp:CheckBox ID="Field3" runat="server"></asp:CheckBox>
</div>
<asp:Button ID="Button1" OnClick="btn_Save" runat="server" Text="Button" />
using (ClientContext clientContext = new ClientContext("http://sp:12001/"))
{
clientContext.Credentials = new NetworkCredential("lee","pw","domain");
Web web = clientContext.Web;
List oList = clientContext.Web.Lists.GetByTitle("MyList3");
ListItemCreationInformation itemCreateInfo = new ListItemCreationInformation();
Microsoft.SharePoint.Client.ListItem oListItem = oList.AddItem(itemCreateInfo);
oListItem["Title"] = Field1.Text;
oListItem["Field2"] = Field2.SelectedItem.Value;
oListItem["Field3"] = Field3.Checked;
oListItem.Update();
clientContext.ExecuteQuery();
}