I'm using SharePoint 2013 foundation.I have created a CAML query to get fields. I capture the results coming from the CAML query in a SPListItemCollection and then bind to a SPGridView.

<FieldRef Name='DocIcon'/>
<FieldRef Name='ServerUrl'/>
<FieldRef Name='FileLeafRef'/> 
<FieldRef Name='GUID'/>

The DocIcon gives 'docx' and ServerUrl gives the path to the doc '/sub1/Shared Documents/Document 1.docx'.

Is there any field that could be used to display the document icon ?

1 Answer 1


You cannot get the document icon as a property, you will have to make the url for it.

SharePoint has already lots of icons available in the DOCICON.xml file at C:/Program Files/Common Files/Microsoft Shared/web server extensions/14/TEMPLATE/XML

Simplest way could be to load based on file extension "/_layouts/images/icXXX.gif (where icXXX, would be icdoc.gif, idpdf.gif, etc.)

You will have to take the file extension by splitting by the last '.' sign and create the url using code or a regular expression.

Reference: Answer by C.Marius

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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