开发者

SPSiteDataquery returning null datatable

开发者 https://www.devze.com 2022-12-17 11:47 出处:网络
I need to query all the subsites of a site I m in. I have list called Country which is 2-3 sub level of site my webpart is rendering. My cod开发者_如何学编程e till now is this..

I need to query all the subsites of a site I m in. I have list called Country which is 2-3 sub level of site my webpart is rendering. My cod开发者_如何学编程e till now is this.. Country is custom list,DT1 is coming out to be null. I don't know where I m getting wrong , any idea on this?

           SPWeb web = SPContext.Current.Web;

           SPSiteDataQuery qry = new SPSiteDataQuery();
            qry.Lists = "<Lists BaseType='1' />";

            qry.Query = "<Where><Contains><FieldRef Name='Title'/><Value Type='Text'>USA</Value></Contains></Where>";

            qry.ViewFields = "<FieldRef Name='Currency'/>";

             qry.Webs = "<Webs Scope='SiteCollection' />";

           DataTable DT1= web.GetSiteData(qry);


Verify tyat all lists with BaseType='1' has field with internal name Currency or else you will get null as a result.

0

精彩评论

暂无评论...
验证码 换一张
取 消