sharepoint 2010 依据指定用户UserID查询该用户列表数据
查询用户数据,例如返回某一个指定用户的数据,可以用如下方法。
SPSecurity.RunWithElevatedPrivileges(delegate()
{
SPWeb web = SPContext.Current.Web;
web.AllowUnsafeUpdates = true;
SPList list = web.Lists["工作组讨论"];
SPQuery query = new SPQuery();
query.Query = @"<Where>
<Eq>
<FieldRef Name=""Author"" LookupId=""TRUE"">
</FieldRef>
<Value Type=""User"">9</Value>
</Eq>
</Where>";
SPListItemCollection sic = list.GetItems(query);
GridView1.DataSource = sic.GetDataTable();
GridView1.DataBind();
});
其中“9”代表的是用户ID,例如SPContext.Current.Web.CurrentUser.ID
广州京微信息科技有限公司,微软sharepoint解决方案提供商。