title: Get the URL of a List in sharepoint using Caml Query
body: <p>I am using SPSiteDataQuery to display documents from different lists. I display the documents using a Gridview. One of the columns of the Gridview is an hyperlinkfield. How can I set the url of each document since each of them comes from different different document libraries? For your information, I am using Caml Query to filter the documents.</p>
  
  <p>Please help me.</p>
  
  <p>here is the code:</p>
  
  <pre><code>using System;
  using System.Web.UI;
  using System.Web.UI.WebControls;
  using System.Web.UI.WebControls.WebParts;
  using Microsoft.SharePoint;
  using System.Data;
  using Microsoft.SharePoint.Utilities;
  
  namespace Uniway.FOD.Intranet.ControlTemplates
  {
      public partial class Documents : UserControl
      {
          protected void Page_Load(object sender, EventArgs e)
          {
              GridView1.DataSource = GetAllDocuments();
              // Set up the field bindings.
              BoundField boundField = new BoundField();
              boundField.HeaderText = "File name";
              boundField.DataField = "Title";//"LinkFilename";
              GridView1.Columns.Add(boundField);
  
              HyperLinkField hyperlinkField = new HyperLinkField();
              hyperlinkField.HeaderText = "Link name";
              hyperlinkField.DataTextField = "LinkFileName";
              hyperlinkField.DataNavigateUrlFields = new[] { "LinkFileName" };
              hyperlinkField.DataNavigateUrlFormatString = "{0}";
              GridView1.Columns.Add(hyperlinkField);
  
              BoundField boundField2 = new BoundField();
              boundField2.HeaderText = "Link File Name";
              boundField2.DataField = "LinkFilename";
              GridView1.Columns.Add(boundField2);
  
              GridView1.DataBind();
          }
  
          public DataTable GetAllDocuments()
          {
              SPSiteDataQuery objSPSiteDataQuery = null;
              SPWeb objSPWeb = null;
              DataTable objDataTable = null;
  
              objSPWeb = SPContext.Current.Web;
              objSPSiteDataQuery = new SPSiteDataQuery();
  
              //Specify the fields to be fetched in the results.Similar to select clause of an SQL query
  
              objSPSiteDataQuery.ViewFields = "&lt;FieldRef Name=\"LinkFilename\"/&gt;" +
                                              "&lt;FieldRef Name=\"Title\" /&gt;" +
                                              "&lt;FieldRef Name=\"Created\" /&gt;" +
                                              "&lt;FieldRef Name=\"Modified\"/&gt;" +
                                              "&lt;FieldRef Name=\"Editor\"/&gt;";
  
              //specifying list server template=101 so that it will query only document libraries
  
              objSPSiteDataQuery.Lists = "&lt;Lists ServerTemplate=\"101\" BaseType=\"1\" Hidden=\"FALSE\" MaxListsLimit=\"0\"/&gt;";
  
              objSPSiteDataQuery.RowLimit = 1000;
              objSPSiteDataQuery.Webs = "&lt;Webs Scope=\"Recursive\"/&gt;";
  
              //querying all documents of the content type 'CT23December1' having version=1.0
  
              objSPSiteDataQuery.Query = @"&lt;Where&gt; 
                                            &lt;Eq&gt; 
                                              &lt;FieldRef Name='File_x0020_Type' /&gt; 
                                              &lt;Value Type='Text'&gt;doc&lt;/Value&gt; 
                                            &lt;/Eq&gt;
                                          &lt;/Where&gt;&lt;OrderBy&gt;&lt;FieldRef Name='Modified' Ascending='False' /&gt;&lt;/OrderBy&gt;";
  
              objDataTable = objSPWeb.GetSiteData(objSPSiteDataQuery);
              return objDataTable;
          }
      }
  }
  </code></pre>