开发者

SPSiteDataquery returning null datatable

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜