繁体   English   中英

如何根据Sharepoint列表在gridview上勾选复选框? ASP.NET,c#

[英]How to get checkbox ticked on gridview based on Sharepoint list? ASP.NET, c#

我试图根据Sharepoint数据勾选复选框。 例如,A =真,B =真,C =假。 我打算如何在A和B上勾选复选框? 我想在页面加载的gridview中显示复选框。 可以将复选框与对象列表绑定? 谢谢

// Starting with ClientContext, the constructor requires a URL to the 
// server running SharePoint. 
   ClientContext context = new ClientContext("http://SiteUrl"); 

// Assume the web has a list named "Announcements". 
  List announcementsList = context.Web.Lists.GetByTitle("Announcements"); 

// This creates a CamlQuery that has a RowLimit of 100, and also specifies Scope="RecursiveAll" 
// so that it grabs all list items, regardless of the folder they are in. 
  CamlQuery query = CamlQuery.CreateAllItemsQuery(100); 
  ListItemCollection items = announcementsList.GetItems(query); 

  // Retrieve all items in the ListItemCollection from List.GetItems(Query). 
  context.Load(items); 
  context.ExecuteQuery(); 
  foreach (ListItem listItem in items) 
  { 
    // We have all the list item data. For example, Title. 
    if (yourListItem["CheckBoxFieldName"].ToString() == "A")
        {
            checkBox1.Checked = true;
        }
   else if (yourListItem["CheckBoxFieldName"].ToString() == "B")
        {
            checkBox1.Checked = true;
        }
   else if (yourListItem["CheckBoxFieldName"].ToString() == "C")
        {
            checkBox1.Checked = false;
        } 
  } 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM