Below is the example how we can use spsitedataquery in sharepoint
using (SPSite site = new SPSite(ServerText.Text))
{
using (SPWeb web = site.OpenWeb())
{
// Fetch using SPSiteDataQuery
SPSiteDataQuery query = new SPSiteDataQuery();
query.Lists = "<Lists ServerTemplate=\"105\" />";
query.ViewFields = "<FieldRef Name=\"Title\" />" + /* Title is LastName column */
"<FieldRef Name=\"FirstName\" Nullable=\"TRUE\" Type=\"Text\"/>";
query.Webs = "<Webs Scope=\"SiteCollection\" />";
DataTable dataTable = web.GetSiteData(query);
dataGridView3.DataSource = dataTable;
}
}
No comments:
Post a Comment