Search code examples
asp.netxmlxsltdevexpressaspxgridview

ASPxGridView bounded with XmlDataSource show empty cells


I have some XML which contains records, like this:

<?xml version="1.0" encoding="utf-8"?>
<ROWDATA>
        <ROW DESTINATION_NO="569" SP="EP0002" OPERATEUR="E.P.E TVC" TETE_LIGNE="ALGER" HEURE="30/12/1899 01:00" QUAI="6" JOUR="0"/>
        <ROW DESTINATION_NO="196" SP="SP0260" OPERATEUR="autorisation ML" TETE_LIGNE="Laghouat" HEURE="30/12/1899 00:01" QUAI="0" JOUR="0"/>
        <ROW DESTINATION_NO="35" SP="SP0250" OPERATEUR="E.U.R.L .EK. el bahya" TETE_LIGNE="Bechar" HEURE="30/12/1899 19:00" QUAI="12" JOUR="0"/>
</ROWDATA>

and the XSLT like this :

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:template match="/">
    <items>
      <xsl:for-each select="//ROW">
        <item DESTINATION_NO="{DESTINATION_NO}" SP="{SP}" OPERATEUR="{OPERATEUR}" TETE_LIGNE="{TETE_LIGNE}"  HEURE="{HEURE}" QUAI="{QUAI}" JOUR="{JOUR}"/>
      </xsl:for-each>
    </items>
  </xsl:template>
</xsl:stylesheet>

the column's settings for ASPxGridView are :

<dx:ASPxGridView ID="ASPxGridView1" runat="server" DataSourceID="DépartsXmlDataSource" AutoGenerateColumns="False" Width="100%">
    <Columns>
        <dx:GridViewDataTextColumn FieldName="DESTINATION_NO" VisibleIndex="0">
        </dx:GridViewDataTextColumn>
        <dx:GridViewDataTextColumn FieldName="SP" VisibleIndex="1">
        </dx:GridViewDataTextColumn>
        <dx:GridViewDataTextColumn FieldName="OPERATEUR_" VisibleIndex="2">
        </dx:GridViewDataTextColumn>
        <dx:GridViewDataTextColumn FieldName="TETE_LIGNE" VisibleIndex="3">
        </dx:GridViewDataTextColumn>
        <dx:GridViewDataTextColumn FieldName="HEURE" VisibleIndex="4">
        </dx:GridViewDataTextColumn>
        <dx:GridViewDataTextColumn FieldName="QUAI" VisibleIndex="5">
        </dx:GridViewDataTextColumn>
        <dx:GridViewDataTextColumn FieldName="JOUR" VisibleIndex="6">
        </dx:GridViewDataTextColumn>
    </Columns>
</dx:ASPxGridView>

when I bound this XML file to ASPxGridView's control, I get all rows in XML file, but all of them is empty,

For example, in XML file containing 3 records, the Gridview display 3 rows, but each cell contain an empty value.

Would someone give me a solution for this problem ? Many thanks.


Solution

  • You have an error in transformation (xslt). The row transformation row should be:

    <item DESTINATION_NO="{@DESTINATION_NO}" SP="{@SP}" 
      OPERATEUR="{@OPERATEUR}" TETE_LIGNE="{@TETE_LIGNE}"  
      HEURE="{@HEURE}" QUAI="{@QUAI}" JOUR="{@JOUR}" />
    

    You can quickly check out the transformation for example here: http://www.freeformatter.com/xsl-transformer.html