Bashar Kokash' Blog

.Net Framework, windows and web development.

This site

Resources

Friends

Sponsors

  • MaximumASP
  • Packet Sniffer
    Custom Essay
  • internet fax

May 2008 - Posts

Visual Studio 2008 SP1 Beta installation note

Visual Studio 2008 Service Pack 1 Beta released and you can download it here.

But if you previously installed a Visual Studio 2008 Hotfix, you must run the Hotfix Cleanup Utility before installing Visual Studio 2008 SP1 Beta.You can download the Visual Studio 2008 Hotfix Cleanup Utility for Installing Visual Studio 2008 SP1 Beta here.

And if you are using Windows VISTA you should install Service Pack 1 first.

Default dot aspx

Default.aspx

No, it's not the name of a page written in ASP.NET, it's a new great website for learning ASP.NET and all relevant technologies.

It contains a lot of topics like: ASP.NET, SQL, JavaScript, OOP,XML, etc...

Tutorials are presented in terms of question and answers, which is suitable for new ASP.NET programmers.

 

By the way, you can ask your own questions there.

Posted: May 14 2008, 03:59 PM by BasharKokash | with no comments
Filed under:
Transforming XML using XSLT

 

Dealing with xml files as a place to store data is very common in ASP.NET, and it's very easy to implement, just use the XmlDataSource and set the DataFile property to your xml file then set the DataSourceID of the data control (GrideView, DataList...) to the XmlDataSource.

If data records in the xml file are described as attributes, then there is no problem while displaying the data records directly in the GrideView as the following example:

<People>
    <Person name="Bashar Kokash" age="22" />
    <Person name="Bassl Kokash" age="21" />
    <Person name="Mohave Musa" age="25"/>
</People>

But what if the xml file was written in different way and the previous attributes are represented as child nodes instead, so the previous xml will look something like this:

<People>
    <Person>
      <name>
        Bashar Kokash
      </name>
      <age>
        22
      </age>
    </Person>
    <Person>
      <name>
        Bassl Kokash
      </name>
      <age>
        21
      </age>
    </Person>
    <Person>
      <name>
        Morhaf Musa
      </name>
      <age>
        25
      </age>
    </Person>
</People>

Simply we can rewrite the xml file to be just like what we want ie; as records each record is represented by node and a set of attributes. Actually it's not that simple when dealing with large amount of data stored as xml. Instead we can Transform the xml file into the desired xml using the XSL Transformation.

To write code in XSLT add an XSLT File to your project, remove the Template section  then format the template of the xml file that you want to get using XSLT tags, for the previous xml the following XSLT code will transform the xml hierarchical nodes into xml records as in the first example:

  <xsl:template match="/">
    <xsl:for-each select="People">
      <xsl:element name="People">
        <xsl:for-each select ="Person">
          <xsl:element name ="Person">
          <xsl:attribute name="name">
            <xsl:value-of select ="name"/>
          </xsl:attribute>
          <xsl:attribute name ="age">
            <xsl:value-of select ="age"/>
          </xsl:attribute>
          </xsl:element>
        </xsl:for-each>
      </xsl:element>
    </xsl:for-each>
  </xsl:template>

Then as a final step when setting the xml file to the XmlDataSource we have also to set the XSLT transformation file. Now we can bind our xml file to the GrideView having no problems.

Posted: May 13 2008, 01:38 PM by BasharKokash | with no comments
Filed under: ,
The leading UI suite for ASP.NET - Telerik radControls
Outstanding performance. Full ASP.NET AJAX support. Nearly codeless development.