Display Document Type Icon in a DVWP
I had a requirement to display document icons inside a Data View Web Part. While googling I found some interesting information on this document types and there icons.
SharePoint has a pre populated list of document types along with respective images that maps to it. This document type to document icon image mapping can be found inside the file DOCICON.XML which can be located in the following location C:Program FilesCommon FilesMicrosoft SharedWeb Server Extensions14TEMPLATEXML
So now how to display the document type icons inside a DVWP. If you have worked with DVWP then you already know there is a names space DDWRT that has quite a lot pre defined functions. Inside those DDWRT function you will find ddwrt:MapToIcon that can be used to get the respective image for a given document type.
In this case we are using another ddwrt method to get the file extension from the file leaf ref and processing it to get the image.