sharepoint 2010 根据指定用户UserID查询该用户列表数据

来源:互联网 发布:淘宝娃娃海报图片素材 编辑:程序博客网 时间:2024/06/01 15:02

查询用户数据,例如返回某一个指定用户的数据,可以用如下方法。

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解决方案提供商。

原创粉丝点击