SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to display my search results in a table-like fashion. Does anyone know any good technique that I can use to display my custom columns in a table fashion?

I used a html table, but it keeps repeating even though I used this:

<xsl:if test="(position())=1">

<td>content goes here</td>

It is still adding spaces between each row and it looks like separate tables. I would like it to look like a gridview, or like the one in a list or library.

Thank you for your help.

share|improve this question


You can create a custom webpart and display results in a grid view or spgridview which will provide options of grouping,filtering,paging etc . PS:

    protected override void Render(HtmlTextWriter writer)
        string currUser = SPContext.Current.Web.CurrentUser.Name;
        string searchQuery = "select title, sitetitle,path from scope()";
        FullTextSqlQuery query = new FullTextSqlQuery(SPContext.Current.Site);

        query.ResultTypes = ResultType.RelevantResults;
        query.QueryText = searchQuery;
        ResultTableCollection result = query.Execute();

        ResultTable resultTable = result[ResultType.RelevantResults];
        DataTable dt = new DataTable();
        dt.Load(resultTable, LoadOption.OverwriteChanges);

        SPGridView spGrid = new SPGridView();
        spGrid.AutoGenerateColumns = false;

        foreach (DataColumn dColumn in dt.Columns)
            SPBoundField field = new SPBoundField();
            field.HeaderText = dColumn.ColumnName;
            field.DataField = dColumn.ColumnName;

        spGrid.DataSource = dt;

share|improve this answer

It is certainly possible, however it would require to understand a little bit how the results are returned and then change the XSLT appropiately. I would suggest strongly to go through collecting the actual XML and use SharePoint Designer 2010 to change the output any way you see fit.

Basically you would need to collect the XML and add it a Data Source in SharePoint designer. Use this XSLT in your Core Search REsults web part to collect the actual output, before the XSLT transformation of the rendering.

<xsl:stylesheet version="1.0" 
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> 
<xsl:template match="/"> 
  <xmp><xsl:copy-of select="*"/></xmp> 

Tobias Zimmerman has a series of articles, which is still viable for SharePoint 2010. Find it here

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.