I am trying to bind a lookup column named team to an asp.net dropdown and the dropdown renders blank
HTML
<asp:DropDownList ID="team" runat="server" AutoPostBack="true"></asp:DropDownList>
CSOM
private void FetchTeam()
{
if (!Page.IsPostBack)
{
using (ClientContext ctx = new ClientContext("https://site.sharepoint.com/sites/test"))
{
string login = "*****";
string password = "******";
SecureString securepassword = new SecureString();
foreach (char c in password)
{ securepassword.AppendChar(c); }
ctx.Credentials = new SharePointOnlineCredentials(login, securepassword);
Web site = ctx.Web;
List list = site.Lists.GetByTitle("Employee");
CamlQuery query = CamlQuery.CreateAllItemsQuery();
Microsoft.SharePoint.Client.ListItemCollection collection = list.GetItems(query);
ctx.Load(collection);
ctx.ExecuteQuery();
foreach (Microsoft.SharePoint.Client.ListItem item in collection)
{
string text = string.Format("{0}", item.FieldValues["Team"]);
eid.Items.Add(new System.Web.UI.WebControls.ListItem(text, item.Id.ToString()));
}
}
}
}
All the articles here are for SharePoint Server SSOM.
Would appreciate if anyone could help me with this.