/// <summary>
/// 为DropDownList帮定数据
/// </summary>
/// <param name="select"> 需要绑定的控件 </param>
/// <param name="listPathLast"> 列表地址,如:Lists/Type/AllItems.aspx </param>
/// <param name="webUrl"> web网站地址,如http://demo1/,为动态获取 </param>
public void SelectBindData(DropDownList select, string listPathLast, string webUrl)
{
SPSecurity.RunWithElevatedPrivileges(delegate
{
using (var site = new SPSite(webUrl))
{
using (SPWeb web = site.OpenWeb())
{
SPList projectTypeList = web.GetList(webUrl + listPathLast);
foreach (SPListItem s in projectTypeList.Items)
{
var ltCu = new ListItem {Value = s.Name, Text = s.Name};
select.Items.Add(ltCu);
}
}
}
});
}
SelectBindData(Type, "Lists/ProjectType/AllItems.aspx" , Weburl);