Quantcast
Channel: SharePoint 2010 - Development and Programming forum
Viewing all articles
Browse latest Browse all 11508

Binding the search results column "EncodedAbsThumbnailUrl" in grid view

$
0
0

Hi,

i created a custom webpart by extending coreresultswebpart.

i need to display the thumbnailof the image and the title column to display the dispform of the item on click of it.

i am unable to bind the column where it has the thumbnail.

this is my code.

namespace Danfoss.Sharepoint.CoreResultsWebpart.SearchWebPart
{
    public partial class SearchWebPartUserControl : UserControl
    {
        DataSet dtSet = null;

        DataTable dtTable = null;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
               
                //SetGridColumns();
                LoadSearchGrid();
            }
        }

        protected void LoadSearchGrid()
        {
        // gets the instance of the querymanager
 QueryManager queryManager = SharedQueryManager.GetInstance(this.Page).QueryManager;
 
//Thereafter, define a DataSet and DataTable object.
 

 
//To get the Xml returned by Search add the following codes:
 if (queryManager != null && queryManager.Count > 0)
 {
 XmlDocument xdoc = new XmlDocument(); //We are using XmlDocument
 xdoc = queryManager.GetResults(queryManager[0]);//xml returned by search 

// Get blended results
 if (xdoc != null)
 {
 XmlReader xmlReader = new XmlNodeReader(xdoc);
 dtSet = new DataSet();
 dtSet.ReadXml(xmlReader);
 
if (dtSet.Tables.Count > 1)
 {
     dtTable = dtSet.Tables["Result"];
         dtTable.Columns.Add("ImageUrl", typeof(string));
     DataRow dr;
     dr = dtTable.Rows.Add();

     //dr["ImageUrl"] = item["ows_EncodedAbsThumbnailUrl"].ToString();

 GridView1.DataSource = dtTable;
 GridView1.AutoGenerateColumns = false; 
     field.DataField = "Title";
     field.HtmlEncode = false;


     GridView1.Columns.Add(field);
       ImageField colImage = new ImageField();

     colImage.DataImageUrlField = "EncodedAbsThumbnailUrl";

     colImage.HeaderText = "Image";

     GridView1.Columns.Add(colImage);

   
 GridView1.DataBind();
 
} 

}
 
} 

    }
      
        
        


Aruna


Viewing all articles
Browse latest Browse all 11508

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>