从.NET控件获取值到SharePoint列表

问题描述 投票:0回答:1

我是否知道如何从.NET前端控制字段中检索要存储在SharePoint列表中的值?

Field1TextBox type

Field2DropDownList type

Field3checkbox type

以下是我对textbox type字段的尝试:

item["Field1"] = (Field1.ToString());

我可以知道我可以检索DDLCB值吗?

.net sharepoint controls
1个回答
0
投票

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();
            }
© www.soinside.com 2019 - 2024. All rights reserved.