<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Tech.It.2.Me-&#62;{By.Anton.Perez} &#187; ASP.NET</title>
	<atom:link href="http://antonperez.com/category/aspnet/feed/" rel="self" type="application/rss+xml" />
	<link>http://antonperez.com</link>
	<description>Technical satisfaction guaranteed...</description>
	<lastBuildDate>Mon, 16 Aug 2010 20:46:07 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Hash class using System.Security.Cryptography</title>
		<link>http://antonperez.com/2010/07/29/hash-class-from-system-security-cryptography/</link>
		<comments>http://antonperez.com/2010/07/29/hash-class-from-system-security-cryptography/#comments</comments>
		<pubDate>Thu, 29 Jul 2010 23:57:20 +0000</pubDate>
		<dc:creator>anton</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[How-to]]></category>

		<guid isPermaLink="false">http://antonperez.com/2010/07/29/hash-class-from-system-security-cryptography/</guid>
		<description><![CDATA[Adding for archival purposes…
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Security.Cryptography;

namespace Classes
{
    public class Hash
    {
        public Hash()
        { }

        #region Hash Choices
        [...]]]></description>
			<content:encoded><![CDATA[<p>Adding for archival purposes…</p>
<pre class="code"><span style="color: blue">using </span>System;
<span style="color: blue">using </span>System.Collections.Generic;
<span style="color: blue">using </span>System.Linq;
<span style="color: blue">using </span>System.Web;
<span style="color: blue">using </span>System.Security.Cryptography;

<span style="color: blue">namespace </span>Classes
{
    <span style="color: blue">public class </span><span style="color: #2b91af">Hash
    </span>{
        <span style="color: blue">public </span>Hash()
        { }

        <span style="color: blue">#region </span>Hash Choices
        <span style="color: gray">/// &lt;summary&gt;</span><span style="color: green">The wanted hash function.</span><span style="color: gray">&lt;/summary&gt;
        </span><span style="color: blue">public enum </span><span style="color: #2b91af">HashType </span>: <span style="color: blue">int
        </span>{
            <span style="color: gray">/// &lt;summary&gt;</span><span style="color: green">MD5 Hashing</span><span style="color: gray">&lt;/summary&gt;
            </span>MD5,
            <span style="color: gray">/// &lt;summary&gt;</span><span style="color: green">SHA1 Hashing</span><span style="color: gray">&lt;/summary&gt;
            </span>SHA1,
            <span style="color: gray">/// &lt;summary&gt;</span><span style="color: green">SHA256 Hashing</span><span style="color: gray">&lt;/summary&gt;
            </span>SHA256,
            <span style="color: gray">/// &lt;summary&gt;</span><span style="color: green">SHA384 Hashing</span><span style="color: gray">&lt;/summary&gt;
            </span>SHA384,
            <span style="color: gray">/// &lt;summary&gt;</span><span style="color: green">SHA512 Hashing</span><span style="color: gray">&lt;/summary&gt;
            </span>SHA512
        } <span style="color: green">/* HashType */
        </span><span style="color: blue">#endregion

        #region </span>Public Methods
        <span style="color: gray">/// &lt;summary&gt;</span><span style="color: green">Generates the hash of a text.</span><span style="color: gray">&lt;/summary&gt;
        /// &lt;param name=&quot;strPlain&quot;&gt;</span><span style="color: green">The text of which to generate a hash of.</span><span style="color: gray">&lt;/param&gt;
        /// &lt;param name=&quot;hshType&quot;&gt;</span><span style="color: green">The hash function to use.</span><span style="color: gray">&lt;/param&gt;
        /// &lt;returns&gt;</span><span style="color: green">The hash as a hexadecimal string.</span><span style="color: gray">&lt;/returns&gt;
        </span><span style="color: blue">public static string </span>GetHash(<span style="color: blue">string </span>strPlain, <span style="color: #2b91af">HashType </span>hshType)
        {
            <span style="color: blue">string </span>strRet;
            <span style="color: blue">switch </span>(hshType)
            {
                <span style="color: blue">case </span><span style="color: #2b91af">HashType</span>.MD5:
                    strRet = GetMD5(strPlain);
                    <span style="color: blue">break</span>;
                <span style="color: blue">case </span><span style="color: #2b91af">HashType</span>.SHA1:
                    strRet = GetSHA1(strPlain);
                    <span style="color: blue">break</span>;
                <span style="color: blue">case </span><span style="color: #2b91af">HashType</span>.SHA256:
                    strRet = GetSHA256(strPlain);
                    <span style="color: blue">break</span>;
                <span style="color: blue">case </span><span style="color: #2b91af">HashType</span>.SHA384:
                    strRet = GetSHA384(strPlain);
                    <span style="color: blue">break</span>;
                <span style="color: blue">case </span><span style="color: #2b91af">HashType</span>.SHA512:
                    strRet = GetSHA512(strPlain);
                    <span style="color: blue">break</span>;
                <span style="color: blue">default</span>:
                    strRet = <span style="color: #a31515">&quot;Invalid HashType&quot;</span>;
                    <span style="color: blue">break</span>;
            }
            <span style="color: blue">return </span>strRet;
        } <span style="color: green">/* GetHash */

        </span><span style="color: gray">/// &lt;summary&gt;</span><span style="color: green">Checks a text with a hash.</span><span style="color: gray">&lt;/summary&gt;
        /// &lt;param name=&quot;strOriginal&quot;&gt;</span><span style="color: green">The text to compare the hash against.</span><span style="color: gray">&lt;/param&gt;
        /// &lt;param name=&quot;strHash&quot;&gt;</span><span style="color: green">The hash to compare against.</span><span style="color: gray">&lt;/param&gt;
        /// &lt;param name=&quot;hshType&quot;&gt;</span><span style="color: green">The type of hash.</span><span style="color: gray">&lt;/param&gt;
        /// &lt;returns&gt;</span><span style="color: green">True if the hash validates, false otherwise.</span><span style="color: gray">&lt;/returns&gt;
        </span><span style="color: blue">public static bool </span>CheckHash(<span style="color: blue">string </span>strOriginal, <span style="color: blue">string </span>strHash, <span style="color: #2b91af">HashType </span>hshType)
        {
            <span style="color: blue">string </span>strOrigHash = GetHash(strOriginal, hshType);
            <span style="color: blue">return </span>(strOrigHash == strHash);
        } <span style="color: green">/* CheckHash */
        </span><span style="color: blue">#endregion

        #region </span>Hashers
        <span style="color: blue">private static string </span>GetMD5(<span style="color: blue">string </span>strPlain)
        {
            <span style="color: #2b91af">UnicodeEncoding </span>UE = <span style="color: blue">new </span><span style="color: #2b91af">UnicodeEncoding</span>();
            <span style="color: blue">byte</span>[] HashValue, MessageBytes = UE.GetBytes(strPlain);
            <span style="color: #2b91af">MD5 </span>md5 = <span style="color: blue">new </span><span style="color: #2b91af">MD5CryptoServiceProvider</span>();
            <span style="color: blue">string </span>strHex = <span style="color: #a31515">&quot;&quot;</span>;

            HashValue = md5.ComputeHash(MessageBytes);
            <span style="color: blue">foreach </span>(<span style="color: blue">byte </span>b <span style="color: blue">in </span>HashValue)
            {
                strHex += <span style="color: #2b91af">String</span>.Format(<span style="color: #a31515">&quot;{0:x2}&quot;</span>, b);
            }
            <span style="color: blue">return </span>strHex;
        } <span style="color: green">/* GetMD5 */

        </span><span style="color: blue">private static string </span>GetSHA1(<span style="color: blue">string </span>strPlain)
        {
            <span style="color: #2b91af">UnicodeEncoding </span>UE = <span style="color: blue">new </span><span style="color: #2b91af">UnicodeEncoding</span>();
            <span style="color: blue">byte</span>[] HashValue, MessageBytes = UE.GetBytes(strPlain);
            <span style="color: #2b91af">SHA1Managed </span>SHhash = <span style="color: blue">new </span><span style="color: #2b91af">SHA1Managed</span>();
            <span style="color: blue">string </span>strHex = <span style="color: #a31515">&quot;&quot;</span>;

            HashValue = SHhash.ComputeHash(MessageBytes);
            <span style="color: blue">foreach </span>(<span style="color: blue">byte </span>b <span style="color: blue">in </span>HashValue)
            {
                strHex += <span style="color: #2b91af">String</span>.Format(<span style="color: #a31515">&quot;{0:x2}&quot;</span>, b);
            }
            <span style="color: blue">return </span>strHex;
        } <span style="color: green">/* GetSHA1 */

        </span><span style="color: blue">private static string </span>GetSHA256(<span style="color: blue">string </span>strPlain)
        {
            <span style="color: #2b91af">UnicodeEncoding </span>UE = <span style="color: blue">new </span><span style="color: #2b91af">UnicodeEncoding</span>();
            <span style="color: blue">byte</span>[] HashValue, MessageBytes = UE.GetBytes(strPlain);
            <span style="color: #2b91af">SHA256Managed </span>SHhash = <span style="color: blue">new </span><span style="color: #2b91af">SHA256Managed</span>();
            <span style="color: blue">string </span>strHex = <span style="color: #a31515">&quot;&quot;</span>;

            HashValue = SHhash.ComputeHash(MessageBytes);
            <span style="color: blue">foreach </span>(<span style="color: blue">byte </span>b <span style="color: blue">in </span>HashValue)
            {
                strHex += <span style="color: #2b91af">String</span>.Format(<span style="color: #a31515">&quot;{0:x2}&quot;</span>, b);
            }
            <span style="color: blue">return </span>strHex;
        } <span style="color: green">/* GetSHA256 */

        </span><span style="color: blue">private static string </span>GetSHA384(<span style="color: blue">string </span>strPlain)
        {
            <span style="color: #2b91af">UnicodeEncoding </span>UE = <span style="color: blue">new </span><span style="color: #2b91af">UnicodeEncoding</span>();
            <span style="color: blue">byte</span>[] HashValue, MessageBytes = UE.GetBytes(strPlain);
            <span style="color: #2b91af">SHA384Managed </span>SHhash = <span style="color: blue">new </span><span style="color: #2b91af">SHA384Managed</span>();
            <span style="color: blue">string </span>strHex = <span style="color: #a31515">&quot;&quot;</span>;

            HashValue = SHhash.ComputeHash(MessageBytes);
            <span style="color: blue">foreach </span>(<span style="color: blue">byte </span>b <span style="color: blue">in </span>HashValue)
            {
                strHex += <span style="color: #2b91af">String</span>.Format(<span style="color: #a31515">&quot;{0:x2}&quot;</span>, b);
            }
            <span style="color: blue">return </span>strHex;
        } <span style="color: green">/* GetSHA384 */

        </span><span style="color: blue">private static string </span>GetSHA512(<span style="color: blue">string </span>strPlain)
        {
            <span style="color: #2b91af">UnicodeEncoding </span>UE = <span style="color: blue">new </span><span style="color: #2b91af">UnicodeEncoding</span>();
            <span style="color: blue">byte</span>[] HashValue, MessageBytes = UE.GetBytes(strPlain);
            <span style="color: #2b91af">SHA512Managed </span>SHhash = <span style="color: blue">new </span><span style="color: #2b91af">SHA512Managed</span>();
            <span style="color: blue">string </span>strHex = <span style="color: #a31515">&quot;&quot;</span>;

            HashValue = SHhash.ComputeHash(MessageBytes);
            <span style="color: blue">foreach </span>(<span style="color: blue">byte </span>b <span style="color: blue">in </span>HashValue)
            {
                strHex += <span style="color: #2b91af">String</span>.Format(<span style="color: #a31515">&quot;{0:x2}&quot;</span>, b);
            }
            <span style="color: blue">return </span>strHex;
        } <span style="color: green">/* GetSHA512 */
        </span><span style="color: blue">#endregion
    </span>}
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://antonperez.com/2010/07/29/hash-class-from-system-security-cryptography/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fix to &quot;The handle is invalid&quot; error when ASP.NET writes to the Eventlogs</title>
		<link>http://antonperez.com/2010/07/12/fix-to-the-handle-is-invalid-error-when-asp-net-writes-to-the-eventlogs/</link>
		<comments>http://antonperez.com/2010/07/12/fix-to-the-handle-is-invalid-error-when-asp-net-writes-to-the-eventlogs/#comments</comments>
		<pubDate>Mon, 12 Jul 2010 20:50:19 +0000</pubDate>
		<dc:creator>anton</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[General Development]]></category>
		<category><![CDATA[How-to]]></category>

		<guid isPermaLink="false">http://antonperez.com/2010/07/12/fix-to-the-handle-is-invalid-error-when-asp-net-writes-to-the-eventlogs/</guid>
		<description><![CDATA[Have you ever come across the error below with one of your ASP.NET web apps that is trying to write to the Eventlogs? If so, read on&#8230; 
 
By default the ASPNET user cannot access the existing eventlogs categories. To resolve this, you must set the permissions in the Eventlog key in the registry: 

Launch [...]]]></description>
			<content:encoded><![CDATA[<p>Have you ever come across the error below with one of your ASP.NET web apps that is trying to write to the Eventlogs? If so, read on&#8230; </p>
<p><a href="http://antonperez.com/wp-content/uploads/2010/07/image1.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://antonperez.com/wp-content/uploads/2010/07/image_thumb1.png" width="244" height="117" /></a> </p>
<p>By default the ASPNET user cannot access the existing eventlogs categories. To resolve this, you must set the permissions in the Eventlog key in the registry: </p>
<ol>
<li>Launch RegEdit. </li>
<li>Navigate to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\. </li>
<li>From the menu, select Edit-&gt;Permissions. </li>
<li>Click the Add button and write ASPNET (if ASP.NET is running under a different User ID, use that ID instead). </li>
<li>Click OK. </li>
<li>Select the newly added user from the list (ASP.NET Machine User by default). </li>
<li>Click on Full Control in the Allow column. 8. Click OK.</li>
</ol>
<p>More info <a href="http://support.microsoft.com/kb/842795">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://antonperez.com/2010/07/12/fix-to-the-handle-is-invalid-error-when-asp-net-writes-to-the-eventlogs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Most Common ASP.NET Support issues</title>
		<link>http://antonperez.com/2010/05/24/most-common-asp-net-support-issues/</link>
		<comments>http://antonperez.com/2010/05/24/most-common-asp-net-support-issues/#comments</comments>
		<pubDate>Mon, 24 May 2010 19:53:32 +0000</pubDate>
		<dc:creator>anton</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Microsoft]]></category>

		<guid isPermaLink="false">http://antonperez.com/2010/05/24/most-common-asp-net-support-issues/</guid>
		<description><![CDATA[Below is a summary of the “two top things that cause trouble in production ASP.NET web sites,” per Scott Hanselman, which he obtained from deep within Microsoft Developer Support.&#160; Go here to read the complete article.
#1 Issue &#8211; Configuration 
Seems the #1 issue in support for problems with ASP.NET 2.x and 3.x is configuration.&#160; 



Symptoms [...]]]></description>
			<content:encoded><![CDATA[<p>Below is a summary of the “two top things that cause trouble in production ASP.NET web sites,” per Scott Hanselman, which he obtained from deep within Microsoft Developer Support.&#160; Go <a href="http://www.hanselman.com/blog/MostCommonASPNETSupportIssuesReportingFromDeepInsideMicrosoftDeveloperSupport.aspx?utm_source=feedburner&amp;utm_medium=feed&amp;utm_campaign=Feed:+ScottHanselmanASPNET+(Scott+Hanselman's+Computer+Zen+-+ASPNET)&amp;utm_content=Google+Reader">here</a> to read the complete article.</p>
<p>#<u><strong>1 Issue &#8211; Configuration</strong></u> </p>
<p>Seems the #1 issue in support for problems with ASP.NET 2.x and 3.x is configuration.&#160; </p>
<table border="1" cellspacing="0" cellpadding="7" width="339">
<tbody>
<tr>
<td valign="top" width="146"><strong>Symptoms </strong></td>
<td valign="top" width="191"><strong>Notes</strong> </td>
</tr>
<tr>
<td valign="top" width="146">OOM          <br />Performance           <br />High memory           <br />Hangs           <br />Deadlocks </td>
<td valign="top" width="191">There are more debug=true cases than there should be.</td>
</tr>
</tbody>
</table>
<p>&#160;</p>
<p><strong><u>#2 Issue &#8211; Problems with an External (non-ASP.NET) Root Cause</u></strong></p>
<p>Sometimes when you&#8217;re having trouble with an ASP.NET site, the problem turns out to not be ASP.NET itself. </p>
<table border="1" cellspacing="0" cellpadding="7" width="522">
<tbody>
<tr>
<td valign="top" width="72"><strong>Issue</strong></td>
<td valign="top" width="47"><strong>Product</strong></td>
<td valign="top" width="71"><strong>Description</strong></td>
<td valign="top" width="144"><strong>Symptoms</strong></td>
<td valign="top" width="186"><strong>Notes</strong></td>
</tr>
<tr>
<td valign="top" width="72">Anti-virus software</td>
<td valign="top" width="47">All</td>
<td valign="top" width="71">Anti-virus software is installed onto Servers and causes all kinds of problems. </td>
<td valign="top" width="144">
<ul>
<li>Application restarting </li>
<li>Slow performance </li>
<li>Session variable are null </li>
<li>Cannot install hotfix </li>
<li>Intermittent time outs </li>
<li>High memory </li>
<li>Session lost </li>
<li>IDE Hangs </li>
<li>Deadlocks </li>
</ul>
</td>
<td valign="top" width="186">
<p>This consists of all AV software reported by our customers. All cases do not report the AV software that is being used so the manufacturer is not always known. </p>
<p>KB821438, KB248013, KB295375, KB817442</p>
</td>
</tr>
<tr>
<td valign="top" width="72">3rd party Vendors</td>
<td valign="top" width="47">All</td>
<td valign="top" width="71">This is a category of cases where the failure was due to a 3rd party manufacturer.</td>
<td valign="top" width="144">
<ul>
<li>Crash </li>
<li>100% CPU </li>
<li>High memory </li>
<li>Framework errors </li>
<li>Hang </li>
</ul>
</td>
<td valign="top" width="186">The top culprits are 3rd party database systems, and 3rd party internet access management systems</td>
</tr>
<tr>
<td valign="top" width="72">Microsoft component</td>
<td valign="top" width="47">All</td>
<td valign="top" width="71">Microsoft software</td>
<td valign="top" width="144">
<ul>
<li>Intermittent time outs </li>
<li>High memory </li>
<li>Deadlocks </li>
<li>100% CPU              <br />Crash </li>
</ul>
</td>
<td valign="top" width="186">Design issues that cause performance issues like sprocs, deadlocks, etc. Profile your applications and the database! (Pro tip: select * from authors doesn&#8217;t scale.) Pair up DBAs and programmers and profile from end to end</td>
</tr>
</tbody>
</table>
]]></content:encoded>
			<wfw:commentRss>http://antonperez.com/2010/05/24/most-common-asp-net-support-issues/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Free Microsoft Press e-book offer</title>
		<link>http://antonperez.com/2007/12/27/free-microsoft-press-e-book-offer/</link>
		<comments>http://antonperez.com/2007/12/27/free-microsoft-press-e-book-offer/#comments</comments>
		<pubDate>Thu, 27 Dec 2007 00:28:37 +0000</pubDate>
		<dc:creator>anton</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Deals]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Resource]]></category>
		<category><![CDATA[Web 2.0]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://antonperez.com/2007/12/27/free-microsoft-press-e-book-offer/</guid>
		<description><![CDATA[Just sign up with your Windows Live/Passport account and you can download all three e-books by Microsoft Press.&#160; It includes the following: 
 
Enjoy!
]]></description>
			<content:encoded><![CDATA[<p>Just sign up with your Windows Live/Passport account and you can <a href="http://csna01.libredigital.com/?urvs5cn3s8">download all three e-books by Microsoft Press</a>.&nbsp; It includes the following: </p>
<p><img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="526" alt="image" src="http://antonperez.com/wp-content/uploads/2008/01/image1.png" width="514" border="0"> </p>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://antonperez.com/2007/12/27/free-microsoft-press-e-book-offer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bind an XMLDataSource to a GridView control</title>
		<link>http://antonperez.com/2007/06/27/bind-an-xmldatasource-to-a-gridview-control/</link>
		<comments>http://antonperez.com/2007/06/27/bind-an-xmldatasource-to-a-gridview-control/#comments</comments>
		<pubDate>Thu, 28 Jun 2007 00:54:22 +0000</pubDate>
		<dc:creator>anton</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[How-to]]></category>
		<category><![CDATA[Microsoft]]></category>

		<guid isPermaLink="false">http://antonperez.com/?p=167</guid>
		<description><![CDATA[
On one of my ASP.NET 2.0 projects, I had to use an XML file as the data source for a GridView control. The problem was that I had never used this method before. But after doing some research, I found it to be very similar (and straightforward) to binding to a database &#8211; with the [...]]]></description>
			<content:encoded><![CDATA[</p>
<p>On one of my ASP.NET 2.0 projects, I had to use an XML file as the data source for a GridView control. The problem was that I had never used this method before. But after doing some research, I found it to be very similar (and straightforward) to binding to a database &#8211; with the exception of the need to use <a title="XPath" href="http://en.wikipedia.org/wiki/XPath" target="_blank">XPath</a>.
<p>So&#8230;without further adieu, here are the steps and code. Enjoy!
<p>1. Create an XML file that contains your data, like below (taken from Microsoft&#8217;s website to save a lot of typing). Save it as <strong>books.xml</strong>.
<pre class="code"><font size="2"><span style="color: rgb(0,0,255)">&lt;?</span><span style="color: rgb(163,21,21)">xml</span><span style="color: rgb(0,0,255)"> </span><span style="color: rgb(255,0,0)">version</span><span style="color: rgb(0,0,255)">=</span>"<span style="color: rgb(0,0,255)">1.0</span>"</font><font size="2"><span style="color: rgb(0,0,255)">?&gt;
&lt;</span><span style="color: rgb(163,21,21)">catalog</span></font><font size="2"><span style="color: rgb(0,0,255)">&gt;
  &lt;</span><span style="color: rgb(163,21,21)">book</span><span style="color: rgb(0,0,255)"> </span><span style="color: rgb(255,0,0)">id</span><span style="color: rgb(0,0,255)">=</span>"<span style="color: rgb(0,0,255)">bk101</span>"</font><font size="2"><span style="color: rgb(0,0,255)">&gt;
    &lt;</span><span style="color: rgb(163,21,21)">author</span><span style="color: rgb(0,0,255)">&gt;</span>Gambardella, Matthew<span style="color: rgb(0,0,255)">&lt;/</span><span style="color: rgb(163,21,21)">author</span></font><font size="2"><span style="color: rgb(0,0,255)">&gt;
    &lt;</span><span style="color: rgb(163,21,21)">title</span><span style="color: rgb(0,0,255)">&gt;</span>XML Developer's Guide<span style="color: rgb(0,0,255)">&lt;/</span><span style="color: rgb(163,21,21)">title</span></font><font size="2"><span style="color: rgb(0,0,255)">&gt;
    &lt;</span><span style="color: rgb(163,21,21)">genre</span><span style="color: rgb(0,0,255)">&gt;</span>Computer<span style="color: rgb(0,0,255)">&lt;/</span><span style="color: rgb(163,21,21)">genre</span></font><font size="2"><span style="color: rgb(0,0,255)">&gt;
    &lt;</span><span style="color: rgb(163,21,21)">price</span><span style="color: rgb(0,0,255)">&gt;</span>44.95<span style="color: rgb(0,0,255)">&lt;/</span><span style="color: rgb(163,21,21)">price</span></font><font size="2"><span style="color: rgb(0,0,255)">&gt;
    &lt;</span><span style="color: rgb(163,21,21)">publish_date</span><span style="color: rgb(0,0,255)">&gt;</span>2000-10-01<span style="color: rgb(0,0,255)">&lt;/</span><span style="color: rgb(163,21,21)">publish_date</span></font><font size="2"><span style="color: rgb(0,0,255)">&gt;
    &lt;</span><span style="color: rgb(163,21,21)">description</span></font><font size="2"><span style="color: rgb(0,0,255)">&gt;
</span>      An in-depth look at creating applications
      with XML.
<span style="color: rgb(0,0,255)">    &lt;/</span><span style="color: rgb(163,21,21)">description</span></font><font size="2"><span style="color: rgb(0,0,255)">&gt;
  &lt;/</span><span style="color: rgb(163,21,21)">book</span></font><font size="2"><span style="color: rgb(0,0,255)">&gt;
  &lt;</span><span style="color: rgb(163,21,21)">book</span><span style="color: rgb(0,0,255)"> </span><span style="color: rgb(255,0,0)">id</span><span style="color: rgb(0,0,255)">=</span>"<span style="color: rgb(0,0,255)">bk102</span>"</font><font size="2"><span style="color: rgb(0,0,255)">&gt;
    &lt;</span><span style="color: rgb(163,21,21)">author</span><span style="color: rgb(0,0,255)">&gt;</span>Ralls, Kim<span style="color: rgb(0,0,255)">&lt;/</span><span style="color: rgb(163,21,21)">author</span></font><font size="2"><span style="color: rgb(0,0,255)">&gt;
    &lt;</span><span style="color: rgb(163,21,21)">title</span><span style="color: rgb(0,0,255)">&gt;</span>Midnight Rain<span style="color: rgb(0,0,255)">&lt;/</span><span style="color: rgb(163,21,21)">title</span></font><font size="2"><span style="color: rgb(0,0,255)">&gt;
    &lt;</span><span style="color: rgb(163,21,21)">genre</span><span style="color: rgb(0,0,255)">&gt;</span>Fantasy<span style="color: rgb(0,0,255)">&lt;/</span><span style="color: rgb(163,21,21)">genre</span></font><font size="2"><span style="color: rgb(0,0,255)">&gt;
    &lt;</span><span style="color: rgb(163,21,21)">price</span><span style="color: rgb(0,0,255)">&gt;</span>5.95<span style="color: rgb(0,0,255)">&lt;/</span><span style="color: rgb(163,21,21)">price</span></font><font size="2"><span style="color: rgb(0,0,255)">&gt;
    &lt;</span><span style="color: rgb(163,21,21)">publish_date</span><span style="color: rgb(0,0,255)">&gt;</span>2000-12-16<span style="color: rgb(0,0,255)">&lt;/</span><span style="color: rgb(163,21,21)">publish_date</span></font><font size="2"><span style="color: rgb(0,0,255)">&gt;
    &lt;</span><span style="color: rgb(163,21,21)">description</span></font><font size="2"><span style="color: rgb(0,0,255)">&gt;
</span>      A former architect battles corporate zombies,
      an evil sorceress, and her own childhood to become queen
      of the world.
<span style="color: rgb(0,0,255)">    &lt;/</span><span style="color: rgb(163,21,21)">description</span></font><font size="2"><span style="color: rgb(0,0,255)">&gt;
  &lt;/</span><span style="color: rgb(163,21,21)">book</span></font><font size="2"><span style="color: rgb(0,0,255)">&gt;
&lt;/</span><span style="color: rgb(163,21,21)">catalog</span><span style="color: rgb(0,0,255)">&gt;</span></font></pre>
<p>2. Add a <strong>GridView</strong> control to your .aspx page and rename it to <strong>gdvBooks</strong>.<br />3. Drag an <strong>XmlDataSource</strong> control to your form, rename it xdsBooks, and assign your XML file (<strong>books.xml</strong>) in the control&#8217;s <strong>DataFile</strong> property.<br />4. Next, change to <strong>Source</strong> view and input the code below.
<pre class="code"><font size="2"><span style="color: rgb(0,0,255)">&lt;</span><span style="color: rgb(163,21,21)">asp</span><span style="color: rgb(0,0,255)">:</span><span style="color: rgb(163,21,21)">GridView</span> <span style="color: rgb(255,0,0)">ID</span><span style="color: rgb(0,0,255)">="gdvServerVersions"</span> <span style="color: rgb(255,0,0)">runat</span><span style="color: rgb(0,0,255)">="server"</span>         </font></pre>
<pre class="code"><font size="2">    <span style="color: rgb(255,0,0)">AutoGenerateColumns</span><span style="color: rgb(0,0,255)">="False"</span> <span style="color: rgb(255,0,0)">DataKeyNames</span><span style="color: rgb(0,0,255)">="id"</span>         </font></pre>
<pre class="code"><font size="2">    <span style="color: rgb(255,0,0)">DataSourceID</span><span style="color: rgb(0,0,255)">="xdsServerVersions" </span><span style="color: rgb(255,0,0)">EmptyDataText</span><span style="color: rgb(0,0,255)">="No data available."&gt;</span>                </font></pre>
<pre class="code"><font size="2">    <span style="color: rgb(0,0,255)">&lt;</span><span style="color: rgb(163,21,21)">Columns</span><span style="color: rgb(0,0,255)">&gt;</span>
        <span style="color: rgb(0,0,255)">&lt;</span><span style="color: rgb(163,21,21)">asp</span><span style="color: rgb(0,0,255)">:</span><span style="color: rgb(163,21,21)">BoundField</span> <span style="color: rgb(255,0,0)">HeaderText</span><span style="color: rgb(0,0,255)">="Book ID" </span><span style="color: rgb(255,0,0)">DataField</span><span style="color: rgb(0,0,255)">="id"</span> </font></pre>
<pre class="code"><font size="2">            <span style="color: rgb(255,0,0)">SortExpression</span><span style="color: rgb(0,0,255)">="id"</span> </font><font size="2"><span style="color: rgb(0,0,255)">/&gt;
</span>        <span style="color: rgb(0,0,255)">&lt;</span><span style="color: rgb(163,21,21)">asp</span><span style="color: rgb(0,0,255)">:</span><span style="color: rgb(163,21,21)">TemplateField</span> <span style="color: rgb(255,0,0)">HeaderText</span></font><font size="2"><span style="color: rgb(0,0,255)">="Author"&gt;
</span>            <span style="color: rgb(0,0,255)">&lt;</span><span style="color: rgb(163,21,21)">ItemTemplate</span></font><font size="2"><span style="color: rgb(0,0,255)">&gt;
</span>                <span style="background: rgb(255,238,98)">&lt;%<span style="color: rgb(0,0,255)"></span>#</span> XPath("author") </font><font size="2"><span style="background: rgb(255,238,98)">%&gt;
</span>            <span style="color: rgb(0,0,255)">&lt;/</span><span style="color: rgb(163,21,21)">ItemTemplate</span></font><font size="2"><span style="color: rgb(0,0,255)">&gt;
</span>        <span style="color: rgb(0,0,255)">&lt;/</span><span style="color: rgb(163,21,21)">asp</span><span style="color: rgb(0,0,255)">:</span><span style="color: rgb(163,21,21)">TemplateField</span><span style="color: rgb(0,0,255)">&gt;</span>
        <span style="color: rgb(0,0,255)">&lt;</span><span style="color: rgb(163,21,21)">asp</span><span style="color: rgb(0,0,255)">:</span><span style="color: rgb(163,21,21)">TemplateField</span> <span style="color: rgb(255,0,0)">HeaderText</span></font><font size="2"><span style="color: rgb(0,0,255)">="Title"&gt;
</span>            <span style="color: rgb(0,0,255)">&lt;</span><span style="color: rgb(163,21,21)">ItemTemplate</span></font><font size="2"><span style="color: rgb(0,0,255)">&gt;
</span>                <span style="background: rgb(255,238,98)">&lt;%<span style="color: rgb(0,0,255)"></span>#</span> XPath("title") </font><font size="2"><span style="background: rgb(255,238,98)">%&gt;
</span>            <span style="color: rgb(0,0,255)">&lt;/</span><span style="color: rgb(163,21,21)">ItemTemplate</span></font><font size="2"><span style="color: rgb(0,0,255)">&gt;
</span>        <span style="color: rgb(0,0,255)">&lt;/</span><span style="color: rgb(163,21,21)">asp</span><span style="color: rgb(0,0,255)">:</span><span style="color: rgb(163,21,21)">TemplateField</span><span style="color: rgb(0,0,255)">&gt;</span>
        <span style="color: rgb(0,0,255)">&lt;</span><span style="color: rgb(163,21,21)">asp</span><span style="color: rgb(0,0,255)">:</span><span style="color: rgb(163,21,21)">TemplateField</span> <span style="color: rgb(255,0,0)">HeaderText</span></font><font size="2"><span style="color: rgb(0,0,255)">="Genre"&gt;
</span>            <span style="color: rgb(0,0,255)">&lt;</span><span style="color: rgb(163,21,21)">ItemTemplate</span></font><font size="2"><span style="color: rgb(0,0,255)">&gt;
</span>                <span style="background: rgb(255,238,98)">&lt;%<span style="color: rgb(0,0,255)"></span>#</span> XPath("genre") </font><font size="2"><span style="background: rgb(255,238,98)">%&gt;
</span>            <span style="color: rgb(0,0,255)">&lt;/</span><span style="color: rgb(163,21,21)">ItemTemplate</span></font><font size="2"><span style="color: rgb(0,0,255)">&gt;
</span>        <span style="color: rgb(0,0,255)">&lt;/</span><span style="color: rgb(163,21,21)">asp</span><span style="color: rgb(0,0,255)">:</span><span style="color: rgb(163,21,21)">TemplateField</span><span style="color: rgb(0,0,255)">&gt;</span>
        <span style="color: rgb(0,0,255)">&lt;</span><span style="color: rgb(163,21,21)">asp</span><span style="color: rgb(0,0,255)">:</span><span style="color: rgb(163,21,21)">TemplateField</span> <span style="color: rgb(255,0,0)">HeaderText</span></font><font size="2"><span style="color: rgb(0,0,255)">="Price"&gt;
</span>            <span style="color: rgb(0,0,255)">&lt;</span><span style="color: rgb(163,21,21)">ItemTemplate</span></font><font size="2"><span style="color: rgb(0,0,255)">&gt;
</span>                <span style="background: rgb(255,238,98)">&lt;%<span style="color: rgb(0,0,255)"></span>#</span> XPath("price") </font><font size="2"><span style="background: rgb(255,238,98)">%&gt;
</span>            <span style="color: rgb(0,0,255)">&lt;/</span><span style="color: rgb(163,21,21)">ItemTemplate</span></font><font size="2"><span style="color: rgb(0,0,255)">&gt;
</span>        <span style="color: rgb(0,0,255)">&lt;/</span><span style="color: rgb(163,21,21)">asp</span><span style="color: rgb(0,0,255)">:</span><span style="color: rgb(163,21,21)">TemplateField</span><span style="color: rgb(0,0,255)">&gt;</span>
        <span style="color: rgb(0,0,255)">&lt;</span><span style="color: rgb(163,21,21)">asp</span><span style="color: rgb(0,0,255)">:</span><span style="color: rgb(163,21,21)">TemplateField</span> <span style="color: rgb(255,0,0)">HeaderText</span></font><font size="2"><span style="color: rgb(0,0,255)">="Publish Date"&gt;
</span>            <span style="color: rgb(0,0,255)">&lt;</span><span style="color: rgb(163,21,21)">ItemTemplate</span></font><font size="2"><span style="color: rgb(0,0,255)">&gt;
</span>                <span style="background: rgb(255,238,98)">&lt;%<span style="color: rgb(0,0,255)"></span>#</span> XPath("publish_date") </font><font size="2"><span style="background: rgb(255,238,98)">%&gt;
</span>            <span style="color: rgb(0,0,255)">&lt;/</span><span style="color: rgb(163,21,21)">ItemTemplate</span></font><font size="2"><span style="color: rgb(0,0,255)">&gt;
</span>        <span style="color: rgb(0,0,255)">&lt;/</span><span style="color: rgb(163,21,21)">asp</span><span style="color: rgb(0,0,255)">:</span><span style="color: rgb(163,21,21)">TemplateField</span><span style="color: rgb(0,0,255)">&gt;</span>
        <span style="color: rgb(0,0,255)">&lt;</span><span style="color: rgb(163,21,21)">asp</span><span style="color: rgb(0,0,255)">:</span><span style="color: rgb(163,21,21)">TemplateField</span> <span style="color: rgb(255,0,0)">HeaderText</span></font><font size="2"><span style="color: rgb(0,0,255)">="Description"&gt;
</span>            <span style="color: rgb(0,0,255)">&lt;</span><span style="color: rgb(163,21,21)">ItemTemplate</span></font><font size="2"><span style="color: rgb(0,0,255)">&gt;
</span>                <span style="background: rgb(255,238,98)">&lt;%<span style="color: rgb(0,0,255)"></span>#</span> XPath("description")</font><font size="2"><span style="background: rgb(255,238,98)">%&gt;
</span>            <span style="color: rgb(0,0,255)">&lt;/</span><span style="color: rgb(163,21,21)">ItemTemplate</span></font><font size="2"><span style="color: rgb(0,0,255)">&gt;
</span>        <span style="color: rgb(0,0,255)">&lt;/</span><span style="color: rgb(163,21,21)">asp</span><span style="color: rgb(0,0,255)">:</span><span style="color: rgb(163,21,21)">TemplateField</span><span style="color: rgb(0,0,255)">&gt;</span>
    <span style="color: rgb(0,0,255)">&lt;/</span><span style="color: rgb(163,21,21)">Columns</span></font><font size="2"><span style="color: rgb(0,0,255)">&gt;
&lt;/</span><span style="color: rgb(163,21,21)">asp</span><span style="color: rgb(0,0,255)">:</span><span style="color: rgb(163,21,21)">GridView</span><span style="color: rgb(0,0,255)">&gt;</span></font>&nbsp;</pre>
<p><font face="Verdana">5. That&#8217;s it! Simply navigate to your newly created page and see the results.</font>
<pre></pre>
]]></content:encoded>
			<wfw:commentRss>http://antonperez.com/2007/06/27/bind-an-xmldatasource-to-a-gridview-control/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
