如何使用sharepoint自定义列表填充下拉列表中的值 [英] how to populate values in dropdownlist with a sharepoint custom list
本文介绍了如何使用sharepoint自定义列表填充下拉列表中的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用sharepoint自定义列表填充dropdownlist中的值
解决方案
SPWeb web = SPContext.Current.Web;
SPList list = web.GetListFromUrl(ListUrl);
SPQuery query = new SPQuery();
//我想field1 包含数据的列 SPList
//需要 在下拉列表中显示
query.ViewFields = < FieldRef Name ='Field1'/>
;
SPListItemCollection spItemColl = list .GetItems(查询);
foreach(spItemColl中的SPListItem oItem)
{
ddlOutput.Items.Add(Convert.ToString(oItem [ Field1]));
}
how to populate values in dropdownlist with a sharepoint custom list
解决方案
SPWeb web = SPContext.Current.Web;
SPList list = web.GetListFromUrl("ListUrl");
SPQuery query = new SPQuery();
//I suppose field1 is the column which contains data in SPList //needs to be displayed in dropdownlist query.ViewFields = "<FieldRef Name='Field1' />"
;
SPListItemCollection spItemColl = list.GetItems(query);
foreach (SPListItem oItem in spItemColl)
{
ddlOutput.Items.Add(Convert.ToString(oItem["Field1"]));
}
这篇关于如何使用sharepoint自定义列表填充下拉列表中的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文