Get Data using SPSiteDataQuery

SPSiteDataQuery query = new SPSiteDataQuery();
            query.Lists = "<Lists><List ID=\"111111E1-11FF-1AC1-B1FC-EB1CFCB1AB2D\"/><List ID=\"A111111C-1110-11BE-111B-01111111B115\"/></Lists>";
            query.Query = "<Where><Gt><FieldRef Name='ID' /><Value Type='Number'>0</Value></Gt></Where>";
            query.Webs = "<Webs Scope='SiteCollection' />";
            query.ViewFields = "<FieldRef Name='Title' /><FieldRef Name='ID' />";
            query.RowLimit = 10;

            DataTable dt = web.GetSiteData(query);
            lblMessage.Text = dt.Rows.Count.ToString();
            gvData.DataSource = dt;
            gvData.DataBind();
Ebook Download
View all
Learn
View all