<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-11070696</id><updated>2011-10-18T19:14:56.242-07:00</updated><category term='SharePoint'/><category term='MOSS'/><category term='ASP.NET 2.0'/><category term='SQL SERVER'/><category term='JavaScript'/><category term='VS.NET'/><category term='WSS 3.0'/><category term='.NET'/><category term='ASP.NET'/><title type='text'>Revived for SharePoint !</title><subtitle type='html'>MOSS 2007, WSS 3.0, SharePoint Server 2010...</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://alvinzc.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://alvinzc.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Alvin Chooi</name><uri>http://www.blogger.com/profile/16063910632877857756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>67</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-11070696.post-6283581063300066873</id><published>2007-01-08T17:34:00.000-08:00</published><updated>2008-11-15T00:45:33.367-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='VS.NET'/><title type='text'>Getting Key Token of a Signed Assembly</title><content type='html'>To obtain the public key token from strong-named and signed assembly, I normally use the Reflector tool to view it. Lately, I discovered that you can get the key token from the Visual Studio.NET IDE tool, too. Here are the steps&lt;br /&gt;&lt;br /&gt;1. Open Visual Studio 2005, click Tools -&gt; External Tools... &lt;br /&gt;2. Click Add and enter the following inputs &lt;br /&gt;&lt;br /&gt;Title: Get Public Key &lt;br /&gt;Command: C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\sn.exe &lt;br /&gt;Arguments: -Tp "$(TargetPath)" &lt;br /&gt;&lt;br /&gt;* Uncheck all options, except Use Output window\ &lt;br /&gt;&lt;br /&gt;After clicking OK, go to the "Get Public Key" in the Tools Menu.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://2.bp.blogspot.com/_wJ88CzqI_WA/RaLzM8TOfSI/AAAAAAAAAA4/-IIJkP6UkpA/s1600-h/toolsmenu.jpg"&gt;&lt;img style="cursor:pointer; cursor:hand;" src="http://2.bp.blogspot.com/_wJ88CzqI_WA/RaLzM8TOfSI/AAAAAAAAAA4/-IIJkP6UkpA/s320/toolsmenu.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5017840338514902306" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;And you would get the public key as well as its token in the OUTPUT WINDOW.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://2.bp.blogspot.com/_wJ88CzqI_WA/RaLzw8TOfUI/AAAAAAAAABI/k8TkG201ebY/s1600-h/output+window.jpg"&gt;&lt;img style="cursor:pointer; cursor:hand;" src="http://2.bp.blogspot.com/_wJ88CzqI_WA/RaLzw8TOfUI/AAAAAAAAABI/k8TkG201ebY/s320/output+window.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5017840956990192962" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11070696-6283581063300066873?l=alvinzc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alvinzc.blogspot.com/feeds/6283581063300066873/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=11070696&amp;postID=6283581063300066873' title='42 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/6283581063300066873'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/6283581063300066873'/><link rel='alternate' type='text/html' href='http://alvinzc.blogspot.com/2007/01/getting-key-token-of-signed-assembly.html' title='Getting Key Token of a Signed Assembly'/><author><name>Alvin Chooi</name><uri>http://www.blogger.com/profile/16063910632877857756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_wJ88CzqI_WA/RaLzM8TOfSI/AAAAAAAAAA4/-IIJkP6UkpA/s72-c/toolsmenu.jpg' height='72' width='72'/><thr:total>42</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11070696.post-3963409180768541642</id><published>2006-12-11T17:00:00.000-08:00</published><updated>2006-12-11T17:07:58.439-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='WSS 3.0'/><title type='text'>ASPMENU Source Code is now available !</title><content type='html'>The underivable AspMenu class that shipped with WSS 3.0 is now unsealed ! The class source code has been released lately to allow developers to extend its functionality. Download the MOSSMenu source code here and you can treat the class as your base class for your own custom menu.&lt;br /&gt;&lt;br /&gt;Check &lt;a href="http://blogs.msdn.com/ecm/archive/2006/12/02/customizing-the-wss-3-0-moss-2007-menu-control-mossmenu-source-code-released.aspx"&gt;Customizing the WSS 3.0/MOSS 2007 Menu Control -- MossMenu source code released&lt;/a&gt; for more information.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11070696-3963409180768541642?l=alvinzc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alvinzc.blogspot.com/feeds/3963409180768541642/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=11070696&amp;postID=3963409180768541642' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/3963409180768541642'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/3963409180768541642'/><link rel='alternate' type='text/html' href='http://alvinzc.blogspot.com/2006/12/aspmenu-source-code-is-now-available.html' title='ASPMENU Source Code is now available !'/><author><name>Alvin Chooi</name><uri>http://www.blogger.com/profile/16063910632877857756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11070696.post-2168749410145639764</id><published>2006-12-11T07:16:00.000-08:00</published><updated>2006-12-11T09:03:30.822-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='WSS 3.0'/><title type='text'>Inflexibility of WSS 3.0 Customization</title><content type='html'>Recently I came across the page customization in WSS 3.0 (Creating new custom page that using application.master under _layouts folder), and I found out that the master page is likely not edited for the company branding purpose because the master page is used and shared by all sites in the WSS v3. Any changes upon the application.master would eventually applied to the rest of the sites too.&lt;br /&gt;&lt;br /&gt;This would be a PAIN for developers where easier customization feature is not ready for them. The very easy and straightforward solutions to the matter that I can think of are:&lt;br /&gt;&lt;br /&gt;1. Clone the application.master and rename it to your own name. Change and apply the custom master page separately.&lt;br /&gt;&lt;br /&gt;2. Develop a custom web control that check current SPSite or SPWeb to change master page accordingly.&lt;br /&gt;&lt;br /&gt;Perhaps, there are more elegant solutions that can resolve this problem.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11070696-2168749410145639764?l=alvinzc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alvinzc.blogspot.com/feeds/2168749410145639764/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=11070696&amp;postID=2168749410145639764' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/2168749410145639764'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/2168749410145639764'/><link rel='alternate' type='text/html' href='http://alvinzc.blogspot.com/2006/12/inflexibility-of-wss-30-customization.html' title='Inflexibility of WSS 3.0 Customization'/><author><name>Alvin Chooi</name><uri>http://www.blogger.com/profile/16063910632877857756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11070696.post-874310977816127593</id><published>2006-12-05T07:06:00.000-08:00</published><updated>2008-11-15T00:45:34.321-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='WSS 3.0'/><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint'/><title type='text'>Installing Custom Group and Actions in WSS/MOSS Features</title><content type='html'>Another customization in WSS/MOSS! You can install your own custom feature other than out-of-box features that offered WSS/MOSS. You can add new actions or menus in any location in WSS/MOSS like Site Settings, Site Actions, Item Context Menu, and etc in Standard Menu.&lt;br /&gt;&lt;br /&gt;By default, there have 5 groups - Look and Feel, Users and Permissions, Gallaries, Site Administration, Site Collection Administration. &lt;br /&gt;&lt;br /&gt;To install new custom feature, create a new folder in C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES. I name the folder as MyCustomGroupAndAction. Then we need to create an XML called feature.xml and another xml file that contains the feature definition. (featuredef.xml)&lt;br /&gt;&lt;br /&gt;Feature.xml has several elements - &amp;lt;Feature&amp;gt;, &amp;lt;ActivationDependencies&amp;gt;, &amp;lt;ElementManifests&amp;gt; and &amp;lt;Properties&amp;gt; but the important ones are :&lt;br /&gt;&lt;br /&gt;1. &lt;em&gt;&amp;lt;Feature&amp;gt; (the root element)&lt;/em&gt; - Defines feature ID, scope (site, collection, etc), description and title.&lt;br /&gt;&lt;br /&gt;2. &lt;em&gt;&amp;lt;ElementManifests&amp;gt;&lt;/em&gt; - defines the feature definition, which links to the xml file that contains the definition.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;u&gt;In feature.xml&lt;/u&gt;&lt;/strong&gt;&lt;br /&gt;&lt;pre class="code"&gt;&lt;br /&gt;&amp;lt;?xml version="1.0" encoding="us-ascii"?&amp;gt;&lt;br /&gt;&amp;lt;Feature  Id="F863C1CF-897D-49c6-8600-7E6F3FC9D653" &lt;br /&gt;                Title="My New Feature" &lt;br /&gt;                Description="This is my new feature"&lt;br /&gt;                Scope="Web" &lt;br /&gt;                xmlns="http://schemas.microsoft.com/sharepoint/"&amp;gt;&lt;br /&gt;    &amp;lt;ElementManifests&amp;gt;&lt;br /&gt;        &amp;lt;ElementManifest Location="featuredef.xml" /&amp;gt;&lt;br /&gt;    &amp;lt;/ElementManifests&amp;gt;&lt;br /&gt;&amp;lt;/Feature&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The &lt;u&gt;ID&lt;/u&gt; of the feature is unique GUID. You need to generate new GUID for each new feature being created. To generate the GUID, you can go to Visual Studio -&amp;gt; Tools Menu -&amp;gt; Create GUID or launch the tool at &lt;em&gt;C:\Program Files\Microsoft Visual Studio 8\Common7\Tools\guidgen.exe.&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://4.bp.blogspot.com/_wJ88CzqI_WA/RX2Gll56FDI/AAAAAAAAAAM/2Gif4v_EUdo/s1600-h/guid.JPG"&gt;&lt;img style="cursor:pointer; cursor:hand;" src="http://4.bp.blogspot.com/_wJ88CzqI_WA/RX2Gll56FDI/AAAAAAAAAAM/2Gif4v_EUdo/s320/guid.JPG" border="0" alt=""id="BLOGGER_PHOTO_ID_5007306341094134834" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The &lt;u&gt;location attribute&lt;/u&gt; of &amp;lt;ElementManifests&amp;gt; specifies the location of feature definiton XML file.&lt;br /&gt;&lt;br /&gt;In featuredef.xml&lt;br /&gt;&lt;pre class="code"&gt;&lt;br /&gt;&amp;lt;?xml version="1.0" encoding="us-ascii"?&amp;gt;&lt;br /&gt;&amp;lt;Elements xmlns="http://schemas.microsoft.com/sharepoint/"&amp;gt;&lt;br /&gt;  &amp;lt;CustomActionGroup&lt;br /&gt;     Id="MyCustomGroup"&lt;br /&gt;     Location="Microsoft.SharePoint.SiteSettings"&lt;br /&gt;     Title="My Custom Group" /&amp;gt;&lt;br /&gt;  &lt;br /&gt; &amp;lt;CustomAction Id="MyCustomFeature"&lt;br /&gt;  GroupId="MyCustomGroup"&lt;br /&gt;  Location="Microsoft.SharePoint.SiteSettings"&lt;br /&gt;  Title="New Custom Feature"&lt;br /&gt;  Sequence="50"&amp;gt;&lt;br /&gt;  &amp;lt;UrlAction Url="_layouts/layoutdesign.aspx"/&amp;gt;&lt;br /&gt; &amp;lt;/CustomAction&amp;gt;&lt;br /&gt;&amp;lt;/Elements&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The &amp;lt;CustomActionGroup&amp;gt; specifies the definition of new group to be created. &lt;u&gt;Location attribute&lt;/u&gt; specifies where the custom group will reside. In this example, "Microsoft.SharePoint.SiteSettings" indicates that the new group will be in the Site Settings menu of WSS sites. Check &lt;a href="http://msdn2.microsoft.com/en-us/library/ms473643.aspx"&gt;Location and Group ID&lt;/a&gt; in MSDN for more information. Text in the &lt;u&gt;Title attribute&lt;/u&gt; is the name of the group.&lt;br /&gt;&lt;br /&gt;&amp;lt;CustomAction&amp;gt; is where the custom feature definition set. The &lt;u&gt;location attribute&lt;/u&gt; MUST BE same as the location being specified in the group that the custom feature points to (in GroupID attribute). &amp;lt;UrlAction&amp;gt; element merely specifies URL of the custom application page.&lt;br /&gt;&lt;br /&gt;It is about to install the feature ! Go to the command prompt, type &lt;br /&gt;&lt;pre class="code"&gt;&lt;br /&gt;C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN&gt;stsadm -o installfeature -name MyCustomGroupAndActions&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The feature has just been installed. However, you need to activate the feature before using it. To activate it, you can type &lt;br /&gt;&lt;pre class="code"&gt;&lt;br /&gt;stsadm -o activatefeature -filename MyFeature/feature.xml -url &amp;lt;server url&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;or &lt;br /&gt;&lt;br /&gt;go to http://&amp;lt;server name&amp;gt;/_layouts/manageFeatures.aspx, and you will see this&lt;br /&gt;&lt;br /&gt;&lt;a href="http://2.bp.blogspot.com/_wJ88CzqI_WA/RX2GxF56FEI/AAAAAAAAAAU/iQnljUHuysg/s1600-h/newfeature.JPG"&gt;&lt;img style="cursor:pointer; cursor:hand;" src="http://2.bp.blogspot.com/_wJ88CzqI_WA/RX2GxF56FEI/AAAAAAAAAAU/iQnljUHuysg/s320/newfeature.JPG" border="0" alt=""id="BLOGGER_PHOTO_ID_5007306538662630466" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Click "Activate" button to activate the feature. Go to "Site Settings" and you will see this&lt;br /&gt;&lt;br /&gt;&lt;a href="http://1.bp.blogspot.com/_wJ88CzqI_WA/RX2G7156FFI/AAAAAAAAAAc/-L5BHzuBQqQ/s1600-h/newgroupfeature.JPG"&gt;&lt;img style="cursor:pointer; cursor:hand;" src="http://1.bp.blogspot.com/_wJ88CzqI_WA/RX2G7156FFI/AAAAAAAAAAc/-L5BHzuBQqQ/s320/newgroupfeature.JPG" border="0" alt=""id="BLOGGER_PHOTO_ID_5007306723346224210" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;You have completed installation of new custom group and feature !!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11070696-874310977816127593?l=alvinzc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alvinzc.blogspot.com/feeds/874310977816127593/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=11070696&amp;postID=874310977816127593' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/874310977816127593'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/874310977816127593'/><link rel='alternate' type='text/html' href='http://alvinzc.blogspot.com/2006/12/installing-custom-group-and-actions-in.html' title='Installing Custom Group and Actions in WSS/MOSS Features'/><author><name>Alvin Chooi</name><uri>http://www.blogger.com/profile/16063910632877857756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_wJ88CzqI_WA/RX2Gll56FDI/AAAAAAAAAAM/2Gif4v_EUdo/s72-c/guid.JPG' height='72' width='72'/><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11070696.post-5701096070818394721</id><published>2006-12-04T06:56:00.000-08:00</published><updated>2006-12-04T07:01:20.343-08:00</updated><title type='text'>Converting String GUID to System.Guid</title><content type='html'>Simple matter. I was trying to convert the GUID in string to type of System.Guid and the code below apparently did not work for me.&lt;br /&gt;&lt;pre class="code"&gt;&lt;br /&gt;System.Guid guid = (System.Guid)strGUIDInString;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;I was given invalid specified cast error message and I noticed that direct casting wasn't the way. I ended up with &lt;br /&gt;&lt;pre class="code"&gt;&lt;br /&gt;System.Guid guid = new System.Guid(strGUIDInString);&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;This was the final solution I could think of, so far !&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11070696-5701096070818394721?l=alvinzc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alvinzc.blogspot.com/feeds/5701096070818394721/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=11070696&amp;postID=5701096070818394721' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/5701096070818394721'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/5701096070818394721'/><link rel='alternate' type='text/html' href='http://alvinzc.blogspot.com/2006/12/converting-string-guid-to-systemguid.html' title='Converting String GUID to System.Guid'/><author><name>Alvin Chooi</name><uri>http://www.blogger.com/profile/16063910632877857756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11070696.post-5384212354163004591</id><published>2006-11-27T07:38:00.000-08:00</published><updated>2006-11-27T07:41:29.472-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='MOSS'/><title type='text'>MOSS 2007 and WSS3 Functional Architecture Diagram</title><content type='html'>Here is the colourful and comprehennsive diagram illustrating the functional architecture of the most latest of Microsoft Office Sharepoint Server 2007 and Windows Sharepoint Services 3.0.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://photos1.blogger.com/x/blogger2/3304/1351/1600/674541/MOSS_Diagram.jpg"&gt;&lt;img style="cursor:pointer; cursor:hand;" src="http://photos1.blogger.com/x/blogger2/3304/1351/320/980880/MOSS_Diagram.jpg" border="0" alt="" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11070696-5384212354163004591?l=alvinzc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alvinzc.blogspot.com/feeds/5384212354163004591/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=11070696&amp;postID=5384212354163004591' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/5384212354163004591'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/5384212354163004591'/><link rel='alternate' type='text/html' href='http://alvinzc.blogspot.com/2006/11/moss-2007-and-wss3-functional.html' title='MOSS 2007 and WSS3 Functional Architecture Diagram'/><author><name>Alvin Chooi</name><uri>http://www.blogger.com/profile/16063910632877857756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11070696.post-9043622320820692205</id><published>2006-11-25T04:58:00.000-08:00</published><updated>2006-11-25T05:04:13.724-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SharePoint'/><title type='text'>Release of WSS RTW and MOSS Standard and Enterprise Edition</title><content type='html'>YOu can download the Release-To-Web version of WSS (Windows SharePoint Services) and Microsoft Office SharePoint Server 2007 Evaluation version at &lt;br /&gt;&lt;br /&gt;1. &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=2e6e5a9c-ebf6-4f7f-8467-f4de6bd6b831&amp;DisplayLang=en"&gt;Microsoft Office SharePoint Server 2007 x86 English Evaluation&lt;/a&gt; &lt;br /&gt;2. &lt;a href="http://www.microsoft.com/technet/windowsserver/sharepoint/download.mspx"&gt;Windows SharePoint Services 3.0&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;CD Keys available for standard and enterprise edition are&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;SharePoint Server Standard Trial:&lt;/strong&gt; XJMKW-8T7PR-76XT6-RTC8G-VVWCQ &lt;br /&gt;&lt;strong&gt;SharePoint Server Enterprise Trial:&lt;/strong&gt; F2JBW-4PDJC-HKXTJ-YCKRP-T2J9D&lt;br /&gt;&lt;br /&gt;For more resources about installation, upgrade, versioning, check this &lt;a href="http://blogs.msdn.com/sharepoint/archive/2006/11/16/announcing-the-rtw-of-wss-and-office-sharepoint-server-2007-standard-and-enterprise-evaluation.aspx"&gt;link&lt;/a&gt;, from Microsoft SharePoint Products and Technologies Team Blog&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11070696-9043622320820692205?l=alvinzc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alvinzc.blogspot.com/feeds/9043622320820692205/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=11070696&amp;postID=9043622320820692205' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/9043622320820692205'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/9043622320820692205'/><link rel='alternate' type='text/html' href='http://alvinzc.blogspot.com/2006/11/release-of-wss-rtw-and-moss-standard.html' title='Release of WSS RTW and MOSS Standard and Enterprise Edition'/><author><name>Alvin Chooi</name><uri>http://www.blogger.com/profile/16063910632877857756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11070696.post-1406269596556276659</id><published>2006-11-23T07:46:00.000-08:00</published><updated>2006-11-23T08:01:20.269-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='JavaScript'/><title type='text'>Efficient String Concatenation in JS</title><content type='html'>In .NET, we use StringBuilder if we need to concatenate strings for better string manipulation performance. For instance,&lt;br /&gt;&lt;pre class="code"&gt;&lt;br /&gt;StringBuilder builder = new StringBuilder();&lt;br /&gt;builder.append("This");&lt;br /&gt;builder.append("is");&lt;br /&gt;builder.append("really");&lt;br /&gt;builder.append("good");&lt;br /&gt;builder.append("for");&lt;br /&gt;builder.append("performance");&lt;br /&gt;  &lt;br /&gt;string str = builder.ToString();&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;In JS, we can also do the same thing for better memory allocation in string concatenation too.&lt;br /&gt;&lt;pre class="code"&gt;&lt;br /&gt;var builder = new Array();&lt;br /&gt;builder.push("This");&lt;br /&gt;builder.push("is");&lt;br /&gt;builder.push("really");&lt;br /&gt;builder.push("good");&lt;br /&gt;builder.push("for");&lt;br /&gt;builder.push("performance");&lt;br /&gt; &lt;br /&gt;var str = builder.join("");&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;This method will perform faster if the number of string concatenation is huge. THe normal += operator will win, otherwise.&lt;br /&gt;&lt;br /&gt;Check &lt;a href="http://dev.opera.com/articles/view/efficient-javascript/"&gt;Efficient JavaScript&lt;/a&gt; for more information on optimizing JS code&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11070696-1406269596556276659?l=alvinzc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alvinzc.blogspot.com/feeds/1406269596556276659/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=11070696&amp;postID=1406269596556276659' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/1406269596556276659'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/1406269596556276659'/><link rel='alternate' type='text/html' href='http://alvinzc.blogspot.com/2006/11/efficient-string-concatenation-in-js.html' title='Efficient String Concatenation in JS'/><author><name>Alvin Chooi</name><uri>http://www.blogger.com/profile/16063910632877857756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11070696.post-9028338112979632917</id><published>2006-11-21T17:24:00.000-08:00</published><updated>2006-11-21T17:38:40.896-08:00</updated><title type='text'>Invoking Executeable File from ASP.NET Web Services</title><content type='html'>Below is the code snippet on how to invoke the executable file (exe) from the cmd.exew being executed.&lt;br /&gt;&lt;pre class="code"&gt;&lt;br /&gt;// Execute the Command Prompt&lt;br /&gt; ProcessStartInfo psi = new ProcessStartInfo("cmd.exe");&lt;br /&gt; &lt;br /&gt;// Indicating the input read from the process's standard input&lt;br /&gt;psi.RedirectStandardInput = true;&lt;br /&gt;psi.UseShellExecute = false;&lt;br /&gt; &lt;br /&gt;// Do not show the GUI of the running app&lt;br /&gt;psi.CreateNoWindow = true;&lt;br /&gt; &lt;br /&gt;Process process = null;&lt;br /&gt;try&lt;br /&gt;{&lt;br /&gt;   // Execute the cmd.exe&lt;br /&gt;   process = Process.Start(psi);&lt;br /&gt; &lt;br /&gt;   StreamWriter writer = process.StandardInput;&lt;br /&gt;             &lt;br /&gt;   // Write the command to the command prompt&lt;br /&gt;   writer.WriteLine("notepad");&lt;br /&gt; &lt;br /&gt;}&lt;br /&gt;catch (Exception ex)&lt;br /&gt;{&lt;br /&gt;  // do something here&lt;br /&gt;}&lt;br /&gt;finally&lt;br /&gt;{&lt;br /&gt;    if (process != null)&lt;br /&gt;    {&lt;br /&gt;                process.Close();&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The code will simply run the notepad from the cmd.exe. You can just call "notepad" from at line the of &lt;span class="code"&gt;ProcessStartInfo psi = new ProcessStartInfo("notepad");&lt;/span&gt;, but I am showing how are you going to write the command to the cmd using the StandardInput of Process object.&lt;br /&gt;&lt;br /&gt;Similarly, you can call batch file from the cmd to execute command in the batch file too, or store those static command in the resource files (resx) inside the app_GlobalResources folder and get from the key by&lt;br /&gt;&lt;pre class="code"&gt;&lt;br /&gt;Resources.&amp;lt;Resource file name&amp;gt;.&amp;lt;key name&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11070696-9028338112979632917?l=alvinzc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alvinzc.blogspot.com/feeds/9028338112979632917/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=11070696&amp;postID=9028338112979632917' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/9028338112979632917'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/9028338112979632917'/><link rel='alternate' type='text/html' href='http://alvinzc.blogspot.com/2006/11/invoking-executeable-file-from-aspnet.html' title='Invoking Executeable File from ASP.NET Web Services'/><author><name>Alvin Chooi</name><uri>http://www.blogger.com/profile/16063910632877857756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11070696.post-3457299855003645441</id><published>2006-11-21T07:39:00.000-08:00</published><updated>2006-11-21T07:42:14.776-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='.NET'/><title type='text'>MSDN Magazine - HTML Help Downloads</title><content type='html'>If you want to read MSDN Magazine contents wherever you are, you can download the dozens of MSDN Magazine in portable chm format at &lt;a href="http://msdn.microsoft.com/msdnmag/htmlhelp.aspx"&gt;http://msdn.microsoft.com/msdnmag/htmlhelp.aspx&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11070696-3457299855003645441?l=alvinzc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alvinzc.blogspot.com/feeds/3457299855003645441/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=11070696&amp;postID=3457299855003645441' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/3457299855003645441'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/3457299855003645441'/><link rel='alternate' type='text/html' href='http://alvinzc.blogspot.com/2006/11/msdn-magazine-html-help-downloads.html' title='MSDN Magazine - HTML Help Downloads'/><author><name>Alvin Chooi</name><uri>http://www.blogger.com/profile/16063910632877857756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11070696.post-3796982723169939469</id><published>2006-11-21T05:59:00.000-08:00</published><updated>2006-11-21T06:40:19.064-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET 2.0'/><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET'/><title type='text'>Use of ResolveClientUrl() method in getting browser-acceptable relative URL</title><content type='html'>In .NET, we always use tilde (~) to refer to root virtual directory of the web application. For instance, &lt;br /&gt;&lt;pre class="code"&gt;&lt;br /&gt;&amp;lt;asp:Image runat="server" ImageUrl="~/images/mypic.gif" /&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;However, in order to generate a URL that can be used by client-side browser, the URL is actually resolved in the AddAttributesToRender() of the Image server control.&lt;br /&gt;&lt;pre class="code"&gt;&lt;br /&gt;writer.AddAttribute(HtmlTextWriterAttribute.Src, ResolveUrl(ImageUrl));&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;That is the reason why you can use "~" in the ImageUrl property. But I afraid this might be the case if you do the same thing upon the normal HTML elements or HtmlGenericControl, such as :&lt;br /&gt;&lt;pre class="code"&gt;&lt;br /&gt;&amp;lt;img src="~/images/mypic.gif" alt="" /&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;because the browser does not recognise what the "~" symbol stands for. In order to workaround with that, this is where the ResolveClientUrl() method comes into place.&lt;br /&gt;&lt;pre class="code"&gt;&lt;br /&gt;&amp;lt;img src='&amp;lt;%= ResolveClientUrl("~/images/mypic.gif") %&amp;gt;' /&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Apart from using it in HTML, it can also be used in code-behind that involves in getting the relative path for the URL. For instance, ResolveClientUrl() method is handy when we are trying to register the javascript reference in code-behind,&lt;br /&gt;&lt;pre class="code"&gt;&lt;br /&gt;this.Page.ClientScript.RegisterClientScriptInclude(this.GetType(),"MyScript", this.ResolveClientUrl("~/images/myscript.js"));&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Not only that, you will always need this method in your custom server control development.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11070696-3796982723169939469?l=alvinzc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alvinzc.blogspot.com/feeds/3796982723169939469/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=11070696&amp;postID=3796982723169939469' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/3796982723169939469'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/3796982723169939469'/><link rel='alternate' type='text/html' href='http://alvinzc.blogspot.com/2006/11/use-of-resolveclienturl-method-in.html' title='Use of ResolveClientUrl() method in getting browser-acceptable relative URL'/><author><name>Alvin Chooi</name><uri>http://www.blogger.com/profile/16063910632877857756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11070696.post-4970085379016368915</id><published>2006-11-02T07:33:00.000-08:00</published><updated>2006-11-02T08:38:37.103-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='JavaScript'/><category scheme='http://www.blogger.com/atom/ns#' term='VS.NET'/><title type='text'>Debugging JS in VS 2005 using Script Explorer</title><content type='html'>Breakpoint is one of the useful features available in Visual Studio 2003/2005 to allow developers to trace the current value of variable at the location where the debugger is currently running at. Nevertheless, you can set any breakpoint in the code-behind of the aspx page, but not in declaractive page. No particular client-side javascript function codes can simply be set as breakpoint in Visual Studio.&lt;br /&gt;&lt;br /&gt;I rarely debug the client-side JS codes, or I can say NEVER! I have tried to debug it using Script Explorer today and it impressed me. To debug the client-side JavaScript functions, you can use the only-visible-in-debugging-environment Script Explorer in Visual Studio 2003/2005. There are few steps need to be followed:&lt;br /&gt;&lt;br /&gt;1. &lt;u&gt;Enable Client-side Script Debugging&lt;/u&gt;&lt;br /&gt;&lt;br /&gt;IE -&gt; Tools Menu -&gt; Options Menu -&gt; Advanced Tab -&gt; Untick " Disable script debugging check box" in Browsing category.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://photos1.blogger.com/blogger2/3304/1351/1600/enabledebugging.png"&gt;&lt;img style="cursor:pointer; cursor:hand;" src="http://photos1.blogger.com/blogger2/3304/1351/320/enabledebugging.png" border="0" alt="" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;2. In VS environment, &lt;u&gt;write a simple JS function in external functions.js&lt;/u&gt;&lt;br /&gt;&lt;pre class="code"&gt;&lt;br /&gt;function MyLoad(name)&lt;br /&gt;{&lt;br /&gt;   var message = "Welcome, " + name;&lt;br /&gt;   alert(message);            &lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Then, invoke the function in body's load() event in ASPX page.&lt;br /&gt;&lt;pre class="code"&gt;&lt;br /&gt;window.onload = MyLoad("Alvin");&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;3. &lt;u&gt;Press F5&lt;/u&gt; to debug the page. In debug mode, go to Debug Menu-&gt;Windows-&gt; Script Explorer (this option only appears in debug mode). The window of Script Explorer will be shown.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://photos1.blogger.com/blogger2/3304/1351/1600/script_explorer.png"&gt;&lt;img style="cursor:pointer; cursor:hand;" src="http://photos1.blogger.com/blogger2/3304/1351/320/script_explorer.png" border="0" alt="" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;4. Once you debugging the page, you will see &lt;u&gt;list of JS files/resources shown in Script Explorer in tree view.&lt;/u&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://photos1.blogger.com/blogger2/3304/1351/1600/SE_Window.jpg"&gt;&lt;img style="cursor:pointer; cursor:hand;" src="http://photos1.blogger.com/blogger2/3304/1351/320/SE_Window.jpg" border="0" alt="" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;u&gt;Double click the "functions.js" and set the breakpoint at particular line.&lt;/u&gt; The debugger will stop at that line when it passing through it.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://photos1.blogger.com/blogger2/3304/1351/1600/debugger.jpg"&gt;&lt;img style="cursor:pointer; cursor:hand;" src="http://photos1.blogger.com/blogger2/3304/1351/320/debugger.jpg" border="0" alt="" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Additionals&lt;/strong&gt;&lt;br /&gt;If your javascript functions are in the aspx page, you can add breakpoint by &lt;br /&gt;&lt;br /&gt;Debug Menu -&gt; "Add Breakpoint" -&gt; "Break At Function" -&gt; type your method name there and choose right language.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://photos1.blogger.com/blogger2/3304/1351/1600/addbreakpoint.jpg"&gt;&lt;img style="cursor:pointer; cursor:hand;" src="http://photos1.blogger.com/blogger2/3304/1351/320/addbreakpoint.jpg" border="0" alt="" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Read more in MSDN&lt;/strong&gt;&lt;br /&gt;1. &lt;a href="http://msdn2.microsoft.com/en-us/library/z959x58c.aspx"&gt;How to: Debug a Client-Side Script from Microsoft Internet Explorer&lt;/a&gt;&lt;br /&gt;2. &lt;a href="http://msdn2.microsoft.com/en-us/library/k2h50zzs.aspx"&gt;How to: Enable Client-Side Script Debugging&lt;/a&gt;&lt;br /&gt;3. &lt;a href="http://msdn2.microsoft.com/en-us/library/15d1wtaf.aspx"&gt;How to: Set a Function Breakpoint&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;I need a break....&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11070696-4970085379016368915?l=alvinzc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alvinzc.blogspot.com/feeds/4970085379016368915/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=11070696&amp;postID=4970085379016368915' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/4970085379016368915'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/4970085379016368915'/><link rel='alternate' type='text/html' href='http://alvinzc.blogspot.com/2006/11/debugging-js-in-vs-2005-using-script.html' title='Debugging JS in VS 2005 using Script Explorer'/><author><name>Alvin Chooi</name><uri>http://www.blogger.com/profile/16063910632877857756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11070696.post-8001801596739456827</id><published>2006-10-31T04:21:00.000-08:00</published><updated>2006-10-31T04:36:46.584-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET 2.0'/><title type='text'>Accessing GridView's DataControlFieldCell Programmatically</title><content type='html'>How would you access the auto-generated control in the HyperLinkField (HyperLink control) and ButtonField (LinkButton or Button control) in RowDataBound event ? You will find out that FindControl() method would no longer be working since there is no concrete ID is assigned to the control, and you are not intelligent enough to know what ID will be assigned automatically by the compiler. There are two workarounds, in which the second one is new in ASP.NET 2.0.&lt;br /&gt;&lt;br /&gt;Assuming that the HyperLinkField is at 4th column.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;First Workaround&lt;/strong&gt;&lt;pre class="code"&gt;&lt;br /&gt;protected void GridView1_RowDataBound(object sender, &lt;br /&gt;GridViewRowEventArgs e) &lt;br /&gt;{ &lt;br /&gt;    if (e.Row.RowType == DataControlRowType.DataRow) &lt;br /&gt;    { &lt;br /&gt;         HyperLink hl = e.Row.Cells[3].Controls[0] as HyperLink;&lt;br /&gt;         hl.Text = "Changing Text here";&lt;br /&gt;    } &lt;br /&gt;} &lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;This workaround is pretty straightward. Cells[3] refers to 4th column (index starting from 0) ; Controls[0] means the first control in that column, which is HyperLink control.&lt;br /&gt;&lt;br /&gt;The first workaround is apparently classic way that we used in DataGrid control. But here is the another workaround, which works in different way !&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Second Workaround&lt;/strong&gt;&lt;pre class="code"&gt;&lt;br /&gt;protected void GridView1_RowDataBound(object sender, &lt;br /&gt;GridViewRowEventArgs e) &lt;br /&gt;    { &lt;br /&gt;        if (e.Row.RowType == DataControlRowType.DataRow) &lt;br /&gt;        { &lt;br /&gt;            DataControlFieldCell dField = e.Row.Cells[3] as &lt;br /&gt;DataControlFieldCell; &lt;br /&gt;            &lt;strong&gt;HyperLinkField&lt;/strong&gt; hlf = dField.ContainingField as HyperLinkField; &lt;br /&gt;            hlf.Text = "Changing Text here"; &lt;br /&gt;            hlf.DataNavigateUrlFormatString = "nextpage.aspx?id={0}";            &lt;br /&gt;        } &lt;br /&gt;    } &lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;As you can see, I am accessing the HyperLinkField itself, and I am able to assign the DataNavigateUrlFormatString property in the RowDataBound event too. Of course, if you would like to access the control in that field, it can be done by&lt;br /&gt;&lt;pre class="code"&gt;&lt;br /&gt;HyperLink hl = dField.Controls[0] as HyperLink;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Hope this helps...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11070696-8001801596739456827?l=alvinzc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alvinzc.blogspot.com/feeds/8001801596739456827/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=11070696&amp;postID=8001801596739456827' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/8001801596739456827'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/8001801596739456827'/><link rel='alternate' type='text/html' href='http://alvinzc.blogspot.com/2006/10/accessing-gridviews-datacontrolfieldcel.html' title='Accessing GridView&apos;s DataControlFieldCell Programmatically'/><author><name>Alvin Chooi</name><uri>http://www.blogger.com/profile/16063910632877857756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11070696.post-198132644673797317</id><published>2006-10-31T02:05:00.000-08:00</published><updated>2006-10-31T02:37:24.025-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL SERVER'/><title type='text'>SQL Server Connection Timeout !</title><content type='html'>Frustrated ! I was given an error message of "Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding." when I was trying to connect to SQL Server 2000 with VS 2005. The connection string was correct and I tried several connection strings :&lt;br /&gt;&lt;pre class="code"&gt;&lt;br /&gt;1. Server=ALVIN;Initial Catalog=pubs;UID=sa;&lt;br /&gt;2. Server=ALVIN;uid=sa; database=pubs";&lt;br /&gt;3. packet size=4096;user id=sa;data source=ALVIN;persist security info=False;database=pubs&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;em&gt;(I used sa account for simplication, don't use it in your production site)&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;But none of them worked for me. I tried it in VS 2003 and unbelievably it worked! (Don't say there is any discrimination) What the heck.. Without any patience left, I saught the answer from Google and I got this link at &lt;a href="http://msdn2.microsoft.com/en-gb/library/ms190181.aspx"&gt;http://msdn2.microsoft.com/en-gb/library/ms190181.aspx&lt;/a&gt;. It explains several causes of the problem, but one of them seemingly is the cause of my problem, which is :&lt;br /&gt;&lt;br /&gt;&lt;em&gt;"Database Engine is not listening on port 1433 because it has been changed, or because it is not the default instance, and the SQL Server Browser service is not running."&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;I tried to go to &lt;strong&gt;Client Network Utility&lt;/strong&gt; and &lt;strong&gt;Server Network Utility&lt;/strong&gt; to change my port number of TCP/IP to 1433 AND reorder it to be the first before the "Named Pipes". &lt;br /&gt;&lt;br /&gt;&lt;a href="http://photos1.blogger.com/blogger2/3304/1351/1600/clientutility.jpg"&gt;&lt;img style="cursor:pointer; cursor:hand;" src="http://photos1.blogger.com/blogger2/3304/1351/320/clientutility.jpg" border="0" alt="" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;After restarting the SQL Server, it eventually went fine for me. :)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11070696-198132644673797317?l=alvinzc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alvinzc.blogspot.com/feeds/198132644673797317/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=11070696&amp;postID=198132644673797317' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/198132644673797317'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/198132644673797317'/><link rel='alternate' type='text/html' href='http://alvinzc.blogspot.com/2006/10/sql-server-connection-timeout.html' title='SQL Server Connection Timeout !'/><author><name>Alvin Chooi</name><uri>http://www.blogger.com/profile/16063910632877857756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11070696.post-609021134164445788</id><published>2006-10-30T07:55:00.000-08:00</published><updated>2006-10-30T08:32:39.180-08:00</updated><title type='text'>New Features of my Blog</title><content type='html'>I have implemented my blogger with new &lt;a href="http://beta.blogger.com/"&gt;Blogger Beta&lt;/a&gt;, and it is pretty amazing. The template in HTML is different from the classic template style. There are some new features added in this blog, such as &lt;u&gt;post count&lt;/u&gt; in the right-hand-side sidebar, new &lt;u&gt;widgets&lt;/u&gt;, new &lt;u&gt;navigation bar&lt;/u&gt;. Other features such as blogs searching will be added soon. Although it is not completely nice, it nears to perfection.&lt;br /&gt;&lt;br /&gt;For those users who use this blogger, you can visit &lt;a href="http://beta.blogger.com/"&gt;http://beta.blogger.com/&lt;/a&gt; for the version switching, or visit these sites for helps.&lt;br /&gt;&lt;br /&gt;1. &lt;a href="http://betabloggerfordummies.blogspot.com/index.html"&gt;http://betabloggerfordummies.blogspot.com/index.html&lt;/a&gt;&lt;br /&gt;2. &lt;a href="http://groups.google.com/group/blogger-help"&gt;http://groups.google.com/group/blogger-help&lt;/a&gt;&lt;br /&gt;3. &lt;a href="http://betabloggerfordummies.blogspot.com/ "&gt;http://betabloggerfordummies.blogspot.com/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Still figuring out its features and specialities....&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11070696-609021134164445788?l=alvinzc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alvinzc.blogspot.com/feeds/609021134164445788/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=11070696&amp;postID=609021134164445788' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/609021134164445788'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/609021134164445788'/><link rel='alternate' type='text/html' href='http://alvinzc.blogspot.com/2006/10/new-features-of-my-blog.html' title='New Features of my Blog'/><author><name>Alvin Chooi</name><uri>http://www.blogger.com/profile/16063910632877857756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11070696.post-116209851773286902</id><published>2006-10-28T22:02:00.000-07:00</published><updated>2006-10-30T08:30:07.682-08:00</updated><title type='text'>Changes on my ValidTextBox Server Control</title><content type='html'>I have made some changes to my ValidTextBox server control. The changes are:&lt;br /&gt;&lt;br /&gt;1. Supports to &lt;u&gt;display error image&lt;/u&gt; instead of text error message when the control is invalid.&lt;br /&gt;2. Supports &lt;u&gt;Tooltips&lt;/u&gt; for error image.&lt;br /&gt;3. Fixed bug of email address expression, which allows symbols.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Screenshots:&lt;/strong&gt;&lt;br /&gt; &lt;br /&gt;&lt;a href="http://img142.imageshack.us/img142/7726/errorimageurloo5.jpg"&gt;&lt;img  src="http://img142.imageshack.us/img142/7726/errorimageurloo5.jpg" border="0" alt="" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://img123.imageshack.us/img123/9940/webnw9.jpg"&gt;&lt;img style="cursor:pointer; cursor:hand;" src="http://img123.imageshack.us/img123/9940/webnw9.jpg" border="0" alt="" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Please check &lt;a href="http://mind.com.my/forums/1018/ShowThread.aspx#1018"&gt;http://mind.com.my/forums/1018/ShowThread.aspx#1018&lt;/a&gt; for more details...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11070696-116209851773286902?l=alvinzc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alvinzc.blogspot.com/feeds/116209851773286902/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=11070696&amp;postID=116209851773286902' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/116209851773286902'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/116209851773286902'/><link rel='alternate' type='text/html' href='http://alvinzc.blogspot.com/2006/10/changes-on-my-validtextbox-server.html' title='Changes on my ValidTextBox Server Control'/><author><name>Alvin Chooi</name><uri>http://www.blogger.com/profile/16063910632877857756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11070696.post-116204094193591751</id><published>2006-10-28T06:08:00.000-07:00</published><updated>2006-10-30T06:55:02.162-08:00</updated><title type='text'>Sample Programming Interview Questions</title><content type='html'>I have found there are a set of interview books, relating to Programming - ".NET Interview Questions", "Java Interview Questions", "SQL Server Interview Questions" and so on. These questions are commonly asked by companies during their interview/recruitment process. You may take a look on sample questions at &lt;a href="http://www.questpond.com/"&gt;http://www.questpond.com/&lt;/a&gt; , which has a lot of sample questions to be downloaded in zip format.&lt;br /&gt;&lt;br /&gt;Some questions are tough!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11070696-116204094193591751?l=alvinzc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alvinzc.blogspot.com/feeds/116204094193591751/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=11070696&amp;postID=116204094193591751' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/116204094193591751'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/116204094193591751'/><link rel='alternate' type='text/html' href='http://alvinzc.blogspot.com/2006/10/sample-programming-interview-questions_28.html' title='Sample Programming Interview Questions'/><author><name>Alvin Chooi</name><uri>http://www.blogger.com/profile/16063910632877857756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11070696.post-116204087764023505</id><published>2006-10-28T06:04:00.000-07:00</published><updated>2006-10-30T06:55:02.083-08:00</updated><title type='text'>[ASP.NET] Building Tag Cloud in ASP.NET</title><content type='html'>What is &lt;strong&gt;Tag Cloud&lt;/strong&gt;. &lt;em&gt;A tag cloud is a way to display a weighted list such that the weight of each item is reflected by the size of the item's text. Tag clouds provide a quick way for one to eyeball a list and ascertain what items are more prevalent.&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;Scott Mitchell has just written an article of &lt;a href="http://aspnet.4guysfromrolla.com/articles/102506-1.aspx"&gt;Creating a Tag Cloud in ASP.NET&lt;/a&gt;. That is very cool especially you are dealing with blogging or tagging-related sites. I have tested it, and that's nothing but COOL !&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11070696-116204087764023505?l=alvinzc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alvinzc.blogspot.com/feeds/116204087764023505/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=11070696&amp;postID=116204087764023505' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/116204087764023505'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/116204087764023505'/><link rel='alternate' type='text/html' href='http://alvinzc.blogspot.com/2006/10/aspnet-building-tag-cloud-in-aspnet.html' title='[ASP.NET] Building Tag Cloud in ASP.NET'/><author><name>Alvin Chooi</name><uri>http://www.blogger.com/profile/16063910632877857756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11070696.post-116179319672900027</id><published>2006-10-25T09:01:00.000-07:00</published><updated>2006-10-30T06:55:01.932-08:00</updated><title type='text'>[ASP.NET] Basic of Custom Server Control Development Part II - ParseChildren(), PersistChildren() and PersistenceMode()</title><content type='html'>Let us boils down to the three attributes that important in implementing simple properties and subproperties in the custom control development - ParseChildrenAttribute, PersistChildrenAttribute and PersistenceModeAttribute.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Default and Inner Property Persistence&lt;/strong&gt;&lt;br /&gt;Default persistence is in constrast to Inner persistence, but they are identically same for its functionality. In our control development, we may have complex properties (class). To persist them, we can use hyphenated syntax (Default Property Persistence) or nesting them within your control tags (Inner Property Persistence). Example of Inner Property Persistence,&lt;br /&gt;&lt;pre class="code"&gt;&lt;br /&gt;&amp;lt;asp:GridView ID="GridView1" runat="server"&amp;gt;&lt;br /&gt;     &amp;lt;HeaderStyle BorderWidth="12" /&amp;gt;&lt;br /&gt;&amp;lt;/asp:GridView&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;In the example given, the BorderWidth is the subproperties of the HeaderStyle property of GridView. To enable this inner property persistence, you need to set the ParseChildren(true) and PersistChildren(false) in your control class.&lt;br /&gt;&lt;pre class="code"&gt;&lt;br /&gt;[ParseChildren(true)]&lt;br /&gt;[PersistChildren(false)]&lt;br /&gt;public class MyWebControl : WebControl&lt;br /&gt;{ &lt;br /&gt;  ... &lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;1. ParseChildrenAttribute&lt;/strong&gt;&lt;br /&gt;This attribute tells the parser to parse the parse the contents within the control tag as properties but not child controls.&lt;br /&gt;&lt;br /&gt;To enable the inner default property persistence, you have to specify the inner default property to the second parameter of ParseChildrenAttribute. &lt;br /&gt;&lt;pre class="code"&gt;&lt;br /&gt;[ParseChildren(true, "&amp;lt;DefaultPropertyName&amp;gt;")]&lt;br /&gt;public class MyControl : WebControl &lt;br /&gt;{ &lt;br /&gt;  ... &lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;2. PersistChildrenAttribute&lt;/strong&gt;&lt;br /&gt;On the other hand, this attribute tells the designer whether the child controls of the server control should be persisted as inner child controls. Setting to false indicates inner content corresponds to properties but not to child controls.&lt;br /&gt;&lt;br /&gt;* Therefore, the ParseChildrenAttribute and the PersistChildrenAttribute attributes use opposing conventions for the semantics of their argument. Check more difference of these two attributes at &lt;a href="http://dotnet.org.za/justin/archive/2005/03/22/15807.aspx"&gt;Justin Lovell's Blog - The ParseChildren and PersistChildren Attributes&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;3. PersistenceModeAttribute&lt;/strong&gt;&lt;br /&gt;This attribute specifies how the property of server control is persisted declaractively in ASP.NET pages. It has 3 enumerations :&lt;br /&gt;&lt;br /&gt;&lt;u&gt;EncodedInnerDefaultProperty&lt;/u&gt; - Specifies that the property persists as the only inner text of the ASP.NET server control. The property value is HTML encoded. Only a string can be given this designation. &lt;br /&gt;&lt;br /&gt;&lt;u&gt;InnerDefaultProperty&lt;/u&gt; - Specifies that the property persists in the ASP.NET server control as inner text. Also indicates that this property is defined as the element's default property. Only one property can be designated the default property. &lt;br /&gt;&lt;br /&gt;&lt;u&gt;InnerProperty&lt;/u&gt; - Specifies that the property persists in the ASP.NET server control as a nested tag. This is commonly used for complex objects, those that have persistable properties of their own.&lt;br /&gt;&lt;br /&gt;Picked from &lt;a href="http://msdn2.microsoft.com/en-us/library/system.web.ui.persistencemode.aspx"&gt;http://msdn2.microsoft.com/en-us/library/system.web.ui.persistencemode.aspx&lt;/a&gt;&lt;br /&gt;&lt;pre class="code"&gt;&lt;br /&gt;[PersistenceMode(PersistenceMode.InnerProperty)]&lt;br /&gt;public virtual TableItemStyle HeaderStyle { ... }&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;This indicates that the designer to persist the property as inner property. By default, it is persisted by using hyphenated syntax in control tag. To persist inner default property, you need to have&lt;br /&gt;&lt;pre class="code"&gt;&lt;br /&gt;[ParseChildren(true, "&amp;lt;DefaultPropertyName&amp;gt;")]&lt;br /&gt;public class MyControl : WebControl &lt;br /&gt;{ &lt;br /&gt;  ... &lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;and &lt;br /&gt;&lt;pre class="code"&gt;&lt;br /&gt;[PersistenceMode(PersistenceMode.InnerDefaultProperty)]&lt;br /&gt;public virtual ListItemCollection Items { ... }&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;These three attributes are confusing, but are not undifferentiable.&lt;strong&gt;&lt;/strong&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11070696-116179319672900027?l=alvinzc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alvinzc.blogspot.com/feeds/116179319672900027/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=11070696&amp;postID=116179319672900027' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/116179319672900027'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/116179319672900027'/><link rel='alternate' type='text/html' href='http://alvinzc.blogspot.com/2006/10/aspnet-basic-of-custom-server-control_25.html' title='[ASP.NET] Basic of Custom Server Control Development Part II - ParseChildren(), PersistChildren() and PersistenceMode()'/><author><name>Alvin Chooi</name><uri>http://www.blogger.com/profile/16063910632877857756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11070696.post-116162374960199897</id><published>2006-10-23T10:11:00.000-07:00</published><updated>2006-10-30T06:55:01.822-08:00</updated><title type='text'>My ValidTextBox is OUT !</title><content type='html'>After spending 3 days of custom control development, I have successfully developed the beta-period ValidTextBox server control. It basically  integrates validator controls (RegularExpressionValidator and RequiredFieldValidator) and normal textbox control to reduce the developers' time and efforts. Here are some screenshots of the ValidTextBox server control.&lt;br /&gt;&lt;br /&gt;&lt;img src="http://img200.imageshack.us/img200/9945/webvssf6.jpg" width="100%" alt=""/&gt;&lt;br /&gt;&lt;br /&gt;&lt;img src="http://img317.imageshack.us/img317/7876/propertiessw4.jpg"/&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Check more about the ValidTextBox server control at &lt;a href="http://mind.com.my/forums/ShowThread.aspx?PostID=1015#1015"&gt;MIND Forum here&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11070696-116162374960199897?l=alvinzc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alvinzc.blogspot.com/feeds/116162374960199897/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=11070696&amp;postID=116162374960199897' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/116162374960199897'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/116162374960199897'/><link rel='alternate' type='text/html' href='http://alvinzc.blogspot.com/2006/10/my-validtextbox-is-out.html' title='My ValidTextBox is OUT !'/><author><name>Alvin Chooi</name><uri>http://www.blogger.com/profile/16063910632877857756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11070696.post-116148666722942335</id><published>2006-10-21T20:03:00.000-07:00</published><updated>2006-10-30T06:55:01.748-08:00</updated><title type='text'>[ASP.NET] All About Dynamic Server Controls</title><content type='html'>If you want have a more-in-depth reading on the dynamic server controls in ASP.NET, you not gonna to miss these :&lt;br /&gt;&lt;br /&gt;1. &lt;a href="http://aspnet.4guysfromrolla.com/articles/082102-1.aspx"&gt;Working with Dynamically-Created Controls [4GuysFromRolla]&lt;/a&gt;&lt;br /&gt;2. &lt;a href="http://aspnet.4guysfromrolla.com/articles/081402-1.aspx"&gt;Dynamic Controls in ASP.NET [4GuysFromRolla]&lt;/a&gt;&lt;br /&gt;3. &lt;a href="http://aspnet.4guysfromrolla.com/articles/092904-1.aspx"&gt;Dynamic Web Controls, Postbacks, and View State&lt;/a&gt; &lt;br /&gt;4. &lt;a href="http://weblogs.asp.net/infinitiesloop/archive/2006/08/25/TRULY-Understanding-Dynamic-Controls-_2800_Part-1_2900_.aspx"&gt;TRULY Understanding Dynamic Controls (Part 1) - Dynamic vs Static &lt;/a&gt;&lt;br /&gt;5. &lt;a href="http://weblogs.asp.net/infinitiesloop/archive/2006/08/30/TRULY-Understanding-Dynamic-Controls-_2800_Part-2_2900_.aspx"&gt;TRULY Understanding Dynamic Controls (Part 2) - Dynamic Controls&lt;/a&gt;&lt;br /&gt;6. &lt;a href="http://weblogs.asp.net/infinitiesloop/archive/2006/08/30/TRULY-Understanding-Dynamic-Controls-_2800_Part-3_2900_.aspx"&gt;TRULY Understanding Dynamic Controls (Part 3)  - Adding Controls to Control Tree&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11070696-116148666722942335?l=alvinzc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alvinzc.blogspot.com/feeds/116148666722942335/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=11070696&amp;postID=116148666722942335' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/116148666722942335'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/116148666722942335'/><link rel='alternate' type='text/html' href='http://alvinzc.blogspot.com/2006/10/aspnet-all-about-dynamic-server.html' title='[ASP.NET] All About Dynamic Server Controls'/><author><name>Alvin Chooi</name><uri>http://www.blogger.com/profile/16063910632877857756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11070696.post-116131208409601014</id><published>2006-10-19T19:24:00.000-07:00</published><updated>2006-10-30T06:55:01.676-08:00</updated><title type='text'>[ASP.NET 2.0] Post-Cache Substitution</title><content type='html'>Post-Cache Substitution, a new feature that is not so eye-catching compared to the other new features introduced in ASP.NET 2.0 like Master Pages, Personalization, DataSource Control and etc. Basically, Post-Cache Substitution allows developers dynamically update the contents of output-cached portions (eg. header, footer). When a header user control (header.ascx) is given the following directive&lt;br /&gt;&lt;pre class="code"&gt;&lt;br /&gt;&amp;lt;%@ OutputCache Duration=3600 VaryByParam=none %&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;It tells the page to be partially cached for an hour (3600 seconds). If there is current date and time showing in the header section, it is unlikely that the time will be updated for every second since it is cached for an hour long.&lt;br /&gt;&lt;br /&gt;There are common 2 ways of implementation of Post-Cache Substitution solves this problem for you - Use of &lt;u&gt;Substitution Control&lt;/u&gt; and &lt;u&gt;Substitution API.&lt;/u&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;u&gt;1. Substitution Control&lt;/u&gt;&lt;/strong&gt;&lt;br /&gt;This control tells the page not to cache the section for its dynamic contents. Every contents in the control would not be cached. &lt;br /&gt;&lt;br /&gt;1. To use this control, drag the Substitution Control from VS 2005's ToolBox and drop it onto your WebForm. &lt;br /&gt;&lt;br /&gt;2. The control has a &lt;strong&gt;MethodName&lt;/strong&gt; property, which is assigned to a static method. In the code-behind, define a static method that accepting a page context as parameter.&lt;br /&gt;&lt;pre class="code"&gt;&lt;br /&gt;public static string GetCurrentDateTime(HttpContext context)&lt;br /&gt;{&lt;br /&gt;      return DateTime.Now.ToLongTimeString ();&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;3. Back to Design View. In the control's property window, assign GetCurrentDateTime to &lt;strong&gt;MethodName&lt;/strong&gt; property. This ascertains that subsequent requests to the page call the method again to generate dynamic content.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;u&gt;&lt;strong&gt;2. Substitution API&lt;/strong&gt;&lt;/u&gt;&lt;br /&gt;This implementation uses the in-lline code, by calling the &lt;strong&gt;Response.WriteSubstitution()&lt;/strong&gt; method that accepting name of method as parameter. Thus, in your ASPX HTML view, add this &lt;br /&gt;&lt;pre class="code"&gt;&lt;br /&gt;&amp;lt;% Response.WriteSubstitution(new HttpResponseSubstitutionCallback(GetCurrentTime)); %&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;It would change client-side cacheability to server cacheability, which the dynamic contents are not cached on clients.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11070696-116131208409601014?l=alvinzc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alvinzc.blogspot.com/feeds/116131208409601014/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=11070696&amp;postID=116131208409601014' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/116131208409601014'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/116131208409601014'/><link rel='alternate' type='text/html' href='http://alvinzc.blogspot.com/2006/10/aspnet-20-post-cache-substitution.html' title='[ASP.NET 2.0] Post-Cache Substitution'/><author><name>Alvin Chooi</name><uri>http://www.blogger.com/profile/16063910632877857756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11070696.post-116122781706748198</id><published>2006-10-18T20:10:00.000-07:00</published><updated>2006-10-30T06:55:01.608-08:00</updated><title type='text'>[ASP.NET] Specifying DefaultButton in MasterPage</title><content type='html'>In normal ASP.NET 2.0, we can easily assign the DefaultButton property in the &lt;br /&gt;&lt;pre class="code"&gt;&lt;br /&gt;&amp;lt;form runat="server" DefaultButton="btnSearch"&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;But what if we would like to make two different buttons from two pages that inheriting the MasterPage to be DefaultButton? It might not be working using the way above because MasterPage because it is publicly shared by its content pages. You, however, have to programmatically assign the DefaultButton in each of the content page.&lt;br /&gt;&lt;br /&gt;In content Page,&lt;br /&gt;&lt;pre class="code"&gt;&lt;br /&gt;this.Form.DefaultButton = "MyDefaultButton";&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;This is not the way of assigning the ID of button to DefaultButton property. Use this way, &lt;br /&gt;&lt;pre class="code"&gt;&lt;br /&gt;this.Form.DefaultButton = &lt;strong&gt;MyDefaultButton.UniqueID&lt;/strong&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Cheeers&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11070696-116122781706748198?l=alvinzc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alvinzc.blogspot.com/feeds/116122781706748198/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=11070696&amp;postID=116122781706748198' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/116122781706748198'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/116122781706748198'/><link rel='alternate' type='text/html' href='http://alvinzc.blogspot.com/2006/10/aspnet-specifying-defaultbutton-in.html' title='[ASP.NET] Specifying DefaultButton in MasterPage'/><author><name>Alvin Chooi</name><uri>http://www.blogger.com/profile/16063910632877857756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11070696.post-116122609990681596</id><published>2006-10-18T19:36:00.000-07:00</published><updated>2006-10-30T06:55:01.533-08:00</updated><title type='text'>[ASP.NET] Redirecting Page after Emiting JS in Code-behind</title><content type='html'>To emit the JavaScript in code-behind in ASP.NET, we use RegisterStartupScript() or RegisterClientScriptBlock() method. But when we would like to redirect user to a specified page after the JS pop-up, we probably would use this (written in VS.NET 2003, use ClientManager for VS 2005)&lt;br /&gt;&lt;pre class="code"&gt;&lt;br /&gt;string strScriptName = "AlertScript";&lt;br /&gt;string strMessage = "There is an error";&lt;br /&gt; &lt;br /&gt;string strScript += strMessage + "')&lt;"&lt;br /&gt;strScript += "/"&lt;br /&gt;strScript += "script&gt;"&lt;br /&gt;&lt;br /&gt;if(!Page.IsStartupScriptRegistered(strScriptName))&lt;br /&gt;     objPage.RegisterStartupScript(strScriptName, strScript)&lt;br /&gt; &lt;br /&gt;&lt;strong&gt;Response.Redirect("error.aspx");&lt;/strong&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;If you run the code, you will notice that you will be redirected to the error.aspx WITHOUT being prompted the error message dialog box of "This is an error" because Response.Redirect() forces the browser not to render the HTML (sending a header to client to cause client to redirect to specified URL).&lt;br /&gt;&lt;br /&gt;To overcome this problem, replace the &lt;strong&gt;Response.Redirect("error.aspx");&lt;/strong&gt; with&lt;br /&gt;&lt;pre class="code"&gt;&lt;br /&gt;Response.AppendHeader("refresh","0;Url='error.aspx'");&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Instead of redirecting the page, the browser would simply refresh the page within 0 second and "redirecting" to the error.aspx, as specified in the Url parameter.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11070696-116122609990681596?l=alvinzc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alvinzc.blogspot.com/feeds/116122609990681596/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=11070696&amp;postID=116122609990681596' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/116122609990681596'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/116122609990681596'/><link rel='alternate' type='text/html' href='http://alvinzc.blogspot.com/2006/10/aspnet-redirecting-page-after-emiting.html' title='[ASP.NET] Redirecting Page after Emiting JS in Code-behind'/><author><name>Alvin Chooi</name><uri>http://www.blogger.com/profile/16063910632877857756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11070696.post-116109333169184040</id><published>2006-10-17T06:44:00.000-07:00</published><updated>2006-10-30T06:55:01.382-08:00</updated><title type='text'>[ASP.NET] Basic of Custom Server Control Development Part I</title><content type='html'>Developing custom server control in ASP.NET is fun! You are flexible to develop it either inheriting the existing ASP.NET server controls like Button, HyperLink, BoundField or create you own control by inheriting Control/WebControl classes from System.Web.UI namespace. There are dozens of cool and fabulous custom server controls developed by third-parties like Metabuilder or ExcentricWorld. I like to develop the custom server control because the tailored controls can specifically accomplish some jobs that normal shipped-in ASP.NET server controls can't. It serves the purpose on your needs.&lt;br /&gt;&lt;br /&gt;There are basic concepts/rules in custom server control development in ASP.NET like :&lt;br /&gt;&lt;br /&gt;1. Derive your control class from &lt;strong&gt;System.Web.UI.Control&lt;/strong&gt; if your control is dealing with non-visual elements or merely render as HTML output. For instance, META tag. Otherwise, your class should inherit from &lt;strong&gt;System.Web.UI.WebControls&lt;/strong&gt; class if your control is built to have visual appearance to the client.&lt;br /&gt;&lt;br /&gt;2. Do not override the &lt;strong&gt;Render()&lt;/strong&gt; method of in your control if it is inheriting from &lt;strong&gt;System.Web.UI.WebControls&lt;/strong&gt; class because the method is responsible in rendering the outer tag and control styling to the output stream. Override its &lt;strong&gt;RenderContent()&lt;/strong&gt; method instead!&lt;br /&gt;&lt;pre class="code"&gt;&lt;br /&gt;protected override void RenderContent(HtmlTextWriter writer)&lt;br /&gt;{&lt;br /&gt;  writer.Write("Test");&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;3. When your control inherting the &lt;strong&gt;System.Web.UI.WebControls&lt;/strong&gt;, its outer tag is &amp;lt;span&amp;gt; by default. You can get rid of this and render any outer tags you want by overriding its &lt;strong&gt;HtmlTextWriterTag.TagKey&lt;/strong&gt; or &lt;strong&gt;TagName&lt;/strong&gt; (non-standard HTML tags).&lt;br /&gt;&lt;pre class="code"&gt;&lt;br /&gt;protected override HtmlTextWriterTag TagKey&lt;br /&gt;{&lt;br /&gt;   get {  return HtmlTextWriterTag.Input; }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;  &lt;br /&gt;or&lt;br /&gt;&lt;pre class="code"&gt;&lt;br /&gt;public Button() : base(HtmlTextWriterTag.Input)&lt;br /&gt;{  }&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;4. Check whether the control is in the &amp;lt;form runat="server"&amp;gt; by&lt;br /&gt;&lt;pre class="code"&gt;&lt;br /&gt;if (Page != null)&lt;br /&gt;    Page.VerifyRenderingInServerForm(this);&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;in either &lt;strong&gt;AddAttributesToRender()&lt;/strong&gt; or &lt;strong&gt;Render()/RenderContent() &lt;/strong&gt;method.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;5. By default, the tag prefix of your custom server control would be auto-generated. For instance, when you drag and drop your control, the tag would be something like&lt;br /&gt;&lt;pre class="code"&gt;&lt;br /&gt;&amp;lt;cc1:CustomMeta ID="CustomMetaTag1" runat="server" /&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;As you see, the "cc1" gives no meaning. You can add your own tag prefix by adding &lt;strong&gt;TagPrefixAttribute&lt;/strong&gt; in the assemblyinfo.cs file. &lt;br /&gt;&lt;pre class="code"&gt;&lt;br /&gt;using System.Web.UI;&lt;br /&gt;[assembly:TagPrefix("SimpleControl", "Alvin")]&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Now, it would become like&lt;br /&gt;&lt;pre class="code"&gt;&lt;br /&gt;&amp;lt;Alvin:CustomMeta ID="CustomMetaTag1" runat="server" /&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;6. Take note of rendering methods of &lt;strong&gt;System.Web.UI.Control&lt;/strong&gt; class&lt;br /&gt;&lt;pre class="code"&gt;&lt;br /&gt;public void RenderControl(HtmlTextWriter writer) {&lt;br /&gt;    if (Visible) {&lt;br /&gt;        Render(writer);&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;protected virtual void Render(HtmlTextWriter writer) {&lt;br /&gt;    RenderChildren(writer);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;protected virtual void RenderChildren(HtmlTextWriter writer) {&lt;br /&gt;    foreach (Control c in Controls) {&lt;br /&gt;        c.RenderControl(writer);&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;It is wise to call the base class's methods if you intend to override the method like &lt;strong&gt;RenderChildren&lt;/strong&gt; method to ensure its child controls are recursively rendered.&lt;br /&gt;&lt;pre class="code"&gt;&lt;br /&gt;protected override void RenderChildren(HtmlTextWriter writer)&lt;br /&gt;{&lt;br /&gt;   base.RenderChildren(writer);&lt;br /&gt;  &lt;br /&gt;   // do your stuff&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;7. To restrict the control to have NO CHILD CONTROLS, you need to return &lt;strong&gt;EmptyControlCollection(this)&lt;/strong&gt; to the overidden &lt;strong&gt;CreateControlCollection()&lt;/strong&gt; method.&lt;br /&gt;&lt;pre class="code"&gt;&lt;br /&gt;protected override ControlCollection CreateControlCollection() {&lt;br /&gt;            return new EmptyControlCollection(this);&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;By doing that, no child controls/tags are allowed. &lt;br /&gt;&lt;pre class="code"&gt;&lt;br /&gt;// Allow&lt;br /&gt;&amp;lt;Alvin:CustomMeta ID="CustomMetaTag1" runat="server" /&amp;gt;&lt;br /&gt;&lt;br /&gt;// Not allow !&lt;br /&gt;&amp;lt;Alvin:CustomMeta ID="CustomMetaTag1" runat="server"&amp;gt;&amp;lt;/Alvin:CustomMeta&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11070696-116109333169184040?l=alvinzc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alvinzc.blogspot.com/feeds/116109333169184040/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=11070696&amp;postID=116109333169184040' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/116109333169184040'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/116109333169184040'/><link rel='alternate' type='text/html' href='http://alvinzc.blogspot.com/2006/10/aspnet-basic-of-custom-server-control.html' title='[ASP.NET] Basic of Custom Server Control Development Part I'/><author><name>Alvin Chooi</name><uri>http://www.blogger.com/profile/16063910632877857756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11070696.post-116089341447331440</id><published>2006-10-14T23:15:00.000-07:00</published><updated>2006-10-30T06:55:01.313-08:00</updated><title type='text'>Go for Google or Microsoft?</title><content type='html'>Cliff, who has been offered by Google and Microsoft is in trouble! He is in hestitation whether to work for Google or Microsoft,  He posted a dicussion topic of &lt;a href="http://ask.slashdot.org/askslashdot/06/10/13/0556241.shtml"&gt;Microsoft or Google?&lt;/a&gt; to ask Slashdot-ers about both companies' working environments and their thought about the companies. It is interesting to see the commenters posted their opinions about Google and Microsoft's working environment, working hours, management styles, pressure, corporate culture, benefits and so on, respectively. &lt;br /&gt;&lt;br /&gt;Google or Microsoft?  Hard to choose even to me.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11070696-116089341447331440?l=alvinzc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alvinzc.blogspot.com/feeds/116089341447331440/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=11070696&amp;postID=116089341447331440' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/116089341447331440'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/116089341447331440'/><link rel='alternate' type='text/html' href='http://alvinzc.blogspot.com/2006/10/go-for-google-or-microsoft.html' title='Go for Google or Microsoft?'/><author><name>Alvin Chooi</name><uri>http://www.blogger.com/profile/16063910632877857756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11070696.post-116083098737603540</id><published>2006-10-14T05:45:00.000-07:00</published><updated>2006-10-30T06:55:01.235-08:00</updated><title type='text'>Tips and Tricks on cloning data-bound controls</title><content type='html'>Here are some tips and tricks on cloning the Data-Bound controls.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;u&gt;Cloning DataGrid/GridView&lt;/u&gt;&lt;/strong&gt;&lt;br /&gt;It is common mistake when you would like to copy the assigned DataGrid's DataSource to another DataGrid's datasource like&lt;br /&gt;&lt;pre class="code"&gt;&lt;br /&gt;DataGrid2.DataSource = (DataSet)DataGrid1.DataSource;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;You would simply get the NullReference exception. It seems work but it doesn't. A better way is store the needed DataSet to Cache or Session and reuse it for subsequent data binding.&lt;br /&gt;&lt;pre class="code"&gt;&lt;br /&gt;Object objDS = Cache["MyDS"];&lt;br /&gt;if(objDS != null)&lt;br /&gt;{&lt;br /&gt;   DataSet ds = (DataSet)objDS;&lt;br /&gt;   DataGrid1.DataSource = ds;&lt;br /&gt;   DataGrid2.DataSource = ds;&lt;br /&gt;}&lt;br /&gt;else&lt;br /&gt;{&lt;br /&gt;   DataSet ds = new DataSet();&lt;br /&gt;   // open conn, fill the DS;&lt;br /&gt;   DataGrid1.DataSource = ds;&lt;br /&gt;   DataGrid2.DataSource = ds;&lt;br /&gt; &lt;br /&gt;   Cache["MyDS"] = ds;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;THERE is another way cloning the content of Grid by rendering its HTML contents to HtmlTextWriter. Try to put this code in the Button's Click event.&lt;br /&gt;&lt;pre class="code"&gt;&lt;br /&gt;StringBuilder strBuilder  = new StringBuilder();&lt;br /&gt;StringWriter writer = new StringWriter();&lt;br /&gt; &lt;br /&gt;HtmlTextWriter textWriter = new HtmlTextWriter(writer);&lt;br /&gt;strBuilder = writer.GetStringBuilder();&lt;br /&gt;dgrdAuthors.RenderControl(textWriter);&lt;br /&gt; &lt;br /&gt;string strContent = strBuilder.ToString();&lt;br /&gt;Response.Write(strContent);&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Once you click the button, the cloned Grid appears. This code is particularly useful especially you would like to send the content of Grid over email.&lt;br /&gt;&lt;br /&gt;&lt;pre class="code"&gt;&lt;br /&gt;.....&lt;br /&gt;objMail.Body = strContent&lt;br /&gt;objMail.BodyFormat = MailFormat.Html&lt;br /&gt;....&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;u&gt;Cloning DropDownList/CheckBoxes/RadioButtonList&lt;/u&gt;&lt;/strong&gt;&lt;br /&gt;How do you make two DropDownLists, which bound to a datasource to have identical items? The very basic method is use of DataSet like&lt;br /&gt;&lt;pre class="code"&gt;&lt;br /&gt;DropDownList1.DataSource = ds;&lt;br /&gt;DropDownList1.DataTextField = "MyText";&lt;br /&gt;DropDownList1.DataValueField = "MyValue";&lt;br /&gt;DropDownList1.DataBind();&lt;br /&gt; &lt;br /&gt;DropDownList2.DataSource = ds;&lt;br /&gt;DropDownList2.DataTextField = "MyText";&lt;br /&gt;DropDownList2.DataValueField = "MyValue";&lt;br /&gt;DropDownList2.DataBind();&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;It works fine. No complain. What if you use forward-only IDataReader for performance wise? You may need to have two IDataReaders for each DDL's data-binding. Here is another trick where only one DataReader is needed.&lt;br /&gt;&lt;pre class="code"&gt;&lt;br /&gt;reader = cmd.ExecuteReader(CommandBehavior.CloseConnection);&lt;br /&gt;DropDownList1.DataSource = reader;&lt;br /&gt;DropDownList1.DataTextField = "MyText";&lt;br /&gt;DropDownList1.DataValueField = "MyValue";&lt;br /&gt;DropDownList1.DataBind();&lt;br /&gt;reader.Close();&lt;br /&gt; &lt;br /&gt;// I am cloning the ListItemCollections of DDL1 to DDL2&lt;br /&gt;DropDownList2.DataSource = DropDownList1.Items;&lt;br /&gt;DropDownList2.DataTextField = "Text";&lt;br /&gt;DropDownList2.DataValueField = "Value";&lt;br /&gt;DropDownList2.DataBind();&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Much simpler, much faster, much neat !&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11070696-116083098737603540?l=alvinzc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alvinzc.blogspot.com/feeds/116083098737603540/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=11070696&amp;postID=116083098737603540' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/116083098737603540'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/116083098737603540'/><link rel='alternate' type='text/html' href='http://alvinzc.blogspot.com/2006/10/tips-and-tricks-on-cloning-data-bound.html' title='Tips and Tricks on cloning data-bound controls'/><author><name>Alvin Chooi</name><uri>http://www.blogger.com/profile/16063910632877857756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11070696.post-116079367884457970</id><published>2006-10-13T19:28:00.000-07:00</published><updated>2006-10-30T06:55:01.122-08:00</updated><title type='text'>Browser DOM Supports and Compatibility Issues</title><content type='html'>I occasionally get some earful from other people how hard to develop an AJAX application. Well, it isn't that hard if you use on-ready AJAX development tools such as Atlas. Nevertheless, you may be cracking your head on writing remote scripting from ground up because there are few issues need to be taken care. &lt;br /&gt;&lt;br /&gt;Other than the checking the types of the browser, you also need to concern about the DOM supports the particular browser can support. For instance, the innerText property of &lt; span &gt; is not supported in FireFox, you have to use textContent property or universal supported innerHTML property. Here are the listing of sites that you may need to check the DOM that the layout engines in each browser can support.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Links&lt;/strong&gt;&lt;br /&gt;1. Web browser HTML support&lt;br /&gt;&lt;a href="http://www.webdevout.net/browser_support_html.php"&gt;http://www.webdevout.net/browser_support_html.php&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;2. Web browser DOM support&lt;br /&gt;&lt;a href="http://www.webdevout.net/browser_support_dom.php"&gt;http://www.webdevout.net/browser_support_dom.php&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;3. DOM Support in Mozilla&lt;br /&gt;&lt;a href="http://www.mozilla.org/docs/dom/mozilla/"&gt;http://www.mozilla.org/docs/dom/mozilla/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;4. Comparison of layout engines (DOM)&lt;br /&gt;&lt;a href="http://en.wikipedia.org/wiki/Comparison_of_layout_engines_%28DOM%29"&gt;http://en.wikipedia.org/wiki/Comparison_of_layout_engines_%28DOM%29&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;5. Common Differences Among IE and Mozilla&lt;br /&gt;&lt;a href="http://www.htmlgoodies.com/primers/jsp/article.php/3624446"&gt;http://www.htmlgoodies.com/primers/jsp/article.php/3624446&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11070696-116079367884457970?l=alvinzc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alvinzc.blogspot.com/feeds/116079367884457970/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=11070696&amp;postID=116079367884457970' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/116079367884457970'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/116079367884457970'/><link rel='alternate' type='text/html' href='http://alvinzc.blogspot.com/2006/10/browser-dom-supports-and-compatibility.html' title='Browser DOM Supports and Compatibility Issues'/><author><name>Alvin Chooi</name><uri>http://www.blogger.com/profile/16063910632877857756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11070696.post-116076486935549512</id><published>2006-10-13T11:37:00.000-07:00</published><updated>2006-10-30T06:55:01.036-08:00</updated><title type='text'>[ASP.NET] Serializing/Deserializing Passing Objects Across Pages with LosFormatter</title><content type='html'>On our ordinary basis, we pass the values or object values across two pages using Session, Form Posting, PreviousPage reference in ASP.NET. But however, we could not able to append the object to the query string (unless you use the Session state instead). There is another alternative way - passing the serialized the object values into string presentation in query string.&lt;br /&gt;&lt;br /&gt;How ?? First of all, are you familiar with this ?&lt;br /&gt;&lt;br /&gt;&lt;pre class="code"&gt;&lt;br /&gt;&lt; input type="hidden" name="__VIEWSTATE" value="dDwxMzIwMTI1MjYwO3Q8O2w8aTwxPjs+O2w8dDw7bDx&lt;br /&gt;pPDE+Oz47bDx0PHA8cDxsPE5hdmlnYXRlVXJsOz47b&lt;br /&gt;DxXZWJmb3JtMi5hc3B4P3ZhbHVlPWJEeDBhR2x6T3o&lt;br /&gt;0PTs+Pjs+Ozs+Oz4+Oz4+Oz5RXn3JAFz8V0ozE1lmu&lt;br /&gt;5B1K2D7xw==" / &gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;If you do, that's good. It is ViewState, the hidden field that stores control state, which the &lt;u&gt;state values (eg. object values, primitive type values) are serialized and deserialized into base-64 string using LosFormatter&lt;/u&gt;. Similarly, this approach can be used to serialize the object and pass it to the next page in query string. &lt;br /&gt;&lt;br /&gt;The following example shows you how to pass the serialized ArrayList to the next page using LosFormatter.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Code&lt;/strong&gt;&lt;br /&gt;&lt;em&gt;Firstpage.aspx&lt;/em&gt;&lt;br /&gt;&lt;pre class="code"&gt;&lt;br /&gt;System.IO;&lt;br /&gt;System.Collections;&lt;br /&gt;&lt;br /&gt;private void Page_Load(Object sender, EventArgs e)&lt;br /&gt;{&lt;br /&gt;   ArrayList ary = new ArrayList();&lt;br /&gt;   ary.Add("this");&lt;br /&gt;&lt;br /&gt;   System.Web.UI.LosFormatter formatter = new System.Web.UI.LosFormatter();&lt;br /&gt;   StringWriter writer = new StringWriter();&lt;br /&gt;&lt;br /&gt;   formatter.Serialize(writer,ary);&lt;br /&gt;   HyperLink1.NavigateUrl = "secondpage.aspx?value=" + writer.ToString();&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Check the URL in the HyperLink control in Firstpage.aspx, it would be something like &lt;br /&gt;&lt;pre class="code"&gt;&lt;br /&gt;http://localhost/WebTest/secondpage.aspx?value=bDx0aGlzOz4=&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The ArrayList object has just been serialized ! How to deserialize the object back? &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;em&gt;Secondpage.aspx&lt;/em&gt;&lt;br /&gt;&lt;pre class="code"&gt;&lt;br /&gt;System.IO;&lt;br /&gt;System.Collections;&lt;br /&gt;&lt;br /&gt;private void Page_Load(Object sender, EventArgs e)&lt;br /&gt;{&lt;br /&gt;   System.Web.UI.LosFormatter formatter = new System.Web.UI.LosFormatter();&lt;br /&gt;   ArrayList aryL = (ArrayList)formatter.Deserialize(Request.QueryString["value"]);&lt;br /&gt;&lt;br /&gt;   Response.Write(aryL[0]);&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;em&gt;* Be noted, you need to explicitly specify the System.Web.UI.LosFormatter in the object instantiation. You will get the undefined Serialize()/Deserialize() method, otherwise. Watch out the number of characters supported in the URL. Not all objects are suitable to be serialized, only relatively small-size objects are appropriate to do so. &lt;/em&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The LosFormatter class is extremely useful especially you override the SaveViewState() or LoadViewState() of the Page class/ Control, you need this class to do the serialization or deserialization of control states.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11070696-116076486935549512?l=alvinzc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alvinzc.blogspot.com/feeds/116076486935549512/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=11070696&amp;postID=116076486935549512' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/116076486935549512'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/116076486935549512'/><link rel='alternate' type='text/html' href='http://alvinzc.blogspot.com/2006/10/aspnet-serializingdeserializing.html' title='[ASP.NET] Serializing/Deserializing Passing Objects Across Pages with LosFormatter'/><author><name>Alvin Chooi</name><uri>http://www.blogger.com/profile/16063910632877857756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11070696.post-116066520222519822</id><published>2006-10-12T07:44:00.000-07:00</published><updated>2006-10-30T06:55:00.917-08:00</updated><title type='text'>[.NET 2.0] Foreach-ing Arrays with Iterator &amp; Generics</title><content type='html'>Prior to the .NET 2.0, we have to use for statement to loop each of the element in the array. C# 2.0 offers you another one - Iterator, a familar word that in the Design Pattern, a method that can be used to enumerate through collection of values such as array and return each of the element in turn. For instance,&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Code&lt;/strong&gt;&lt;pre class="code"&gt;&lt;br /&gt;string[] aryNames = {"Alvin","Westley","Howard"};&lt;br /&gt; &lt;br /&gt;foreach(string str in IterateMe(aryNames))&lt;br /&gt;  Response.Write(str + " ");&lt;br /&gt; &lt;br /&gt; &lt;br /&gt;private IEnumerable IterateMe(string[] str)&lt;br /&gt;{&lt;br /&gt;      int iLength = str.Length;&lt;br /&gt;      for(int index=0;index &lt; iLength;index++)&lt;br /&gt;          yield return str[index];&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;strong&gt;Output :&lt;/strong&gt;&lt;br /&gt;Alvin Westley Howard&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Your Iterator method has to return either IEnumerable or IEnumerator type to the caller function, which in turn contains the element value of current iteration. Make it more usable with generic,&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Code:&lt;/strong&gt;&lt;pre class="code"&gt;&lt;br /&gt;string[] aryNames = {"Alvin","Westley","Howard"};&lt;br /&gt;int[] iValues = {1,2,15,4,6,9};&lt;br /&gt; &lt;br /&gt;foreach(string str in IterateMe&lt; string &gt;(aryNames,true))&lt;br /&gt;  Response.Write(str + " ");&lt;br /&gt;  &lt;br /&gt;foreach(int value in IterateMe&lt; int &gt;(iValues,true))&lt;br /&gt;  Response.Write(value + " ");&lt;br /&gt; &lt;br /&gt; &lt;br /&gt;private IEnumerable IterateMe&lt; T &gt;(T[] str, bool sorting)&lt;br /&gt;{&lt;br /&gt;    if(sorting &amp;&amp; !typeof(T).Name.Equals("Object"))&lt;br /&gt;        Array.Sort(str);&lt;br /&gt; &lt;br /&gt;    int iLength = str.Length;  &lt;br /&gt;    for(int index=0;index &lt; iLength;index++)&lt;br /&gt;          yield return str[index];&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;br /&gt;Alvin Howard Westley&lt;br /&gt;1 2 3 6 9 15&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11070696-116066520222519822?l=alvinzc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alvinzc.blogspot.com/feeds/116066520222519822/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=11070696&amp;postID=116066520222519822' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/116066520222519822'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/116066520222519822'/><link rel='alternate' type='text/html' href='http://alvinzc.blogspot.com/2006/10/net-20-foreach-ing-arrays-with.html' title='[.NET 2.0] Foreach-ing Arrays with Iterator &amp; Generics'/><author><name>Alvin Chooi</name><uri>http://www.blogger.com/profile/16063910632877857756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11070696.post-116058497129616864</id><published>2006-10-11T09:40:00.000-07:00</published><updated>2006-10-30T06:55:00.667-08:00</updated><title type='text'>My Revamped Blog !</title><content type='html'>I have just revamped my blog by changing the page template to my favourite color and font family + size combinations. &lt;br /&gt;&lt;br /&gt;Testing..&lt;br /&gt;&lt;br /&gt;&lt;pre class="code"&gt;&lt;br /&gt;    Response.Write("Welcome to my newly-revamped blog!");&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11070696-116058497129616864?l=alvinzc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alvinzc.blogspot.com/feeds/116058497129616864/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=11070696&amp;postID=116058497129616864' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/116058497129616864'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/116058497129616864'/><link rel='alternate' type='text/html' href='http://alvinzc.blogspot.com/2006/10/my-revamped-blog.html' title='My Revamped Blog !'/><author><name>Alvin Chooi</name><uri>http://www.blogger.com/profile/16063910632877857756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11070696.post-116049994349028758</id><published>2006-10-10T09:58:00.000-07:00</published><updated>2006-10-30T06:54:59.212-08:00</updated><title type='text'>[AJAX] IE 7 getting Native XMLHTTPRequest object</title><content type='html'>Programming AJAX Web application would be in trouble when users turning off the ActiveX support in IE. The sentence of &lt;br /&gt;&lt;pre class="code"&gt;&lt;br /&gt;var xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); &lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;would not be working. But luckily, there is native XMLHTTPRequest object like what non-IE browsers do.&lt;br /&gt;&lt;pre class="code"&gt;&lt;br /&gt;var xmlHttp = new XMLHttpRequest();&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt; &lt;br /&gt;No ActiveX object is needed, so far. Here is the code needs to be added to check the support of native XMLHTTPRequest object&lt;br /&gt;&lt;pre class="code"&gt;&lt;br /&gt;if (window.XMLHttpRequest)&lt;br /&gt;{&lt;br /&gt;   // If IE7, Mozilla, Safari, etc: Use native object&lt;br /&gt;   var xmlHttp = new &lt;strong&gt;XMLHttpRequest();&lt;/strong&gt;&lt;br /&gt;}&lt;br /&gt;else &lt;br /&gt;{&lt;br /&gt;   if (window.ActiveXObject){&lt;br /&gt;          // use the ActiveX control for IE5.x and IE6&lt;br /&gt;          var xmlHttp = &lt;strong&gt;new ActiveXObject("Microsoft.XMLHTTP"); &lt;/strong&gt;&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11070696-116049994349028758?l=alvinzc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alvinzc.blogspot.com/feeds/116049994349028758/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=11070696&amp;postID=116049994349028758' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/116049994349028758'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/116049994349028758'/><link rel='alternate' type='text/html' href='http://alvinzc.blogspot.com/2006/10/ajax-ie-7-getting-native.html' title='[AJAX] IE 7 getting Native XMLHTTPRequest object'/><author><name>Alvin Chooi</name><uri>http://www.blogger.com/profile/16063910632877857756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11070696.post-116049804793369565</id><published>2006-10-10T09:29:00.000-07:00</published><updated>2006-10-30T06:54:59.141-08:00</updated><title type='text'>[ASP.NET] ASP.NET's FREE Components List</title><content type='html'>Jason'd compiled a long but yet comprehensive list of free components of ASP.NET, ranging from data-bound controls, graphing controls, navigation controls to templating and reporting controls..&lt;br /&gt;&lt;br /&gt;Check &lt;a href="http://aspalliance.com/articleViewer.aspx?aId=652&amp;pId=5"&gt;Free Components for ASP.NET&lt;/a&gt; for more detailed info. (Check user comments for some other useful controls too)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Hunting for more !&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11070696-116049804793369565?l=alvinzc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alvinzc.blogspot.com/feeds/116049804793369565/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=11070696&amp;postID=116049804793369565' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/116049804793369565'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/116049804793369565'/><link rel='alternate' type='text/html' href='http://alvinzc.blogspot.com/2006/10/aspnet-aspnets-free-components-list.html' title='[ASP.NET] ASP.NET&apos;s FREE Components List'/><author><name>Alvin Chooi</name><uri>http://www.blogger.com/profile/16063910632877857756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11070696.post-116038382173720315</id><published>2006-10-09T01:43:00.000-07:00</published><updated>2006-10-30T06:54:59.063-08:00</updated><title type='text'>[My Project] LVUtilities Lib v1.109 Updates : XmlHelper class</title><content type='html'>I have just done the following changes in this LVUtilities Lib v1.109&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;New XMLHelper class &lt;/strong&gt;&lt;br /&gt;1. ReadValuesByXPath()&lt;br /&gt;2. ReadElementValues()&lt;br /&gt;3. ReadElementList()&lt;br /&gt;4. ReadSingleElementValue()&lt;br /&gt;5. ReadAttributeValue()&lt;br /&gt;&lt;br /&gt;6. UpdateValuesByXPath()&lt;br /&gt;7. UpdateSingleValueByXPath()&lt;br /&gt;&lt;br /&gt;8. InsertAttributeByXPath()&lt;br /&gt;9. InsertElementByXPath()&lt;br /&gt;&lt;br /&gt;10.RemoveAttributeByXPath()&lt;br /&gt;11.RemoveElementByXPath()&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Changelog &lt;/strong&gt;&lt;br /&gt;1. Overloaded Generic IsDBNullValue&lt;&gt;() method&lt;br /&gt;2. Improve the string manipulation performance in string replacement&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.savefile.com/files/144583"&gt;Download the library + examples here&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11070696-116038382173720315?l=alvinzc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alvinzc.blogspot.com/feeds/116038382173720315/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=11070696&amp;postID=116038382173720315' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/116038382173720315'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/116038382173720315'/><link rel='alternate' type='text/html' href='http://alvinzc.blogspot.com/2006/10/my-project-lvutilities-lib-v1109.html' title='[My Project] LVUtilities Lib v1.109 Updates : XmlHelper class'/><author><name>Alvin Chooi</name><uri>http://www.blogger.com/profile/16063910632877857756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11070696.post-116022269098795209</id><published>2006-10-07T04:57:00.000-07:00</published><updated>2006-10-30T06:54:58.987-08:00</updated><title type='text'>Updates : SecurityHelper and ValidationHelper classes</title><content type='html'>I have enhanced the SecurityHelper and the ValidationHelper classes to support :&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;1. ValidationHelper class&lt;/strong&gt;&lt;br /&gt;The IsValidStateNames(), IsValidPhoneNO() , IsValidHPNO(), IsValidICNO(), IsValidPostalCode() are no longer limited to Malaysia context. For instance, to validate the phone number of US,&lt;br /&gt;&lt;pre class="code"&gt;&lt;br /&gt;if(ValidationHelper.IsValidPhoneNO(strInput,"(999)999-9999"))&lt;br /&gt;  // true or false&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;in which the "(999)999-9999" is the input mask pattern that used to validate the US phone number format.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;2. SecurityHelper class&lt;/strong&gt;&lt;br /&gt;The CompareValueToHash() method can now accept both string parameters of user input and hashed string. For instance,&lt;br /&gt;&lt;pre class="code"&gt;&lt;br /&gt;string strPassword = SecurityHelper.GenerateHashInString("abc");&lt;br /&gt;if(SecurityHelper.CompareValueToHash("abc",strPassword))&lt;br /&gt;  // true or false&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.savefile.com/files/138428"&gt;Download Examples and Library here&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11070696-116022269098795209?l=alvinzc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alvinzc.blogspot.com/feeds/116022269098795209/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=11070696&amp;postID=116022269098795209' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/116022269098795209'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/116022269098795209'/><link rel='alternate' type='text/html' href='http://alvinzc.blogspot.com/2006/10/updates-securityhelper-and.html' title='Updates : SecurityHelper and ValidationHelper classes'/><author><name>Alvin Chooi</name><uri>http://www.blogger.com/profile/16063910632877857756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11070696.post-116014818351013871</id><published>2006-10-06T08:16:00.000-07:00</published><updated>2006-10-30T06:54:58.843-08:00</updated><title type='text'>[.NET] Debugger, dont STEP INTO my method !</title><content type='html'>Had you experienced whenever you debug your application using the step-into feature (F11), the debugger will go through the implementation of the methods being called, which you might not want it to. How do you "tell" the debugger to skip the method and move on to next statement? Here is the answer.&lt;br /&gt;&lt;div style="color:#990000"&gt;&lt;br /&gt;using System.Diagnosis;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;[DebuggerStepThrough]&lt;/strong&gt;&lt;br /&gt;public void MyMethod()&lt;br /&gt;{&lt;br /&gt; ....&lt;br /&gt;}&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Be noted, the [DebuggerStepThrough] attribute can be used in the get/set of property, too.&lt;br /&gt;&lt;br /&gt;&lt;div style="color:#990000"&gt;&lt;br /&gt;public string MyProperty&lt;br /&gt;{&lt;br /&gt; &lt;strong&gt;[DebuggerStepThrough]&lt;/strong&gt;&lt;br /&gt; get {  }&lt;br /&gt;}&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;MyMethod : "Thanks for skipping over me, Debugger !"&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11070696-116014818351013871?l=alvinzc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alvinzc.blogspot.com/feeds/116014818351013871/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=11070696&amp;postID=116014818351013871' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/116014818351013871'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/116014818351013871'/><link rel='alternate' type='text/html' href='http://alvinzc.blogspot.com/2006/10/net-debugger-dont-step-into-my-method.html' title='[.NET] Debugger, dont STEP INTO my method !'/><author><name>Alvin Chooi</name><uri>http://www.blogger.com/profile/16063910632877857756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11070696.post-116011199360889598</id><published>2006-10-05T22:16:00.000-07:00</published><updated>2006-10-30T06:54:58.778-08:00</updated><title type='text'>[AJAX] AJAX Tutorials !</title><content type='html'>Planning to develop the AJAX app on the fly? Here are AJAX tutorials links that you can't afford to lose....&lt;br /&gt;&lt;br /&gt;1. &lt;a href="http://www.ajaxmatters.com/blog/ajax-tutorials/"&gt;130+ AJAX Tutorials [AjaxMatters]&lt;/a&gt;&lt;br /&gt;2. &lt;a href="http://vyk1.spaces.live.com/Blog/cns!EBE3A761F939F926!1051.entry"&gt;Top 126 AJAX Tutorials&lt;/a&gt;&lt;br /&gt;3. &lt;a href="http://www.maxkiesler.com/index.php/weblog/comments/60_more_helpful_ajax_tutorials/"&gt;60 Tutorials of AJAX [Max Kiesler]&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11070696-116011199360889598?l=alvinzc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alvinzc.blogspot.com/feeds/116011199360889598/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=11070696&amp;postID=116011199360889598' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/116011199360889598'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/116011199360889598'/><link rel='alternate' type='text/html' href='http://alvinzc.blogspot.com/2006/10/ajax-ajax-tutorials.html' title='[AJAX] AJAX Tutorials !'/><author><name>Alvin Chooi</name><uri>http://www.blogger.com/profile/16063910632877857756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11070696.post-116007038304105738</id><published>2006-10-05T10:37:00.000-07:00</published><updated>2006-10-30T06:54:58.719-08:00</updated><title type='text'>[My Project] My Helper library is OUT !</title><content type='html'>I have been working on creating a simple library which consists of 5 major helper classes in this version as following:&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;1. ValidationHelper class&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;a. IsValidFileName()&lt;br /&gt;b. IsValidNumeric()&lt;br /&gt;c. IsDBNullValue()&lt;br /&gt;d. IsValidDateFormat()&lt;br /&gt;e. IsAlpahbet()&lt;br /&gt;f. IsAlphaNumeric()&lt;br /&gt;g. IsValidUserName()&lt;br /&gt;h. IsValidName()&lt;br /&gt;i. IsValidStateName()   // Malaysia Context only&lt;br /&gt;j. IsValidPhoneNo()     // Malaysia Context only&lt;br /&gt;k. IsValidHPNo()    // Malaysia Context only&lt;br /&gt;l. IsValidICNo()    // Malaysia Context only&lt;br /&gt;m. IsValidPostalCode()   // Malaysia Context only&lt;br /&gt;n. IsValidEmail()&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;2. SecurityHelper Class&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;a. GenerateHash()        // MD5, SHA1, SHA256, SHA384, SHA512&lt;br /&gt;b. GenerateHashInString()&lt;br /&gt;c. CompareValueToHash()&lt;br /&gt;d. TDESEncrypt() and TDESDecrypt()    // Triple DES&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;3. MailHelper Class&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;a. SendMessage()&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;4. HttpPostHelper Class&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;a. SendRequest()&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;5. ClientScriptHelper Class&lt;/strong&gt; (ASP.NET only)&lt;br /&gt;&lt;br /&gt;a. ShowMessage()&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;em&gt;* I am working on the XmlHelper and FileHelper classes in coming release. &lt;/em&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Download &lt;/strong&gt;&lt;br /&gt;Download Library DLL and Examples : &lt;a href="http://www.megaupload.com/?d=1G96G4U9"&gt;http://www.megaupload.com/?d=1G96G4U9&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11070696-116007038304105738?l=alvinzc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alvinzc.blogspot.com/feeds/116007038304105738/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=11070696&amp;postID=116007038304105738' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/116007038304105738'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/116007038304105738'/><link rel='alternate' type='text/html' href='http://alvinzc.blogspot.com/2006/10/my-project-my-helper-library-is-out.html' title='[My Project] My Helper library is OUT !'/><author><name>Alvin Chooi</name><uri>http://www.blogger.com/profile/16063910632877857756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11070696.post-116001416693015577</id><published>2006-10-04T19:03:00.000-07:00</published><updated>2006-10-30T06:54:58.592-08:00</updated><title type='text'>[ADO.NET] 3 ways closing DataReader &amp; Connection..</title><content type='html'>These are the 3 common ways I use to close the XDataReader and DB Connection...&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;1. Use CommandBehavior.CloseConnection &lt;/strong&gt;&lt;div style="color:#990000"&gt;&lt;br /&gt;SqlDataReader reader = null;&lt;br /&gt;&lt;br /&gt;try&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;reader = cmd.ExecuteReader(CommandBehavior.CloseConnection);&lt;br /&gt;   &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;// do stuff&lt;br /&gt;}&lt;br /&gt;catch(Exception ex)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;// logging error&lt;br /&gt;}&lt;br /&gt;finally&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;// conn will be closed when reader is closed&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;reader.Close();&lt;br /&gt;}&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;2. Explicitly Close DataReader and Connection&lt;/strong&gt;&lt;div style="color:#990000"&gt;&lt;br /&gt;SqlDataReader reader = null;&lt;br /&gt;&lt;br /&gt;try&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;reader = cmd.ExecuteReader();&lt;br /&gt;   &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;// do stuff&lt;br /&gt;}&lt;br /&gt;catch(Exception ex)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;// logging error&lt;br /&gt;}&lt;br /&gt;finally&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;// conn will be closed when reader is closed&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;reader.Close();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;conn.Close();&lt;br /&gt;}&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;3. Use Using Statement&lt;/strong&gt;&lt;div style="color:#990000"&gt;&lt;br /&gt;using(SqlConnection con = new SqlConnection(&amp;lt;connection string&amp;gt;))&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;using(SqlCommand cmd = new SqlCommand(&amp;lt;query&amp;gt;,conn))&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;using(SqlDataReader reader = cmd.ExecuteReader())&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// do stuff&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;}&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;The first one is my preference, what about you?&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11070696-116001416693015577?l=alvinzc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alvinzc.blogspot.com/feeds/116001416693015577/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=11070696&amp;postID=116001416693015577' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/116001416693015577'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/116001416693015577'/><link rel='alternate' type='text/html' href='http://alvinzc.blogspot.com/2006/10/adonet-3-ways-closing-datareader.html' title='[ADO.NET] 3 ways closing DataReader &amp; Connection..'/><author><name>Alvin Chooi</name><uri>http://www.blogger.com/profile/16063910632877857756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11070696.post-115997513005211313</id><published>2006-10-04T08:09:00.000-07:00</published><updated>2006-10-30T06:54:58.530-08:00</updated><title type='text'>[.NET 2.0] New Methods / Operator in .NET 2.0</title><content type='html'>I summarize some of the useful new methods and operator introduced in .NET 2.0 here...&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;1. String.Contains()&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Old way in .NET v1.X&lt;div style="color:#0066cc"&gt;string str = "Today is monday";&lt;br /&gt;&lt;br /&gt;if(str.IndexOf("is")!= -1)&lt;br /&gt;  // do stuff&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;New way in .NET 2.0&lt;div style="color:#990000"&gt;string str = "Today is monday";&lt;br /&gt;if(str.Contains("is"))&lt;br /&gt;   // do stuff&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;2. String.StartsWith()&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Old way&lt;div style="color:#0066cc"&gt;string str = "Alvin Chooi";&lt;br /&gt;if(str.IndexOf("Al")==0)&lt;br /&gt;  // do stuff&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;New way&lt;div style="color:#990000"&gt;string str = "Alvin Chooi";&lt;br /&gt;if(str.StartsWith("Al"))&lt;br /&gt;   // do stuff&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;3. String.EndsWith()&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Old way&lt;div style="color:#0066cc"&gt;string str = "Alvin Chooi";&lt;br /&gt;if(str.IndexOf("Al")== str.Length-2)&lt;br /&gt;  // do stuff&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;New way&lt;div style="color:#990000"&gt;string str = "Alvin Chooi";&lt;br /&gt;if(str.EndsWith("Al"))&lt;br /&gt;   // do stuff&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;4. String.IsNullOrEmpty()&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Old way&lt;div style="color:#0066cc"&gt;string str = "Alvin Chooi";&lt;br /&gt;if((str!=null) &amp;&amp; (str.Length &gt; 0))&lt;br /&gt;  // do stuff&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;New way&lt;div style="color:#990000"&gt;string str = "Alvin Chooi";&lt;br /&gt;if(!String.IsNullOrEmpty(str))&lt;br /&gt;  // do stuff&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;5. TryParse()&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Old way&lt;div style="color:#0066cc"&gt;int iValue;&lt;br /&gt;try&lt;br /&gt;{&lt;br /&gt; iValue = Int32.Parse("2x");&lt;br /&gt;&lt;br /&gt; return true;&lt;br /&gt;}&lt;br /&gt;catch(Exception ex)&lt;br /&gt;{&lt;br /&gt;  return false;&lt;br /&gt;}&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;New way&lt;div style="color:#990000"&gt;int iValue&lt;br /&gt;bool isValid = Int32.TryParse("2x",out iValue);&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;6. Non-null operator (??)&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Old Way&lt;div style="color:#0066cc"&gt;string str = null;&lt;br /&gt;&lt;br /&gt;if(str!=null)&lt;br /&gt;  Response.Write(str);&lt;br /&gt;else&lt;br /&gt;  Response.Write("It is null");&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;New way&lt;div style="color:#990000"&gt;Response.Write(str?? "It is null");&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;7. Eval() &amp; Bind() in ASP.NET 2.0&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Old way&lt;div style="color:#0066cc"&gt;&amp;lt;%# DataBinder.Eval(Container.DataItem,"MyField") %&amp;gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;New way&lt;br /&gt;&lt;div style="color:#990000"&gt;&amp;lt;%# Eval("MyField") %&amp;gt;   // one-way binding&lt;br /&gt;&amp;lt;%# Bind("MyField") %&amp;gt;   // two-way binding&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Codes become lesser and lesser... (But why our work will never be lessen?, ha)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11070696-115997513005211313?l=alvinzc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alvinzc.blogspot.com/feeds/115997513005211313/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=11070696&amp;postID=115997513005211313' title='7 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/115997513005211313'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/115997513005211313'/><link rel='alternate' type='text/html' href='http://alvinzc.blogspot.com/2006/10/net-20-new-methods-operator-in-net-20.html' title='[.NET 2.0] New Methods / Operator in .NET 2.0'/><author><name>Alvin Chooi</name><uri>http://www.blogger.com/profile/16063910632877857756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>7</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11070696.post-115993942594769130</id><published>2006-10-03T22:15:00.000-07:00</published><updated>2006-10-30T06:54:58.465-08:00</updated><title type='text'>[ASP.NET] RequiredFieldValidator + OnClientClick issue</title><content type='html'>OnClientClick property was introduced in ASP.NET 2.0 to eliminate the need of developers to add the client-side "onclick" to a control programmatically. For instance,&lt;br /&gt;&lt;br /&gt;JS script&lt;br /&gt;&lt;div style="color:#990000"&gt;&lt;br /&gt;function ConfirmMe()&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;return confirm("Do you want to proceed?");&lt;br /&gt;}&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;ASPX&lt;br /&gt;&lt;div style="color:#990000"&gt;&lt;br /&gt;&amp;lt;asp:TextBox id="txtName" runat="server"/&amp;gt;&lt;br /&gt;&amp;lt;asp:Button id="btnSubmit" OnClientClick="return ConfirmMe()" Text="Submit" runat="server"/&amp;gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Well, that is pretty straightforward. BUT, it goes weird when you have a validator control (eg. RequiredFieldValidator) that is used to validate the "txtName" textbox server control. For instance,&lt;br /&gt;&lt;br /&gt;&lt;div style="color:#990000"&gt;&lt;br /&gt;&amp;lt;asp:TextBox id="txtName" runat="server"/&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&amp;lt;asp:RequiredFieldValidator id="rq1" ControlToValidate="txtName" ErrorMessage="Name cannot be blank" Display="Dynamic" runat="server"/&amp;gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;asp:Button id="btnSubmit" OnClientClick="return ConfirmMe()" Text="Submit" runat="server"/&amp;gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Whenever you press the button with no textbox value, the client-side confirmation dialog will be invoked first before the validator message is able to show up. This isn't what we expected it to behave. I tried several ways to overcome this problem, including using CLIENT CALLBACK, disabling the CauseValidation, but it failed. Finally, I was able to find a solution by adding JUST ONE line in the JS script.&lt;br /&gt;&lt;div style="color:#990000"&gt;&lt;br /&gt;function ConfirmMe()&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;if(&lt;strong&gt;Page_ClientValidate()&lt;/strong&gt;)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return confirm('Do you want to proceed?');&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;return false;&lt;br /&gt;}&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Another discovery today !&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11070696-115993942594769130?l=alvinzc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alvinzc.blogspot.com/feeds/115993942594769130/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=11070696&amp;postID=115993942594769130' title='15 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/115993942594769130'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/115993942594769130'/><link rel='alternate' type='text/html' href='http://alvinzc.blogspot.com/2006/10/aspnet-requiredfieldvalidator.html' title='[ASP.NET] RequiredFieldValidator + OnClientClick issue'/><author><name>Alvin Chooi</name><uri>http://www.blogger.com/profile/16063910632877857756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>15</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11070696.post-115992682208631335</id><published>2006-10-03T18:45:00.000-07:00</published><updated>2006-10-30T06:54:58.395-08:00</updated><title type='text'>Validator for CheckBox/CheckBoxList</title><content type='html'>By default, there is no validator server control available to validate the validity of checkbox in ASP.NET. On the basis practice, I have to use CustomValidator control or using pure client-side JS or the postback checking on server-side. But to ease the job,  you can try &lt;strong&gt;Custom Checkbox Validator&lt;/strong&gt;, created by Microsoft MVP, Scott Mitchell.&lt;br /&gt;&lt;br /&gt;URL : &lt;a href="http://aspnet.4guysfromrolla.com/articles/092006-1.aspx"&gt;http://aspnet.4guysfromrolla.com/articles/092006-1.aspx&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;IsValid? True !&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11070696-115992682208631335?l=alvinzc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alvinzc.blogspot.com/feeds/115992682208631335/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=11070696&amp;postID=115992682208631335' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/115992682208631335'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/115992682208631335'/><link rel='alternate' type='text/html' href='http://alvinzc.blogspot.com/2006/10/validator-for-checkboxcheckboxlist.html' title='Validator for CheckBox/CheckBoxList'/><author><name>Alvin Chooi</name><uri>http://www.blogger.com/profile/16063910632877857756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11070696.post-115986566038951252</id><published>2006-10-03T01:38:00.000-07:00</published><updated>2006-10-30T06:54:58.326-08:00</updated><title type='text'>About SqlDataSource control</title><content type='html'>I've been running a problem of losing the selected items in a listbox, which is bound to the SqlDataSource control on every postback. The code is :&lt;br /&gt;&lt;br /&gt;&lt;div style="color:#990000"&gt;&lt;br /&gt;&amp;lt;asp:ListBox ID="lstBox" runat="server" CssClass="listbox-flat" &lt;strong&gt;DataSourceID="objSQL"&lt;/strong&gt; DataTextField="userFullName" DataValueField="RID" SelectionMode="Multiple" Width="335px" Enabled="False"&amp;gt;&amp;lt;/asp:ListBox&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;asp:SqlDataSource &lt;strong&gt;ID="objSQL"&lt;/strong&gt; runat="server" ConnectionString="&amp;lt;%$ ConnectionStrings:dbConnectionString %&amp;gt;" SelectCommand="SELECT * FROM Table1"&amp;gt;  &amp;lt;/asp:SqlDataSource&amp;gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;As far as I remember, the selections of ListBox SHOULD be retained on the postback since the ViewState of the control will be saved in the SaveViewState event after the binding, but the thing goes weird unexpectedly :(. Since &lt;u&gt;the automatic databinding performed by the SqlDataSource takes place in the Page_PreRender event&lt;/u&gt; &lt;em&gt;(You can check it by using Page Tracing)&lt;/em&gt;. Here is the screenshot:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://photos1.blogger.com/blogger/953/883/1600/page_trace.jpg"&gt;&lt;img style="cursor:pointer; cursor:hand;" src="http://photos1.blogger.com/blogger/953/883/320/page_trace.jpg" border="0" alt="" /&gt;&lt;/a&gt;&lt;br /&gt;* The ListBox is bound to the DataSource control.&lt;br /&gt;&lt;br /&gt;Eventually, I used another way round  by programmatically binding the ListBox in that PreRender event with IsPostBack checking. &lt;em&gt;(No choice, this is the best way I could think of, I will find out the cause of the problem later)&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;u&gt;Steps&lt;/u&gt;&lt;/strong&gt;&lt;br /&gt;1. Set the DataSourceID property of ListBox to empty (So that it would not be bound to the SqlDataSource until runtime)&lt;br /&gt;&lt;br /&gt;2. Obtain the SqlDataSource's IEnumerable collection by calling the DataSource's Select() method with no argument.&lt;br /&gt;&lt;br /&gt;3. Call the ListBox's DataBind() method&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;u&gt;Code&lt;/u&gt;&lt;/strong&gt;&lt;br /&gt;&lt;div style="color:#990000"&gt;&lt;br /&gt;protected void Page_PreRender(Object sender, EventArgs e)&lt;br /&gt;{&lt;br /&gt;     if(!IsPostBack)&lt;br /&gt;     {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;lstBox.DataSourceID = String.Empty;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;lstBox.DataSource = &lt;strong&gt;objSQL.Select(DataSourceSelectArgument.Empty);&lt;/strong&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;lstBox.DataBind();&lt;br /&gt;     }&lt;br /&gt;}&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;u&gt;Good Practice&lt;/u&gt;&lt;/strong&gt;&lt;br /&gt;For ordinary data binding operations like binding DataGrid, ListBox, DropDownList, etc, we normally perform in Page_Load() event. Actually, &lt;u&gt;we can do the binding in the Page_PreRender event&lt;/u&gt; &lt;em&gt;(bind the data-bound controls as late as possible)&lt;/em&gt; before the controls are about to be rendered.&lt;br /&gt;&lt;br /&gt;Do always check IsPostBack before performing any data binding to reduce the roundtirp to server.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Digging into detailed observations...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11070696-115986566038951252?l=alvinzc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alvinzc.blogspot.com/feeds/115986566038951252/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=11070696&amp;postID=115986566038951252' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/115986566038951252'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/115986566038951252'/><link rel='alternate' type='text/html' href='http://alvinzc.blogspot.com/2006/10/about-sqldatasource-control.html' title='About SqlDataSource control'/><author><name>Alvin Chooi</name><uri>http://www.blogger.com/profile/16063910632877857756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11070696.post-115952247624920957</id><published>2006-09-29T02:30:00.000-07:00</published><updated>2006-10-30T06:54:58.259-08:00</updated><title type='text'>Patterns &amp; Practices Guidance Explorer</title><content type='html'>ScottGu recommended a very useful tool,namely &lt;a href="http://www.gotdotnet.com/codegallery/codegallery.aspx?id=bb9aecfe-56ba-4ca9-8127-44e551b90962"&gt;Patterns &amp; Practices Guidance Explorer&lt;/a&gt;, which contains hundreds lists of security &amp; performance best practices and patterns. The usage scenarios are&lt;br /&gt;&lt;br /&gt;&lt;em&gt;"1. Improve the security and performance of your application with guidelines and checklists that match your application exactly. &lt;br /&gt;2. You can build custom sets of guidance and share with your team as recommended practice.&lt;br /&gt;&lt;br /&gt;3. You can add new guidance to the library to share with your team, your company or the larger development community. "&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Hope this helps...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11070696-115952247624920957?l=alvinzc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alvinzc.blogspot.com/feeds/115952247624920957/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=11070696&amp;postID=115952247624920957' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/115952247624920957'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/115952247624920957'/><link rel='alternate' type='text/html' href='http://alvinzc.blogspot.com/2006/09/patterns-practices-guidance-explorer.html' title='Patterns &amp; Practices Guidance Explorer'/><author><name>Alvin Chooi</name><uri>http://www.blogger.com/profile/16063910632877857756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11070696.post-115882800615478910</id><published>2006-09-21T01:37:00.000-07:00</published><updated>2006-10-30T06:54:58.183-08:00</updated><title type='text'>Free PDF Converter in .NET</title><content type='html'>I have been struggling looking for non-commercial PDF library to convert my ASP.NET pages to PDF for reporting purpose. Finally, I decided to choose &lt;strong&gt;iTextSharp v3.1.5&lt;/strong&gt; library among other free libraries. I have found out that the library is extremely handy with few cool features such as document watermarking and encryption, user permission on copying, printing the document and the list goes on.&lt;br /&gt;&lt;br /&gt;Anyway, there is an annoying problem - the library has iTextSharp.text.Image class, which conflicts with the System.Drawing.Image class. Hence, the class will be ambiguous if both namespaces are imported in your project. Anyway, this matter is bearable for me. :)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Library Project Homepage : &lt;a href="http://sourceforge.net/projects/itextsharp/"&gt;http://sourceforge.net/projects/itextsharp/&lt;/a&gt;&lt;br /&gt;Library Download : &lt;a href="http://prdownloads.sourceforge.net/itextsharp/itextsharp-3.1.5-dll.zip?download"&gt;http://prdownloads.sourceforge.net/itextsharp/itextsharp-3.1.5-dll.zip?download&lt;/a&gt;&lt;br /&gt;Tutorial (C#) Download : &lt;a href="http://prdownloads.sourceforge.net/itextsharp/iTextSharp.tutorial.01.zip?download"&gt;http://prdownloads.sourceforge.net/itextsharp/iTextSharp.tutorial.01.zip?download&lt;/a&gt;&lt;br /&gt;Tutorial (VB) Download : &lt;a href="http://prdownloads.sourceforge.net/itextsharp/iTextSharp.tutorial.VB.NET.01.zip?download"&gt;http://prdownloads.sourceforge.net/itextsharp/iTextSharp.tutorial.VB.NET.01.zip?download&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Cool !&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11070696-115882800615478910?l=alvinzc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alvinzc.blogspot.com/feeds/115882800615478910/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=11070696&amp;postID=115882800615478910' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/115882800615478910'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/115882800615478910'/><link rel='alternate' type='text/html' href='http://alvinzc.blogspot.com/2006/09/free-pdf-converter-in-net.html' title='Free PDF Converter in .NET'/><author><name>Alvin Chooi</name><uri>http://www.blogger.com/profile/16063910632877857756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11070696.post-115873027636987661</id><published>2006-09-19T22:23:00.000-07:00</published><updated>2006-10-30T06:54:58.121-08:00</updated><title type='text'>No more DbCommandWrapper class</title><content type='html'>I'm testing the &lt;strong&gt;Enterprise Library January CTP 2006&lt;/strong&gt;, and I have been searching for the &lt;u&gt;DbCommandWrapper class&lt;/u&gt; and the &lt;/u&gt;GetXCommandWrapper()&lt;/u&gt; methods of Database class but they do not exist. Eventually, I found out that they are actually removed from the DAAB in this new version. &lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Example of code for old versions of DAAB prior to January 2006 release&lt;/strong&gt;&lt;br /&gt;&lt;div style="color:#990000"&gt;&lt;br /&gt;Database db = DatabaseFactory.CreateDatabase();&lt;br /&gt;&lt;strong&gt;DBCommandWrapper&lt;/strong&gt; dbCommand = db.&lt;strong&gt;GetStoredProcCommandWrapper&lt;/strong&gt;("SelectAuthors"); &lt;br /&gt;dbCommand.AddInParameter("AuthorID", DbType.String, strAuthorID);&lt;br /&gt;DataSet dsAuthors = db.ExecuteDataSet(dbCommand);&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Example of code for DAAB January CTP 2006&lt;/strong&gt;&lt;br /&gt;&lt;div style="color:#990000"&gt;&lt;br /&gt;&lt;strong&gt;using System.Data.Common;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Database db = DatabaseFactory.CreateDatabase();&lt;br /&gt;&lt;strong&gt;DbCommand&lt;/strong&gt; dbCommand = db.&lt;strong&gt;GetStoredProcCommand&lt;/strong&gt;("SelectAuthors"); &lt;br /&gt;&lt;strong&gt;db&lt;/strong&gt;.AddInParameter(&lt;strong&gt;dbCommand&lt;/strong&gt;,"AuthorID", DbType.String, strAuthorID);&lt;br /&gt;DataSet dsAuthors = db.ExecuteDataSet(dbCommand);&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Be informed that some online examples are using DbCommandWrapper class. thus, make some modification like above. Visit &lt;a href="ms-help://MS.VSCC.v80/MS.VSIPCC.v80/ms.EntLib.2006Jan/EnterpriseLibrary/html/03-01-000-Introduction%20to%20the%20Data%20Access%20Application%20Block.htm"&gt;Intro to DAAB January 2006 &lt;/a&gt;for more version migration issues.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11070696-115873027636987661?l=alvinzc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alvinzc.blogspot.com/feeds/115873027636987661/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=11070696&amp;postID=115873027636987661' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/115873027636987661'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/115873027636987661'/><link rel='alternate' type='text/html' href='http://alvinzc.blogspot.com/2006/09/no-more-dbcommandwrapper-class.html' title='No more DbCommandWrapper class'/><author><name>Alvin Chooi</name><uri>http://www.blogger.com/profile/16063910632877857756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11070696.post-115864820407911471</id><published>2006-09-18T23:36:00.000-07:00</published><updated>2006-10-30T06:54:58.064-08:00</updated><title type='text'>EBook on Threading in .NET</title><content type='html'>Thinking of learning Threading in .NET? I've found out a very handy ebook that explains fundamentals about .NET Threading. Worth to read !&lt;br /&gt;&lt;br /&gt;Web  : &lt;a href="http://www.albahari.com/threading/"&gt;http://www.albahari.com/threading/&lt;/a&gt;&lt;br /&gt;Book (PDF) : &lt;a href="http://www.albahari.com/threading/"&gt;http://www.albahari.com/threading/threading.pdf&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Sharing~~&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11070696-115864820407911471?l=alvinzc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alvinzc.blogspot.com/feeds/115864820407911471/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=11070696&amp;postID=115864820407911471' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/115864820407911471'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/115864820407911471'/><link rel='alternate' type='text/html' href='http://alvinzc.blogspot.com/2006/09/ebook-on-threading-in-net.html' title='EBook on Threading in .NET'/><author><name>Alvin Chooi</name><uri>http://www.blogger.com/profile/16063910632877857756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11070696.post-115863538816298886</id><published>2006-09-18T20:02:00.000-07:00</published><updated>2006-10-30T06:54:57.993-08:00</updated><title type='text'>Corrections of ClientCallBack Example</title><content type='html'>I have tested the example of ASP.NET 2.0 new feature - ClientCallBack at &lt;a href="http://dotnetjunkies.com/Article/E80EC96F-1C32-4855-85AE-9E30EECF13D7.dcik"&gt;ASP.NET 2.0's Client Callback Feature&lt;/a&gt;, but found not working due to:&lt;br /&gt;&lt;br /&gt;1. There is no this.GetCallbackEventReference()&lt;br /&gt;2. RaiseCallbackEvent() does not return string data type, from ICallbackEventHandler&lt;br /&gt;3. Missing of GetCallbackResult(), that defined in ICallbackEventHandler&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Finally I get it done by making some corrections:&lt;br /&gt;&lt;br /&gt;1. Use this.ClientScript.GetCallbackEventReference()&lt;br /&gt;2. Define the RaiseCallbackEvent() that returns no data type&lt;br /&gt;3. Define GetCallbackResult() to return the result to the client-side&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Corrected code:&lt;/strong&gt;&lt;br /&gt;&lt;div style="color:#990000"&gt;&lt;br /&gt;    protected void Page_Load(object sender, EventArgs e)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;        sCallBackInvocation = this&lt;strong&gt;.ClientScript.&lt;/strong&gt;GetCallbackEventReference(this, "message", "ShowServerTime", "context", "OnError",true);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;    public &lt;strong&gt;void RaiseCallbackEvent&lt;/strong&gt;(string eventArgument)&lt;br /&gt;    {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;        sCallBackInvocation = DateTime.Now.ToString();&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;    public string GetCallbackResult()&lt;br /&gt;    {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;        return sCallBackInvocation;&lt;br /&gt;    } &lt;/strong&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Recommendation&lt;/strong&gt;&lt;br /&gt;1. Check whether the browser does support callback feature in Page_Load() event&lt;br /&gt;&lt;br /&gt;&lt;div style="color:#990000"&gt;&lt;br /&gt;if (!Request.Browser.SupportsCallback)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;  // error message &lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11070696-115863538816298886?l=alvinzc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alvinzc.blogspot.com/feeds/115863538816298886/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=11070696&amp;postID=115863538816298886' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/115863538816298886'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/115863538816298886'/><link rel='alternate' type='text/html' href='http://alvinzc.blogspot.com/2006/09/corrections-of-clientcallback-example.html' title='Corrections of ClientCallBack Example'/><author><name>Alvin Chooi</name><uri>http://www.blogger.com/profile/16063910632877857756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11070696.post-115856525470041816</id><published>2006-09-18T00:30:00.000-07:00</published><updated>2006-10-30T06:54:57.922-08:00</updated><title type='text'>Page Redirect After Login in Forms Authentication</title><content type='html'>Normally, we will be redirected to the originally requesting page, with ReturnUrl query string appended in the URL after successful user login in Form Authentication using FormsAuthentication.RedirectFromLoginPage() method. Otherwise, the we will be redirected to default.aspx, by default.&lt;br /&gt;&lt;br /&gt;The question is, what method do we need to use if we want to redirect the users to different page other than default.aspx? Here I demonstrate how it can be accomplished.&lt;br /&gt;&lt;br /&gt;&lt;div style="color:#990000"&gt;&lt;br /&gt;bool isAuthenticated = true;&lt;br /&gt;&lt;br /&gt;if(isAuthenticated)        // after user is authenticated&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;if(Request.Params["ReturnUrl"] != null)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;    &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;FormsAuthentication.RedirectFromLoginPage(txtUsername.Text, false);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;else&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;FormsAuthentication.SetAuthcookie(txtUsername.Text, false);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Response.Redirect("yourpage.aspx");&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;}&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Get rid of default ones.... !&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11070696-115856525470041816?l=alvinzc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alvinzc.blogspot.com/feeds/115856525470041816/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=11070696&amp;postID=115856525470041816' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/115856525470041816'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/115856525470041816'/><link rel='alternate' type='text/html' href='http://alvinzc.blogspot.com/2006/09/page-redirect-after-login-in-forms.html' title='Page Redirect After Login in Forms Authentication'/><author><name>Alvin Chooi</name><uri>http://www.blogger.com/profile/16063910632877857756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11070696.post-115855829822056897</id><published>2006-09-17T22:37:00.000-07:00</published><updated>2006-10-30T06:54:57.855-08:00</updated><title type='text'>VIEWing your controls STATE</title><content type='html'>ViewState is one of the state managements in the ASP.NET and it is paramount especially in custom server control development. Proper understanding and use of ViewState could definitely save your life, notably in postback model in ASP.NET. &lt;br /&gt;&lt;br /&gt;Here I recommend some articles of ViewState for your readings :&lt;br /&gt;&lt;br /&gt;1. &lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/viewstate.asp"&gt;Understanding ASP.NET ViewState [MSDN]&lt;/a&gt;&lt;br /&gt;2. &lt;a href="http://weblogs.asp.net/infinitiesloop/archive/2006/08/03/Truly-Understanding-Viewstate.aspx"&gt;TRULY Understanding ViewState [InfiniteLoop's Blog]&lt;/a&gt;&lt;br /&gt;3. &lt;a href="http://aspalliance.com/909"&gt;Understanding View State in ASP.NET [aspAlliance]&lt;/a&gt;&lt;br /&gt;4. &lt;a href="http://aspalliance.com/articleViewer.aspx?aId=135&amp;pId="&gt;ViewState: All You Wanted to Know&lt;/a&gt;&lt;br /&gt;5. &lt;a href="http://msdn.microsoft.com/msdnmag/issues/03/02/CuttingEdge/"&gt;The ASP.NET ViewState [MSDN Magazine]&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;You already mastered another ASP.NET 's state management ;)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11070696-115855829822056897?l=alvinzc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alvinzc.blogspot.com/feeds/115855829822056897/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=11070696&amp;postID=115855829822056897' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/115855829822056897'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/115855829822056897'/><link rel='alternate' type='text/html' href='http://alvinzc.blogspot.com/2006/09/viewing-your-controls-state.html' title='VIEWing your controls STATE'/><author><name>Alvin Chooi</name><uri>http://www.blogger.com/profile/16063910632877857756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11070696.post-115855056805541559</id><published>2006-09-17T20:27:00.000-07:00</published><updated>2006-10-30T06:54:57.786-08:00</updated><title type='text'>ASP.NET 2.0 Full Page Life Cycle Diagram</title><content type='html'>Here is the big yet comprehensive diagram illustrating the page life cycle in &lt;strong&gt;ASP.NET 2.0&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://photos1.blogger.com/blogger/953/883/1600/pagelifecycle.jpg"&gt;&lt;img style="cursor:pointer; cursor:hand;" src="http://photos1.blogger.com/blogger/953/883/320/pagelifecycle.jpg" border="0" alt="" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;To recall the Page Life Cycle in &lt;strong&gt;ASP.NET v1.x&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://photos1.blogger.com/blogger/953/883/1600/pagelifecycle.gif"&gt;&lt;img style="cursor:pointer; cursor:hand;" src="http://photos1.blogger.com/blogger/953/883/320/pagelifecycle.png" border="0" alt="" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;ASP.NET 2.0 ones much complex !&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11070696-115855056805541559?l=alvinzc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alvinzc.blogspot.com/feeds/115855056805541559/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=11070696&amp;postID=115855056805541559' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/115855056805541559'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/115855056805541559'/><link rel='alternate' type='text/html' href='http://alvinzc.blogspot.com/2006/09/aspnet-20-full-page-life-cycle-diagram.html' title='ASP.NET 2.0 Full Page Life Cycle Diagram'/><author><name>Alvin Chooi</name><uri>http://www.blogger.com/profile/16063910632877857756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11070696.post-115854895777752728</id><published>2006-09-17T19:39:00.000-07:00</published><updated>2006-10-30T06:54:57.692-08:00</updated><title type='text'>Checking Existence of Available SQL Server</title><content type='html'>Of late, I had read an article about determining list of SQL Servers that are available to your application.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;.NET 1.1&lt;/strong&gt;&lt;br /&gt;There is no way but you need to use COM-based SQLDMO to have an interop call.&lt;br /&gt;&lt;br /&gt;&lt;div style="color:#990000"&gt;&lt;br /&gt;using SQLDMO;&lt;br /&gt;&lt;br /&gt;try&lt;br /&gt;{&lt;br /&gt;NameList objSQLList;&lt;br /&gt;ApplicationClass objSQLApp = new SQLDMO.ApplicationClass();&lt;br /&gt;&lt;br /&gt;objSQLList = objSQLApp.ListAvailableSQLServers();&lt;br /&gt;   &lt;br /&gt;foreach(string name in objSQLList)&lt;br /&gt;Response.Write(name + "&lt;br/&gt;");&lt;br /&gt;}&lt;br /&gt;catch(Exception ex)&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;finally&lt;br /&gt;{&lt;br /&gt;   objSQLApp.Quit();&lt;br /&gt;}&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;* You have to reference the SQLDMO.dll, which located at &lt;SQLServerInstallDrive&gt;:\Program Files\Microsoft SQL Server\&lt;Version&gt;\Tools\Binn  by default.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;.NET 2.0&lt;/strong&gt;&lt;br /&gt;It is much easier. You can retrieve the list of servers available using System.Data.Sql namespace, by enumerating each of the server instance.&lt;br /&gt;&lt;br /&gt;&lt;div style="color:#990000"&gt;&lt;br /&gt;SqlDataSourceEnumerator enumerator = SqlDataSourceEnumerator.Instance;&lt;br /&gt;DataTable datatable1 = enumerator.GetDataSources();&lt;br /&gt;foreach (DataRow row in datatable1.Rows)&lt;br /&gt;{&lt;br /&gt;            Response.Write("Server Name:" + row["ServerName"] + "&lt;br/&gt;");&lt;br /&gt;            Response.Write("Instance Name:" + row["InstanceName"] + "&lt;br/&gt;");&lt;br /&gt;} &lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Sometimes, these methods are better trying to connect the DB Server to see whether it is succesfully connected, but the output not always accurate due to :&lt;br /&gt;&lt;br /&gt;1. Invalid Login / User credentials&lt;br /&gt;2. Timeout due to network congestions&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Neat !&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11070696-115854895777752728?l=alvinzc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alvinzc.blogspot.com/feeds/115854895777752728/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=11070696&amp;postID=115854895777752728' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/115854895777752728'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/115854895777752728'/><link rel='alternate' type='text/html' href='http://alvinzc.blogspot.com/2006/09/checking-existence-of-available-sql.html' title='Checking Existence of Available SQL Server'/><author><name>Alvin Chooi</name><uri>http://www.blogger.com/profile/16063910632877857756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11070696.post-115812860678622215</id><published>2006-09-12T22:49:00.000-07:00</published><updated>2006-10-30T06:54:57.620-08:00</updated><title type='text'>Storing Static JavaScript in Resource File [ASP.NET 2.0]</title><content type='html'>In ASP.NET , we normally embedded the script string in the code-behind and invoke the RegisterStartupScript() to emit the JavaScript. The normal way we do like&lt;br /&gt;&lt;br /&gt;&lt;div style="color:#990000"&gt;&lt;br /&gt;ClientScriptManager csManager = Page.ClientScript;&lt;br /&gt;&lt;br /&gt;StringBuilder strScript = new StringBuilder();&lt;br /&gt;strScript.AppendLine("&amp;lt;script&amp;gt;");&lt;br /&gt;strScript.AppendLine(@"var response = confirm('{0}, do you want to continue ?');","Alvin Chooi");&lt;br /&gt;strScript.AppendLine("if(response)");&lt;br /&gt;strScript.AppendLine(" alert('OK')");&lt;br /&gt;strScript.Append("&amp;lt;/script&amp;gt;");&lt;br /&gt;&lt;br /&gt;if (!csManager.IsStartupScriptRegistered("ScriptTest"))&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;csManager.RegisterStartupScript(this.GetType(), "ScriptTest", strScript.ToString());&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;The script is less readable and messy. What the worst is that would be a slightly string manipulation overhead. In ASP.NET 2.0, you can store this static script in the resource file resx, which is stored in the App_GlobalResources folder.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Screenshot&lt;/strong&gt;&lt;br /&gt;&lt;a href="http://photos1.blogger.com/blogger/953/883/1600/script.jpg"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;" src="http://photos1.blogger.com/blogger/953/883/320/script.jpg" border="0" alt="" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;You could able to reference the script string from the resource file without hard-coding the script in the code-behind by&lt;br /&gt;&lt;br /&gt;&lt;div style="color:#990000"&gt;&lt;br /&gt;ClientScriptManager csManager = Page.ClientScript;&lt;br /&gt;&lt;br /&gt;if (!csManager.IsStartupScriptRegistered("ScriptTest"))&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;csManager.RegisterStartupScript(this.GetType(), "ScriptTest", String.Format(Resources.script.&lt;strong&gt;AlertMeScript&lt;/strong&gt;,"Alvin Chooi"));&lt;br /&gt;}&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Neat and manageable !&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11070696-115812860678622215?l=alvinzc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alvinzc.blogspot.com/feeds/115812860678622215/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=11070696&amp;postID=115812860678622215' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/115812860678622215'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/115812860678622215'/><link rel='alternate' type='text/html' href='http://alvinzc.blogspot.com/2006/09/storing-static-javascript-in-resource.html' title='Storing Static JavaScript in Resource File [ASP.NET 2.0]'/><author><name>Alvin Chooi</name><uri>http://www.blogger.com/profile/16063910632877857756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11070696.post-115812060548820370</id><published>2006-09-12T21:04:00.000-07:00</published><updated>2006-10-30T06:54:57.555-08:00</updated><title type='text'>Microsoft Interview Questions</title><content type='html'>Recently, I'd read the post of Jason Looney about questions asked &lt;a href="http://www.thelooneys.com/blogs/jason/archive/2006/04/17/the_microsoft_interview.aspx"&gt;Microsoft Interview&lt;/a&gt;. Amazing and extraordinary !&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Worth to read &lt;/strong&gt;&lt;br /&gt;1. &lt;a href="http://www.emicrosoftinterview.com/"&gt;Microsoft Interview Questions Guide&lt;/a&gt; &lt;br /&gt;2. &lt;a href="http://www.hanselman.com/blog/ASPNETInterviewQuestions.aspx"&gt;ASP.NET Interview Questions&lt;/a&gt; (The only one I could answer well ;p)&lt;br /&gt;3. &lt;a href="http://www.hanselman.com/blog/WhatGreatNETDevelopersOughtToKnowMoreNETInterviewQuestions.aspx"&gt;.NET Interview Questions&lt;/a&gt;&lt;br /&gt;4. &lt;a href="http://www.joelonsoftware.com/articles/fog0000000073.html"&gt;The Guerrilla Guide to Interviewing&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Hunting for more....&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11070696-115812060548820370?l=alvinzc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alvinzc.blogspot.com/feeds/115812060548820370/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=11070696&amp;postID=115812060548820370' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/115812060548820370'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/115812060548820370'/><link rel='alternate' type='text/html' href='http://alvinzc.blogspot.com/2006/09/microsoft-interview-questions.html' title='Microsoft Interview Questions'/><author><name>Alvin Chooi</name><uri>http://www.blogger.com/profile/16063910632877857756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11070696.post-115773832167547579</id><published>2006-09-08T10:51:00.000-07:00</published><updated>2006-10-30T06:54:57.415-08:00</updated><title type='text'>Fastest Ever Browser ?</title><content type='html'>Recently, I had read an article of &lt;a href="http://www.apcstart.com/site/amills/2006/09/1304/whats-the-worlds-fastest-browser"&gt;What is the world's fastest browser,&lt;/a&gt; and it claimed that optimized firefox (swiftfox) is the fastest browser among others in 64-bit environment. Whereas, Konqueror is crowned best-performance browser in Linux.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11070696-115773832167547579?l=alvinzc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alvinzc.blogspot.com/feeds/115773832167547579/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=11070696&amp;postID=115773832167547579' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/115773832167547579'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/115773832167547579'/><link rel='alternate' type='text/html' href='http://alvinzc.blogspot.com/2006/09/fastest-ever-browser.html' title='Fastest Ever Browser ?'/><author><name>Alvin Chooi</name><uri>http://www.blogger.com/profile/16063910632877857756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11070696.post-115768734802586707</id><published>2006-09-07T20:32:00.000-07:00</published><updated>2006-10-30T06:54:57.342-08:00</updated><title type='text'>Accessing Text in DataGrid's TemplateField</title><content type='html'>If you try to access the content of TemplateField&lt;br /&gt;&lt;br /&gt;&amp;lt;asp:TemplateColumn&amp;gt;&lt;br /&gt;&amp;lt;ItemTemplate&amp;gt;&lt;br /&gt;&amp;lt;%# DataBinder.Eval(Container.DataItem,"au_fname") %&amp;gt;&lt;br /&gt;&amp;lt;%# DataBinder.Eval(Container.DataItem,"au_lname") %&amp;gt;&lt;br /&gt;&amp;lt;/ItemTemplate&amp;gt;&lt;br /&gt;&amp;lt;/asp:TemplateColumn&amp;gt;&lt;br /&gt;&lt;br /&gt;using &lt;strong&gt;DataGrid1.Items[0].Cells[0].Text&lt;/strong&gt; (I assume it is first column), you would probably get nothing. It is because the text would be placed in  a special literal control called DataBoundLiteralControl, which is auto-generated by the compiler IF you place the data-bound expression in the ItemTemplate. Therefore, to access its content. You can use this,&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;((DataBoundLiteralControl)dgrdAuthors.Items[0].Cells[0].Controls[0]).Text&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;You get it !!!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11070696-115768734802586707?l=alvinzc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alvinzc.blogspot.com/feeds/115768734802586707/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=11070696&amp;postID=115768734802586707' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/115768734802586707'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/115768734802586707'/><link rel='alternate' type='text/html' href='http://alvinzc.blogspot.com/2006/09/accessing-text-in-datagrids.html' title='Accessing Text in DataGrid&apos;s TemplateField'/><author><name>Alvin Chooi</name><uri>http://www.blogger.com/profile/16063910632877857756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11070696.post-115768530178440311</id><published>2006-09-07T20:07:00.000-07:00</published><updated>2006-10-30T06:54:57.266-08:00</updated><title type='text'>Capitalizing Every First Letter of Words</title><content type='html'>How would you do that in your first thought? Would you create your own user-defined  function for that purpose in .NET? Please do not reinvent the wheel because there is built-in method available.&lt;br /&gt;&lt;br /&gt;&lt;div style="color:#990000"&gt;&lt;br /&gt;using System.Globalization;&lt;br /&gt;&lt;br /&gt;string str = "cool strINg";&lt;br /&gt;string str1 = "COOL STRING";&lt;br /&gt;&lt;br /&gt;TextInfo objTextInfo = new CultureInfo("en-US",false).TextInfo(); &lt;br /&gt;str = objTextInfo.ToTitleCase(str);   // Cool String *CORRECT&lt;br /&gt;&lt;i&gt;str1 = objTextInfo.ToTitleCase(str1);  // COOL STRING *WRONG&lt;/i&gt;&lt;br /&gt;str1 = objTextInfo.ToTitleCase(str1.toLower());   // Cool String *CORRECT&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;* For FULL CAPITALIZED words, you need to convert them to lower case before passing it to the ToTitleCase() method.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11070696-115768530178440311?l=alvinzc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alvinzc.blogspot.com/feeds/115768530178440311/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=11070696&amp;postID=115768530178440311' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/115768530178440311'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/115768530178440311'/><link rel='alternate' type='text/html' href='http://alvinzc.blogspot.com/2006/09/capitalizing-every-first-letter-of.html' title='Capitalizing Every First Letter of Words'/><author><name>Alvin Chooi</name><uri>http://www.blogger.com/profile/16063910632877857756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11070696.post-115768383971295330</id><published>2006-09-07T19:27:00.000-07:00</published><updated>2006-10-30T06:54:57.200-08:00</updated><title type='text'>Dynamically Adding Columns to GridView</title><content type='html'>I was asked in &lt;a href="http://forums.asp.net" target="_blank"&gt;ASP.NET Forum&lt;/a&gt; why the dynamically inserted BoundField would be lost from the GridView's column collection on postback (eg. Button click in GridView)?&lt;br /&gt;&lt;br /&gt;Many people would dynamically create controls in the Page_Load event. But I afraid it isn't a right place for the dynamic creation because the data in the control may not be pertained. (ViewState lost on postback). If possible, do the dynamic control creation in Initialization event (eg. Page_Init). &lt;br /&gt;&lt;br /&gt;One of the &lt;u&gt;differences between Page_Init and Page_Load&lt;/u&gt; is Page_Init event is only fired once and it is not fired on each postback, whereas the Page_Load event is always fired on every postback.&lt;br /&gt;&lt;br /&gt;Back to the topic, hence, to avoid the dynamic GridView's fields gone from its GridView's collection on postback, you SHOULD always create it in GridView's Init event. For instance,&lt;br /&gt;&lt;br /&gt;&lt;div style="color:#990000"&gt;Protected Sub GridView_Init(sender as Object, e as EventArgs) Handles &lt;b&gt;myGridView.Init&lt;/b&gt;&lt;br /&gt;      Dim field As New BoundField()&lt;br /&gt;  field.DataField = "data"&lt;br /&gt;&lt;br /&gt;      myGridView.Columns.Insert(0, field)   'To be first column in GridView&lt;br /&gt;End Sub&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The related discussion can be found &lt;a href="http://forums.asp.net/thread/1360096.aspx"&gt;here&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Good luck !&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11070696-115768383971295330?l=alvinzc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alvinzc.blogspot.com/feeds/115768383971295330/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=11070696&amp;postID=115768383971295330' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/115768383971295330'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/115768383971295330'/><link rel='alternate' type='text/html' href='http://alvinzc.blogspot.com/2006/09/dynamically-adding-columns-to-gridview.html' title='Dynamically Adding Columns to GridView'/><author><name>Alvin Chooi</name><uri>http://www.blogger.com/profile/16063910632877857756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11070696.post-115768110709224314</id><published>2006-09-07T18:56:00.000-07:00</published><updated>2006-10-30T06:54:57.134-08:00</updated><title type='text'>Recovering DB with LDF only</title><content type='html'>Of late, I witnessed the loss of mdf (due to corrupted or accidentally removed/overwritten) is painful. It is easy to recover the data from the .bak (database backup) or mdf(database file), but how would it be done the same thing just using ldf (log file) ? Here are the 10 steps that needs to be followed in order you have data restored.&lt;br /&gt;&lt;br /&gt;    &lt;strong&gt;1. Find out your previous database .bak file (backup file).&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;    &lt;strong&gt;2. Backup your updated .MDF file and the latest LDF file&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;    &lt;strong&gt;3. Delete your current database&lt;/strong&gt;&lt;br /&gt;        - If you cant access to SQL Queries Analyzer no worries just open with master&lt;br /&gt;        - type : &lt;div style="color:#990000"&gt;DROP DATABASE  SAMPLE_DB&lt;br /&gt;                 GO&lt;/div&gt;&lt;br /&gt;      &lt;i&gt;p/s - Make sure your infected MDF and LDF fully deleted from C:\Program Files\Microsoft SQL Server\MSSQL\Data&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;    &lt;strong&gt;4. Create a new database with FULL Mode&lt;/strong&gt;&lt;br /&gt;       - Open SQL Analyzer type following codes:&lt;br /&gt;       - type :  &lt;div style="color:#990000"&gt;USE master&lt;br /&gt;                 GO&lt;br /&gt;&lt;br /&gt;                 CREATE DATABASE myDB&lt;br /&gt;                 ON(NAME='myDB',&lt;br /&gt;                 FILENAME='C:\Program Files\Microsoft SQL Server\MSSQL\Data\myDB..mdf')&lt;br /&gt;                 LOG ON(NAME='myDB',&lt;br /&gt;                 FILENAME='C:\Program Files\Microsoft SQL Server\MSSQL\Data\myDB_Log')&lt;br /&gt;                 GO&lt;br /&gt;&lt;br /&gt;                 ALTER DATABASE myDB&lt;br /&gt;                 SET RECOVERY FULL&lt;br /&gt;                 GO&lt;br /&gt;&lt;br /&gt;                 EXEC sp_dboption 'myDB', 'autoclose', true&lt;br /&gt;                 GO&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;  &lt;strong&gt;5. Delete existing data and log files&lt;/strong&gt;&lt;br /&gt;     - type :  &lt;div style="color:#990000"&gt;EXEC master..xp_cmdshell 'del C:\Program Files\Microsoft SQL Server\MSSQL\Data\myDB.mdf&lt;br /&gt;              EXEC master..xp_cmdshell 'del C:\Program Files\Microsoft SQL Server\MSSQL\Data\myDB_Log'&lt;br /&gt;              GO&lt;/div&gt;&lt;br /&gt;     &lt;br /&gt;- Make sure no more .MDF and .LDF in your C:\Program Files\Microsoft SQL Server\MSSQL\Data&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;    &lt;strong&gt;6. Stop your whole database&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;    &lt;strong&gt;7. Copy your previous infected .MDF and .LDF to C:\Program Files\Microsoft SQL Server\MSSQL\Data&lt;/strong&gt;&lt;br /&gt;        &lt;br /&gt;    &lt;strong&gt;8. Backup the log with NO_TRUNCATE&lt;/strong&gt;&lt;br /&gt;       - Note that backup will error due to inaccessible data file, but log will still be backed up.&lt;br /&gt;       - type : &lt;div style="color:#990000"&gt;BACKUP LOG myDB&lt;br /&gt;                            TO DISK='C:\Backups\myDB.bak'&lt;br /&gt;                            WITH NO_TRUNCATE, INIT&lt;br /&gt;                            GO&lt;/div&gt;&lt;br /&gt;      - Make sure backup success, check the .bak file if the file size too small if compare with your .LDF file size then might                    be error, maybe your infected .LDF file stored wrongly, but normally no problem.&lt;br /&gt;      - This is very important file, no error here then fine already.&lt;br /&gt;&lt;br /&gt;    &lt;strong&gt;9. Restore your database&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;       - Restore your previous backup database. Doesn't matter if your data not up to date.&lt;br /&gt;       - type :  &lt;div style="color:#990000"&gt;USE Master&lt;br /&gt;&lt;br /&gt;                 RESTORE DATABASE DatabaseName&lt;br /&gt;                 FROM DISK = 'c:\Backups\old_myDB.BAK&lt;br /&gt;                 WITH NORECOVERY&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;      - p/s Remember use WITH NORECOVERY&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;    &lt;strong&gt;10. Restore your backup log&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;        - type:  &lt;div style="color:#990000"&gt;RESTORE LOG myDB&lt;br /&gt;                 FROM DISK = 'C:\Backups\myDB.bak'&lt;br /&gt;                WITH RECOVERY&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;    - p/s Remember use WITH RECOVERY&lt;br /&gt;&lt;br /&gt;    - Check your data again.&lt;br /&gt;    - Done !!!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11070696-115768110709224314?l=alvinzc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alvinzc.blogspot.com/feeds/115768110709224314/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=11070696&amp;postID=115768110709224314' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/115768110709224314'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/115768110709224314'/><link rel='alternate' type='text/html' href='http://alvinzc.blogspot.com/2006/09/recovering-db-with-ldf-only.html' title='Recovering DB with LDF only'/><author><name>Alvin Chooi</name><uri>http://www.blogger.com/profile/16063910632877857756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11070696.post-115764315640945639</id><published>2006-09-07T08:27:00.000-07:00</published><updated>2006-10-30T06:54:57.072-08:00</updated><title type='text'>JSON Reader</title><content type='html'>Today is a boring day, I decided to create a lightweight JSON reader for JSON manipulation using JavaScript (After I have not been touching JSON and JavaScript prototype since my FYP). My intention of creating this JSONReader is simply to manipulate/read the JSON value with string path supplied.  To start off, I use a very simple JSON in my example.&lt;br /&gt;&lt;br /&gt;&lt;div style="color:#990000"&gt;var myJSON = {"Image": {&lt;br /&gt;    "Width":800,&lt;br /&gt;     "Width":200,&lt;br /&gt;    "Height":600,&lt;br /&gt;    "Title":"View from 15th Floor",&lt;br /&gt;    "Thumbnail":&lt;br /&gt;    {&lt;br /&gt;      "Url":"http:\/\/scd.mm-b1.yimg.com\/image\/481989943",&lt;br /&gt;      "Height": 125,&lt;br /&gt;      "Width": "100"&lt;br /&gt;    },&lt;br /&gt;  "IDs":[ 116, 943, 234, 38793 ]&lt;br /&gt;  }}&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Now, we "instantiate" the object of JSONReader with the JSON format passed as parameter to its constructor.&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#990000"&gt;&lt;br /&gt;var reader = new JSONReader(myJSON);&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Then at the frontend, we allow the users to key in the string path in the TextBox.&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#990000"&gt;&lt;br /&gt;  &amp;ltinput type="text" id="txtPath" name="textfield"&amp;gt;&lt;br /&gt;  &amp;ltinput type="button" onclick="GetValue()" name="Submit" value="Get the Value"&amp;gt;&lt;br /&gt;&lt;br /&gt;   &amp;ltspan id="lblMessage"/&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The string path provided by user will be passed to the FindValueByKeyPath() method of JSONReader in the GetValue() function to obtain the value in JSON. &lt;i&gt;The $F() is the method in the prototype.js that used to retrieve the value of specified HTML element. &lt;/i&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#990000"&gt;var path = $F("txtPath");&lt;br /&gt;   lblMessage.innerHTML = reader.findValueByKeyPath(path);&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Test Results&lt;/strong&gt;&lt;br /&gt;&lt;u&gt;User Input&lt;/u&gt; : Image\Thumbnail&lt;br /&gt;&lt;u&gt;Output&lt;/u&gt; : {"Url":"http://scd.mm-b1.yimg.com/image/481989943","Height":125,"Width":"100"}&lt;br /&gt;&lt;br /&gt;&lt;u&gt;User Input&lt;/u&gt; : Image\Thumbnail\Url&lt;br /&gt;&lt;u&gt;Output&lt;/u&gt; : http://scd.mm-b1.yimg.com/image/481989943&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Screenshot&lt;/strong&gt;&lt;br /&gt;&lt;a href="http://photos1.blogger.com/blogger/953/883/1600/jsonreader_exam.0.jpg"&gt;&lt;img style="cursor:hand;" src="http://photos1.blogger.com/blogger/953/883/320/jsonreader_exam.0.jpg" border="0" alt="" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Additional Libraries Needed&lt;/strong&gt;&lt;br /&gt;&lt;u&gt;prototype.js&lt;/u&gt;&lt;br /&gt;$F(), class.Create()&lt;br /&gt;&lt;br /&gt;&lt;u&gt;json.js&lt;/u&gt;&lt;br /&gt;parseJSON(), toJSONString()&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The complete example can be downloaded &lt;a href="http://www.uploading.com/files/OJ46FP0T/jsonreader_example.rar.html"&gt;here&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Still boring ~~ :|&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11070696-115764315640945639?l=alvinzc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alvinzc.blogspot.com/feeds/115764315640945639/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=11070696&amp;postID=115764315640945639' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/115764315640945639'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/115764315640945639'/><link rel='alternate' type='text/html' href='http://alvinzc.blogspot.com/2006/09/json-reader.html' title='JSON Reader'/><author><name>Alvin Chooi</name><uri>http://www.blogger.com/profile/16063910632877857756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11070696.post-115721298677156781</id><published>2006-09-02T08:53:00.000-07:00</published><updated>2006-10-30T06:54:56.935-08:00</updated><title type='text'>ASP.NET Best Practices</title><content type='html'>I have been collecting ASP.NET BEST PRACTICES articles for quite some time. Here are some articles/guidelines that may be handy to you.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;ASP.NET Performance Best Practices&lt;/strong&gt;&lt;br /&gt;1. &lt;a href="http://msdn.microsoft.com/library/en-us/dnpag/html/scalenetchapt06.asp?frame=true"&gt;Improving ASP.NET Performance [MSDN]&lt;/a&gt;&lt;br /&gt;2. &lt;a href="http://msdn2.microsoft.com/en-us/library/5dws599a.aspx"&gt;Developing High-Performance ASP.NET Application [MSDN2]&lt;/a&gt;&lt;br /&gt;3. &lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/dotnetperftips.asp"&gt;Performance Tips and Tricks for .NET Applications [MSDN]&lt;/a&gt;&lt;br /&gt;4. &lt;a href="http://msdn.microsoft.com/msdnmag/issues/05/01/ASPNETPerformance/default.aspx"&gt;10 Tips for Writing High-Performance Web Applications [MSDN Magazine]&lt;/a&gt;&lt;br /&gt;5. &lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/vbnstrcatn.asp"&gt;Improving String Handling Performance in .NET Framework Applications [MSDN]&lt;/a&gt;&lt;br /&gt;6. &lt;a href="http://www.codeproject.com/aspnet/SitePerf.asp"&gt;Performance Strategies for Enterprise Web Site Development [Code Project]&lt;/a&gt;&lt;br /&gt;7. &lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag/html/scalenetchapt14.asp?frame=true"&gt;Improving SQL Server Performance [MSDN]&lt;/a&gt;&lt;br /&gt;8. &lt;a href="http://authors.aspalliance.com/aspxtreme/webapps/developinghigh-performanceaspnetapplications.aspx"&gt;Developing High-Performance ASP.NET Applications [aspalliance]&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;ASP.NET Security Best Practices&lt;/strong&gt;&lt;br /&gt;1. &lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetsec/html/secnetlpMSDN.asp"&gt;Building Secure ASP.NET Applications: Authentication, Authorization, and Secure Communication [MSDN]&lt;/a&gt;&lt;br /&gt;2. &lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetsec/html/threatcounter.asp"&gt;Improving Web Application Security: Threats and Countermeasures [MSDN]&lt;/a&gt;&lt;br /&gt;3. &lt;a href="http://www.devx.com/security/Article/20898?trk=DXRSS_LATEST"&gt;ASP.NET Security: 8 Ways to Avoid Attack [devx]&lt;/a&gt;&lt;br /&gt;4. &lt;a href="http://www.sitepoint.com/article/sql-injection-attacks-safe"&gt;SQL Injection Attacks - Are You Safe? [sitepoint.com]&lt;/a&gt;&lt;br /&gt;5. &lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag2/html/PAGPractices0001.asp"&gt;Security Practices: ASP.NET 2.0 Security Practices at a Glance [MSDN]&lt;/a&gt;&lt;br /&gt;6. &lt;a href="http://msdn.microsoft.com/msdnmag/issues/02/04/ASPSec/"&gt;An Introductory Guide to Building and Deploying More Secure Sites with ASP.NET and IIS [MSDN Magazine]&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;ADO.NET Best Practices&lt;/strong&gt;&lt;br /&gt;1. &lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnadonet/html/adonetbest.asp"&gt;Best Practices for Using ADO.NET [MSDN]&lt;/a&gt;&lt;br /&gt;2. &lt;a href="http://www.devx.com/codemag/Article/17905"&gt;ADO.NET Best Practices [devx]&lt;/a&gt;&lt;br /&gt;3. &lt;a href="http://www.devx.com/codemag/Article/20138"&gt;ADO.NET Best Practices, Part II [devx]&lt;/a&gt;&lt;br /&gt;4. &lt;a href="http://www.code-magazine.com/Article.aspx?quickid=0311051"&gt;ADO.NET Best Practices [code-magazine]&lt;/a&gt;&lt;br /&gt;5. &lt;a href="http://www.developerdotstar.com/community/node/531"&gt;Using Data with ASP.Net - 10 of my 'Best Practices'&lt;/a&gt;&lt;br /&gt;6. &lt;a href="http://www.theserverside.net/tt/articles/showarticle.tss?id=OptimizingADONET"&gt;Optimized ADO.NET [theserverside.net]&lt;/a&gt;&lt;br /&gt;7. &lt;a href="http://www.sql-server-performance.com/ado_net_performance.asp"&gt;ADO.NET and SQL Server Performance Tips [sql-server-performance]&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Error Logging / Exceptions Best Practices&lt;/strong&gt;&lt;br /&gt;1. &lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconBestPracticesForHandlingExceptions.asp"&gt;Best Practices for Handling Exceptions [MSDN]&lt;/a&gt;&lt;br /&gt;2. &lt;a href="http://www.codeproject.com/dotnet/exceptionbestpractices.asp"&gt;Exception Handling Best Practices in .NET [codeproject]&lt;/a&gt;&lt;br /&gt;3. &lt;a href="http://www.devcity.net/Articles/134/1/article.aspx"&gt;Exception Handling in Enterprise Applications [devcity]&lt;/a&gt;&lt;br /&gt;4. &lt;a href="http://dturini.blogspot.com/2005/02/exception-handling-best-practices-in.html"&gt;Exception Handling Best Practices in .NET&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Naming/Standards Guidelines&lt;/strong&gt;&lt;br /&gt;1. &lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconnamingguidelines.asp"&gt;Naming Guidelines [MSDN]&lt;/a&gt;&lt;br /&gt;2. &lt;a href="http://www.dotnetspider.com/tutorials/BestPractices.aspx"&gt;C# Coding Standards and Best Programming Practices [dotnetspider]&lt;/a&gt;&lt;br /&gt;3. &lt;a href="http://www.ssw.com.au/SSW/Standards/Default.aspx"&gt;SSW's Naming Conventions [SSW]&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;I'll post more useful ASP.NET links in the future. Hope this helps... :)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11070696-115721298677156781?l=alvinzc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alvinzc.blogspot.com/feeds/115721298677156781/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=11070696&amp;postID=115721298677156781' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/115721298677156781'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/115721298677156781'/><link rel='alternate' type='text/html' href='http://alvinzc.blogspot.com/2006/09/aspnet-best-practices.html' title='ASP.NET Best Practices'/><author><name>Alvin Chooi</name><uri>http://www.blogger.com/profile/16063910632877857756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11070696.post-110949477391907418</id><published>2005-02-27T00:58:00.000-08:00</published><updated>2006-10-30T06:54:56.864-08:00</updated><title type='text'>Displaying 2 Field Names  in 1 Column of DataGrid</title><content type='html'>&lt;span style="font-family:verdana;font-size:8pt;"&gt;&lt;br /&gt;In the previous articles, I used the &lt;em&gt;Authors&lt;/em&gt; table from &lt;em&gt;Pubs&lt;/em&gt; database to display data in the datagrid. As you can see the screenshots, the author's firstname (au_fname) and author's lastname (au_lname) are displayed in the different columns. Perhaps, you would be wondering how to combine both au_fname and au_lname fields into 1 column. Now, I will demonstrate two ways to do that. &lt;u&gt;First method&lt;/u&gt; using new combined &lt;em&gt;&lt;strong&gt;DataColumn&lt;/strong&gt;&lt;/em&gt;, and &lt;u&gt;second method&lt;/u&gt; using &lt;em&gt;&lt;strong&gt;Data Binding in the ItemDataBound event.&lt;/strong&gt;&lt;/em&gt; To avoid this article from becoming lengthy, I combine both methods into 1 solution. &lt;em&gt;[As you will notice that there are two same columns, which have author's full names.]&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;In the aspx page,&lt;br /&gt;&lt;div style="background-color:#f7f7f7"&gt;&lt;br /&gt;&amp;lt;asp:datagrid id="dgrdAuthors" &lt;strong&gt;onItemDataBound="dgrdAuthors_ItemDataBound"&lt;/strong&gt; .......&amp;gt;&lt;br /&gt;&amp;lt;Columns&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;strong&gt;asp:BoundColumn&lt;/strong&gt; DataField="&lt;u&gt;au_id&lt;/u&gt;" HeaderText="Author ID"/&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;strong&gt;asp:BoundColumn&lt;/strong&gt; DataField="&lt;u&gt;FullName&lt;/u&gt;" HeaderText="&lt;font color="blue"&gt;Name (DataColumn)&lt;/font&gt;"/&amp;gt;;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;em&gt; &lt;font color="#ff0000"&gt;&lt;--  First method &lt;/font&gt;&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;strong&gt;asp:TemplateColumn&lt;/strong&gt; HeaderText="&lt;font color="blue"&gt;Name(DataItem)&lt;/font&gt;"&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;em&gt;&lt;font color="#ff0000"&gt;&lt;--  Second method &lt;/font&gt;&lt;/em&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;ItemTemplate&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;asp:label id="lblFullName" runat="server"/&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/ItemTemplate&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/asp:TemplateColumn&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;strong&gt;asp:BoundColumn&lt;/strong&gt; DataField="&lt;u&gt;phone&lt;/u&gt;" HeaderText="Phone"/&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;strong&gt;asp:BoundColumn&lt;/strong&gt; DataField="&lt;u&gt;city&lt;/u&gt;" HeaderText="City"/&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;strong&gt;asp:BoundColumn&lt;/strong&gt; DataField="&lt;u&gt;state&lt;/u&gt;" HeaderText="State"/&amp;gt;&lt;br /&gt;&amp;lt;/Columns&amp;gt;&lt;br /&gt;&amp;lt;/asp:datagrid&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;In my DataGrid, there are total number of 6 columns, which 2 of columns are the same (&lt;em&gt;&lt;strong&gt;Name(DataColumn)&lt;/strong&gt;&lt;/em&gt; and &lt;strong&gt;&lt;em&gt;Name(DataItem)&lt;/em&gt;&lt;/strong&gt; columns). As you can notice, one of the columns used is &lt;em&gt;&lt;strong&gt;TemplateColumn&lt;/strong&gt;&lt;/em&gt;. This column is customizable and provide more flexibility in formatting the appearance of the displayed data. The purpose of using this &lt;em&gt;&lt;strong&gt;TemplateColumn&lt;/strong&gt;&lt;/em&gt; here is I want to customize the data (combining both &lt;em&gt;&lt;strong&gt;au_fname&lt;/strong&gt;&lt;/em&gt; and &lt;em&gt;&lt;strong&gt;au_lname&lt;/strong&gt;&lt;/em&gt;) at run time.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Definitions : &lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwebuiwebcontrolstemplatecolumnclasstopic.asp" target="_blank"&gt;TemplateColumn class&lt;/a&gt; | &lt;a href="http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemWebUIWebControlsBoundColumnClassTopic.asp?frame=true" target="_blank"&gt;BoundColumn Class&lt;/a&gt; | &lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwebuiwebcontrolsdatagridclassitemdataboundtopic.asp" target="_blank"&gt;ItemDataBound Event &lt;/a&gt;&lt;br /&gt;&lt;br /&gt;See Also : &lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbtskcustomizingdatalistitemsatruntime.asp" target="_blank"&gt;Customizing DataList Items at Run Time [MSDN] &lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;In the &amp;lt;script&amp;gt; tag or code behind ,&lt;br /&gt;&lt;div style="background-color:#f7f7f7"&gt;&lt;br /&gt;&amp;lt;script&amp;gt;&lt;br /&gt;protected void &lt;strong&gt;Page_Load&lt;/strong&gt;(Object sender, EventArgs e)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if(!IsPostBack)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;SqlConnection conPubs = new SqlConnection("Server=DOTNET;uid=sa;database=pubs");&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;SqlDataAdapter daSelectAuthors = new SqlDataAdapter("SELECT au_id, au_fname, au_lname, phone,city,state FROM Authors",conPubs);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;strong&gt;DataSet&lt;/strong&gt; dsAuthors = new DataSet();&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;conPubs.Open();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;daSelectAuthors.Fill(dsAuthors,"Authors");&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;conPubs.Close();&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;strong&gt;DataColumn&lt;/strong&gt; dcolFullName = new &lt;strong&gt;DataColumn()&lt;/strong&gt;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;dcolFullName.&lt;strong&gt;ColumnName&lt;/strong&gt; = "FullName";&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;dcolFullName.&lt;strong&gt;DataType&lt;/strong&gt; = System.Type.GetType("System.String");&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;dcolFullName.&lt;strong&gt;Expression&lt;/strong&gt; = "au_fname + ' ' + au_lname";&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;dsAuthors.Tables["Authors"].Columns.&lt;strong&gt;Add&lt;/strong&gt;(dcolFullName); &lt;em&gt;// add new column to the datatable&lt;/em&gt; &lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;dgrdAuthors.DataSource = dsAuthors.Tables["Authors"].DefaultView;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;dgrdAuthors.DataBind();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;private void &lt;strong&gt;dgrdAuthors_ItemDataBound&lt;/strong&gt;(Object sender, DataGridItemEventArgs e)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Label lblFullName = (Label)e.Item.&lt;em&gt;&lt;strong&gt;FindControl&lt;/strong&gt;&lt;/em&gt;("lblFullName");&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;lblFullName.Text = (((DataRowView)e.Item.DataItem)&lt;strong&gt;["au_fname"]&lt;/strong&gt;).ToString() + " " + &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(((DataRowView)e.Item.DataItem)&lt;strong&gt;["au_lname"]&lt;/strong&gt;).ToString();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;  &lt;br /&gt;&lt;br /&gt;} &lt;br /&gt;&amp;lt;/script&amp;gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;For the first method, I have created a new datacolumn, which has &lt;em&gt;&lt;strong&gt;FullName&lt;/strong&gt;&lt;/em&gt; column name and  &lt;strong&gt;&lt;em&gt;string&lt;/em&gt;&lt;/strong&gt; data type. The &lt;em&gt;&lt;strong&gt;Expression&lt;/strong&gt;&lt;/em&gt; property of DataColumn can be used for calculating values from different data fields, combining columns and so on. At here, I'm combining the &lt;em&gt;&lt;strong&gt;au_fname&lt;/strong&gt;&lt;/em&gt; and &lt;em&gt;&lt;strong&gt;au_lname&lt;/strong&gt;&lt;/em&gt; fields as 1 field (column). After that, I add this new column to the &lt;em&gt;&lt;strong&gt;DataColumnCollection&lt;/strong&gt;&lt;/em&gt; of &lt;em&gt;&lt;strong&gt;"Authors"&lt;/strong&gt;&lt;/em&gt; DataTable, and then bind this DataSet to DataGrid. &lt;u&gt;Eventually, the DataSet has 7 fields.&lt;/u&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;In the &lt;em&gt;&lt;strong&gt;ItemDataBound&lt;/strong&gt;&lt;/em&gt; event, I check the data rows using the &lt;em&gt;If..... Statement&lt;/em&gt;, and for each data row, I use the &lt;em&gt;&lt;strong&gt;FindControl()&lt;/strong&gt;&lt;/em&gt; to search and locate the &lt;em&gt;&lt;strong&gt;Label&lt;/strong&gt;&lt;/em&gt; server control that is placed in the TemplateColumn there &lt;u&gt;by its ID&lt;/u&gt;. Of course, I have to cast the returned result of the &lt;em&gt;&lt;strong&gt;FindControl()&lt;/strong&gt;&lt;/em&gt; to &lt;em&gt;&lt;strong&gt;Label&lt;/strong&gt;&lt;/em&gt; type. Let us proceed to next line, which will be a bit complicated.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The &lt;em&gt;&lt;strong&gt;e.Item.DataItem&lt;/strong&gt;&lt;/em&gt; is an object that represents the data item in the DataGrid. &lt;u&gt;It can only be placed in the data rows like Item, AlternatingItem, SelectedItem and EditedItem&lt;/u&gt;. Whereas  the &lt;em&gt;&lt;strong&gt;DataRowView &lt;/strong&gt;&lt;/em&gt; represents each displayed data row. The &lt;em&gt;&lt;strong&gt;((DataRowView)e.Item.DataItem)["au_fname"]&lt;/strong&gt;&lt;/em&gt; is an explicit casting. Alternatively, you can change to the &lt;em&gt;&lt;strong&gt;DataBinder.Eval(e.Item.DataItem,"au_fname")&lt;/strong&gt;&lt;/em&gt;, which is the equivalent to the &lt;em&gt;&lt;strong&gt;((DataRowView)e.Item.DataItem)["au_fname"]&lt;/strong&gt;&lt;/em&gt;. &lt;u&gt;The reason I use the explicit casting is because it offers better performance than DataBinder.Eval() in avoiding the cost of reflection.&lt;/u&gt;&lt;br /&gt;&lt;br /&gt;TRY it and GET it !&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Definitions : &lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdatadatacolumnclasscolumnnametopic.asp" target="_blank"&gt;DataColumn.ColumnName Property&lt;/a&gt; | &lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdatadatacolumnclassdatatypetopic.asp" target="_blank"&gt;DataColumn.DataType Property&lt;/a&gt; | &lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemDataDataColumnClassExpressionTopic.asp" target="_blank"&gt;DataColumn.Expression Property&lt;/a&gt; | &lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemtypeclasstopic.asp" target="_blank"&gt;Type Class&lt;/a&gt; | &lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdatadatacolumncollectionclassaddtopic.asp"&gt; DataColumnCollection.Add() &lt;/a&gt; | &lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemWebUIWebControlsDataGridItemClassDataItemTopic.asp" target="_blank"&gt;DataGridItem.DataItem&lt;/a&gt; | &lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdatadatarowviewclasstopic.asp" target="_blank"&gt;DataRowView Class&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;See Also : &lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag/html/scalenetchapt06.asp" target="_blank"&gt; Improving ASP.NET Performance [MSDN]&lt;/a&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11070696-110949477391907418?l=alvinzc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alvinzc.blogspot.com/feeds/110949477391907418/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=11070696&amp;postID=110949477391907418' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/110949477391907418'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/110949477391907418'/><link rel='alternate' type='text/html' href='http://alvinzc.blogspot.com/2005/02/displaying-2-field-names-in-1-column.html' title='Displaying 2 Field Names  in 1 Column of DataGrid'/><author><name>Alvin Chooi</name><uri>http://www.blogger.com/profile/16063910632877857756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11070696.post-110949079893792170</id><published>2005-02-26T23:44:00.000-08:00</published><updated>2006-10-30T06:54:56.783-08:00</updated><title type='text'>Showing number of records at footer in DataGrid (Pt. 2)</title><content type='html'>&lt;span style="font-family:verdana;font-size:8pt;"&gt;&lt;br /&gt;This is my second part of the &lt;strong&gt;"Showing number of records at footer in DataGrid"&lt;/strong&gt;. In the first part, I showed how to do it when you using &lt;em&gt;&lt;strong&gt;SqlDataReader&lt;/strong&gt;&lt;/em&gt;. And now, I show how can it be done if you are using &lt;em&gt;&lt;strong&gt;DataSet&lt;/strong&gt;&lt;/em&gt;. Compared to the &lt;em&gt;&lt;strong&gt;SqlDataReader&lt;/strong&gt;&lt;/em&gt;, it is much easier for you using &lt;em&gt;&lt;strong&gt;DataSet&lt;/strong&gt;&lt;/em&gt;.&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;&lt;u&gt;DataSet&lt;/u&gt;&lt;/h3&gt;DataSet object is always a &lt;u&gt;disconnected recordset&lt;/u&gt;. It is the core of the ADO.NET disconnected architecture. Unlike DataReader, it is not connected to the database. It is filled by the SqlDataAdapter (a bridge between the connected and disconnected objects), which associates with the Database. Behind the scenes, a SqlDataReader is created implicitly and the rowset is retrieved one row at a time in succession and sent to the DataSet. Once all the data is in the DataSet, the implicit &lt;em&gt;&lt;strong&gt;SqlDataReader&lt;/strong&gt;&lt;/em&gt; is destroyed and the SqlConnection is closed.&lt;br /&gt;&lt;br /&gt;&lt;em&gt;&lt;strong&gt;DataSet&lt;/strong&gt;&lt;/em&gt; is &lt;u&gt;fully navigable&lt;/u&gt;. It can traverse forward and backward, which unlike the &lt;em&gt;&lt;strong&gt;SqlDataReader&lt;/strong&gt;&lt;/em&gt; that moves forward only. Also, the &lt;em&gt;&lt;strong&gt;DataSet&lt;/strong&gt;&lt;/em&gt; is &lt;u&gt;flexible&lt;/u&gt; since the DataTables in the it can be sorted, filtered and searched. Also, it is &lt;u&gt;fully bindable&lt;/u&gt;. it can be bound to the data source of data controls every time. The &lt;em&gt;&lt;strong&gt;DataSet&lt;/strong&gt;&lt;/em&gt; can &lt;u&gt;reduce the roundtrip&lt;/u&gt; to the database server, but, however, it &lt;u&gt;increases the memory footprint&lt;/u&gt; in where it is stored. If you are retrieving 1 million of records, these records will be stored in the memory, which occupies the system resources. &lt;br /&gt;&lt;br /&gt;Therefore, you have to be careful which one you are using. If you just merely want to view or display the data, always stick with the SqlDataReader ; if you would like to sort, filter , search the retrieved data, you can consider the DataSet. Nevertheless, there are some situations where you must use &lt;em&gt;&lt;strong&gt;DataSet&lt;/strong&gt;&lt;/em&gt;. For instance, when doing paging in DataGrid, the &lt;em&gt;&lt;strong&gt;DataSet&lt;/strong&gt;&lt;/em&gt; is needed because it requires your data source implements &lt;em&gt;&lt;strong&gt;ICollection&lt;/strong&gt;&lt;/em&gt; interface.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;See Also : &lt;a href="http://www.sitepoint.com/article/dataset-datareader" target="_blank"&gt;DataSet Vs. DataReader [sitepoint] &lt;/a&gt; | &lt;a href="http://msdn.microsoft.com/msdnmag/issues/04/06/DataPoints/default.aspx"&gt;Contrasting the ADO.NET DataReader and DataSet [MSDN Magazine]&lt;/a&gt; &lt;br /&gt;&lt;br /&gt;Definition : &lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemcollectionsicollectionclasstopic.asp" target="_blank"&gt; ICollection interface [MSDN]&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="background-color:#f7f7f7"&gt;&lt;br /&gt;&amp;lt;script&amp;gt;&lt;br /&gt;&lt;strong&gt;DataSet&lt;/strong&gt; dsAuthors = new DataSet();&lt;br /&gt;&lt;br /&gt;protected void &lt;b&gt;Page_Load&lt;/b&gt;(Object sender, EventArgs e)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if(!&lt;b&gt;IsPostBack&lt;/b&gt;)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;strong&gt;using&lt;/strong&gt;(SqlConnection conPubs = new SqlConnection())&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;conPubs.ConnectionString = "Server=DOTNET;uid=sa;database=pubs";&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;strong&gt;SqlDataAdapter&lt;/strong&gt; daSelectAuthors = new &lt;strong&gt;SqlDataAdapter&lt;/strong&gt;("SELECT au_id, au_fname, au_lname, phone FROM Authors",conPubs);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;conPubs.Open();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;daSelectAuthors.&lt;strong&gt;Fill&lt;/strong&gt;(dsAuthors,"Authors");&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;dgrdAuthors.DataSource = dsAuthors.Tables["Authors"].DefaultView;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;dgrdAuthors.DataBind();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;}&lt;br /&gt;&amp;lt;/script&amp;gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Here, I am not going to explain the code line by line since I explained it in my &lt;a href="http://alvinzc.blogspot.com/2005/02/showing-number-of-records-at-footer-in.html"&gt;previous article&lt;/a&gt;. Instead of using the &lt;em&gt;&lt;strong&gt;SqlCommand&lt;/strong&gt;&lt;/em&gt;, I use the &lt;em&gt;&lt;strong&gt;SqlDataAdapter&lt;/strong&gt;&lt;/em&gt;, which in turn will fill the &lt;em&gt;&lt;strong&gt;DataSet&lt;/strong&gt;&lt;/em&gt; with the DataTable named &lt;em&gt;&lt;strong&gt;"Authors"&lt;/strong&gt;&lt;/em&gt;. After that, I bind the DataTable to the data source of the DataGrid. Note that I declare the DataSet outside of the &lt;em&gt;&lt;strong&gt;Page_Load()&lt;/strong&gt;&lt;/em&gt; event because it can be used in the &lt;em&gt;&lt;strong&gt;ItemDataBound&lt;/strong&gt;&lt;/em&gt; event later. Simple ?&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;In the &lt;em&gt;&lt;strong&gt;ItemDataBound&lt;/strong&gt;&lt;/em&gt; event,&lt;br /&gt;&lt;br /&gt;&lt;div style="background-color:#f7f7f7"&gt;&lt;br /&gt;protected void dgrdAuthors_&lt;strong&gt;ItemDataBound&lt;/strong&gt;(Object sender, DataGridItemEventArgs e)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if(e.Item.ItemType == ListItemType.&lt;strong&gt;Footer&lt;/strong&gt;)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;strong&gt;TableCellCollection&lt;/strong&gt; cells = e.Item.Cells;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;int iCount = dsAuthors.Tables["Authors"].Rows.&lt;strong&gt;Count&lt;/strong&gt;; // &lt;em&gt;obtaining total rows in the data table.&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;cells.&lt;strong&gt;RemoveAt(0)&lt;/strong&gt;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;cells.&lt;strong&gt;RemoveAt(0)&lt;/strong&gt;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;cells.&lt;strong&gt;RemoveAt(0)&lt;/strong&gt;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;cells[0].&lt;strong&gt;ColumnsSpan&lt;/strong&gt;= 4;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if(iCount!=0)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;cells[0].HorizontalAlign = HorizontalAlign.&lt;strong&gt;Right&lt;/strong&gt;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;cells[0].Text = String.Format("{0} records found",iCount.ToString());&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;else&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;cells[0].HorizontalAlign = HorizontalAlign.&lt;strong&gt;Center&lt;/strong&gt;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;cells[0].Text = "No record found";&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;}&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Is this code looked simpler? Yes, we do not need to count the number of data in the datagrid one by one because we are able to the get the total rows in the &lt;em&gt;&lt;strong&gt;rows.count&lt;/strong&gt;&lt;/em&gt; property of the &lt;em&gt;&lt;strong&gt;"Authors"&lt;/strong&gt;&lt;/em&gt; DataTable of the DataSet. Instead of calling the &lt;em&gt;&lt;strong&gt;e.Item.Cells&lt;/strong&gt;&lt;/em&gt; everytime, I assign it to the variable &lt;em&gt;&lt;strong&gt;cells&lt;/strong&gt;&lt;/em&gt; with type of &lt;em&gt;&lt;strong&gt;TableCellCollection&lt;/strong&gt;&lt;/em&gt;. Therefore, it is more readable with less typing errors. For the subsequent codes, it is similar to what the &lt;a href="http://alvinzc.blogspot.com/2005/02/showing-number-of-records-at-footer-in.html"&gt;previous article&lt;/a&gt; does.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Definitions : &lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwebuiwebcontrolstablecellcollectionclasstopic.asp" target="_blank"&gt;TableCellCollection [MSDN] &lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;- The End - &lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11070696-110949079893792170?l=alvinzc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alvinzc.blogspot.com/feeds/110949079893792170/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=11070696&amp;postID=110949079893792170' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/110949079893792170'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/110949079893792170'/><link rel='alternate' type='text/html' href='http://alvinzc.blogspot.com/2005/02/showing-number-of-records-at-footer-in_26.html' title='Showing number of records at footer in DataGrid (Pt. 2)'/><author><name>Alvin Chooi</name><uri>http://www.blogger.com/profile/16063910632877857756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11070696.post-110944066709781885</id><published>2005-02-26T09:57:00.000-08:00</published><updated>2006-10-30T06:54:56.606-08:00</updated><title type='text'>Showing Number of Records at Footer In DataGrid (Pt. 1)</title><content type='html'>&lt;span style="font-size:8pt;"&gt;&lt;br /&gt;&lt;div align="center"&gt;&lt;br /&gt;&lt;a href='http://photos1.blogger.com/img/219/3801/640/recordfound.1.jpg'&gt;&lt;img border='0' style='border:1px solid #000000; margin:2px' src='http://photos1.blogger.com/img/219/3801/320/recordfound.1.jpg'&gt;&lt;/a&gt;&lt;br /&gt;Showing number of records in DataGrid&amp;nbsp;&lt;a href='http://www.hello.com/' target='ext'&gt;&lt;img src='http://photos1.blogger.com/pbh.gif' alt='Posted by Hello' border='0' style='border:0px;padding:0px;background:transparent;' align='absmiddle'&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;When displaying the data in the DataGrid, you likely want to show the total records that are listed in the grid. When there is no data available, the ASP.NET will generate a blank datagrid that has column names but does not have any data inside, which isn't what we wanted.&lt;br /&gt;&lt;br /&gt;In this article, I will show you how to display the &lt;strong&gt;"XX records found"&lt;/strong&gt;  at the footer, and show &lt;strong&gt;"No record found"&lt;/strong&gt; when there is no data in the datagrid. Same thing, I use the Pub database and Author table in my following example. In this example, I will use &lt;strong&gt;SqlDataReader&lt;/strong&gt; and &lt;strong&gt;DataSet&lt;/strong&gt; to accomplish this job.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;&lt;strong&gt;&lt;u&gt;SqlDataReader&lt;/u&gt;&lt;/strong&gt;&lt;/h3&gt;First, let me talk about the introduction of &lt;em&gt;&lt;strong&gt;SqlDataReader&lt;/strong&gt;&lt;/em&gt;. The &lt;em&gt;&lt;strong&gt;SqlDataReader&lt;/strong&gt;&lt;/em&gt;, which implements the &lt;em&gt;&lt;strong&gt;IDataReader&lt;/strong&gt;&lt;/em&gt; interface, is &lt;u&gt;connected&lt;/u&gt;, &lt;u&gt;read-only&lt;/u&gt; and &lt;u&gt;forward-only&lt;/u&gt; (also called firehose cursor of ADO.NET). It is &lt;u&gt;a stream of data&lt;/u&gt; that is returned from query of database. It can read one row at a time from database and can only move forward. Those rows retrieved from database by &lt;em&gt;&lt;strong&gt;SqlDataReader&lt;/strong&gt;&lt;/em&gt; can be read, but they cannot be edited. However, the &lt;em&gt;&lt;strong&gt;SqlDataReader&lt;/strong&gt;&lt;/em&gt; has to &lt;u&gt;maintain its connection to the data source&lt;/u&gt; (stay connected) and it is &lt;u&gt;partially bindable&lt;/u&gt;. (It is bindable for only one time, unless you resetting the cursor to the beginning)&lt;br /&gt;&lt;br /&gt;Back to the matter, here is my code, which can be placed in the script tag or in the code-behind of the ASP.NET page. For me, I put it in the script tag.&lt;br /&gt;&lt;br /&gt;&lt;div style="background-color:#f7f7f7"&gt;&lt;br /&gt;&amp;lt;script&amp;gt;&lt;br /&gt;protected void &lt;b&gt;Page_Load&lt;/b&gt;(Object sender, EventArgs e)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if(!&lt;b&gt;IsPostBack&lt;/b&gt;)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;strong&gt;using&lt;/strong&gt;(SqlConnection conPubs = new SqlConnection())&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;conPubs.ConnectionString = "Server=DOTNET;uid=sa;database=pubs";&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;SqlCommand cmdSelectAuthors = new SqlCommand("SELECT au_id, au_fname, au_lname, phone FROM Authors",conPubs);&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;try&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;conPubs.Open();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;dgrdAuthors.DataSource = cmdSelectAuthors.ExecuteReader();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;dgrdAuthors.DataBind();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;catch(SqlException ex)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Response.Write(ex.Message);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;finally&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if(conPubs.State == ConnectionState.Open)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;conPubs.Close();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;}&lt;br /&gt;&amp;lt;/script&amp;gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;At the very first line of the &lt;em&gt;&lt;strong&gt;Page_Load&lt;/strong&gt;&lt;/em&gt; event, I use the if statement the check whether it is &lt;em&gt;&lt;strong&gt;IsPostBack&lt;/strong&gt;&lt;/em&gt;. Normally, we only need to bind the data from data source to DataGrid once - first time the page is loaded, but not everytime the page is requested. It could reduce the roundtrip to the database server. In the following line, I use the &lt;em&gt;&lt;strong&gt;using&lt;/strong&gt;&lt;/em&gt; block, that is, when the the code exits the &lt;em&gt;&lt;strong&gt;using&lt;/strong&gt;&lt;/em&gt; block, the SqlConnection object will be disposed automatically. &lt;em&gt;[However, some saying that it is inefficient to wait until the GC to dispose the SqlConnection object. Erm.. it depends on you, if you dont use this method, then call the Close() method manually. * Close the connection as soon as possible. ]&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;Then, I assign the &lt;em&gt;&lt;strong&gt;ConnectionString&lt;/strong&gt;&lt;/em&gt; property with the correct value. Next, I retrieve 4 fields in the &lt;em&gt;Author&lt;/em&gt; table, open the connection and run the bind the a data reader which is returned by result of &lt;em&gt;&lt;strong&gt;ExecuteReader()&lt;/strong&gt;&lt;/em&gt; to the datagrid.&lt;br /&gt;&lt;br /&gt;Definitions : &lt;a href="http://www.c-sharpcorner.com/Code/2002/Dec/UsingStatement.asp" target="_blank"&gt;The "Using" Statement in C#&lt;/a&gt; | &lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/csref/html/vclrfusingstatement.asp" target="_blank"&gt;using Statement [MSDN]&lt;/a&gt; | &lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemDataSqlClientSqlDataReaderClassTopic.asp" target="_blank"&gt;SqlDataReader class &lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;In the &lt;em&gt;&lt;strong&gt;ItemDataBound&lt;/strong&gt;&lt;/em&gt; event,&lt;br /&gt;&lt;br /&gt;&lt;div style="background-color:#f7f7f7"&gt;&lt;br /&gt;int iCount = 0;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;i&gt; // count the number of items&lt;/i&gt;&lt;br /&gt;protected void dgrdAuthors_&lt;strong&gt;ItemDataBound&lt;/strong&gt;(Object sender, DataGridItemEventArgs e)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if(e.Item.ItemType == ListItemType.&lt;strong&gt;Item&lt;/strong&gt; || e.Item.ItemType == ListItemType.&lt;strong&gt;AlternatingItem&lt;/strong&gt;)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;i&gt;// .... do other things here&lt;/i&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;iCount++;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;else if(e.Item.ItemType == ListItemType.&lt;strong&gt;Footer&lt;/strong&gt;)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;e.Item.Cells.&lt;strong&gt;RemoveAt(0)&lt;/strong&gt;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;e.Item.Cells.&lt;strong&gt;RemoveAt(0)&lt;/strong&gt;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;e.Item.Cells.&lt;strong&gt;RemoveAt(0)&lt;/strong&gt;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;e.Item.Cells[0].&lt;strong&gt;ColumnsSpan&lt;/strong&gt;= 4;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if(iCount!=0)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;e.Item.Cells[0].HorizontalAlign = HorizontalAlign.&lt;strong&gt;Right&lt;/strong&gt;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;e.Item.Cells[0].Text = String.Format("{0} records found",iCount.ToString());&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;else&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;e.Item.Cells[0].HorizontalAlign = HorizontalAlign.&lt;strong&gt;Center&lt;/strong&gt;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;e.Item.Cells[0].Text = "No record found";&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;}&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Repeating what the &lt;em&gt;&lt;strong&gt;ItemDataBound&lt;/strong&gt;&lt;/em&gt; event is, the &lt;em&gt;&lt;strong&gt;ItemDataBound&lt;/strong&gt;&lt;/em&gt; event is fired when the data is bound to each row of the datagrid. Therefore, this event is the best place for us to count the number of data in the grid. In the code above, I declare an integer-type variable with value of 0. Its value increments to 1 whenever a data is bound to the row, so that we could know how many data are actually in the datagrid. Remember, I exclude the header and footer, which are not counted in.&lt;br /&gt;&lt;br /&gt;At the footer, I merge the 4 cells in the row by calling the removing the cells 3 times before merging it. For more information about merging cells, you can read my previous article &lt;a href="http://alvinzc.blogspot.com/2005/02/merging-cells-in-datagrid.html" target="_blank"&gt;Merging Cells in DataGrid&lt;/a&gt;. Then, I check whether there is any incrementation of value of iCount. If yes, that means there is data in the DataGrid. I set to the &lt;em&gt;&lt;strong&gt;HorizontalAlign&lt;/strong&gt;&lt;/em&gt; to Right, which will display the &lt;em&gt;&lt;strong&gt;"XX records found"&lt;/strong&gt;&lt;/em&gt; on the right hand side. Otherwise, it will be showing the &lt;em&gt;&lt;strong&gt;"No record found"&lt;/strong&gt;&lt;/em&gt; at the center of the footer row.&lt;br /&gt;&lt;br /&gt;Since this article is quite lengthy, I will separate the one using &lt;em&gt;&lt;strong&gt;DataSet&lt;/strong&gt;&lt;/em&gt; in part 2 of this article.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Definitions : &lt;a target="_blank" href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwebuiwebcontrolsdatagridclassitemdataboundtopic.asp"&gt; OnItemDataBound event&lt;/a&gt; | &lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwebuiwebcontrolsdatalistitemclassitemtypetopic.asp"&gt;DataGrid's ItemTypes&lt;/a&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11070696-110944066709781885?l=alvinzc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alvinzc.blogspot.com/feeds/110944066709781885/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=11070696&amp;postID=110944066709781885' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/110944066709781885'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/110944066709781885'/><link rel='alternate' type='text/html' href='http://alvinzc.blogspot.com/2005/02/showing-number-of-records-at-footer-in.html' title='Showing Number of Records at Footer In DataGrid (Pt. 1)'/><author><name>Alvin Chooi</name><uri>http://www.blogger.com/profile/16063910632877857756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11070696.post-110943169111124149</id><published>2005-02-26T07:27:00.000-08:00</published><updated>2006-10-30T06:54:56.493-08:00</updated><title type='text'>Merging Cells in DataGrid</title><content type='html'>&lt;span style="font-family:verdana;font-size:8pt;"&gt;&lt;br /&gt;&lt;div align="center"&gt;&lt;a href='http://photos1.blogger.com/img/219/3801/640/mergecells.jpg'&gt;&lt;img border='0' style='border:1px solid #000000; margin:2px' src='http://photos1.blogger.com/img/219/3801/320/mergecells.jpg'&gt;&lt;/a&gt;&lt;br /&gt;Merging Cells in DataGrid&amp;nbsp;&lt;a href='http://www.hello.com/' target='ext'&gt;&lt;img src='http://photos1.blogger.com/pbh.gif' alt='Posted by Hello' border='0' style='border:0px;padding:0px;background:transparent;' align='absmiddle'&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;By default, all the data bound to the DataGrid are displayed in the tabular form, which is like an ordinary table. But, however, sometimes we neeed to adjust or change the appearance of the grid so that the displaying data would be presented nicely and clearly. And here is the reason this article comes about. I would like to show you how to merge the cells (columns in a row) in the DataGrid.&lt;br /&gt;&lt;br /&gt;As what I said in my &lt;a href="http://alvinzc.blogspot.com/2005/02/changing-rows-background-color-in.html"&gt;first article&lt;/a&gt; before, the &lt;strong&gt;&lt;em&gt;onItemCreated&lt;/em&gt;&lt;/strong&gt; event is the great place for us to edit and change the appearance of the datagrid. ( not to forget about the &lt;em&gt;&lt;strong&gt;ItemDataBound&lt;/strong&gt;&lt;/em&gt; event, too).&lt;br /&gt;&lt;br /&gt;In the example below, I use the Pubs as my database, retrieving au_id, au_fname and au_lname fields frome the Authors table. Then, I would like to merge the 2nd and 3rd cells at the header, and all cells at the footer there.&lt;br /&gt;&lt;br /&gt;&lt;div style="background-color:#f7f7f7"&gt;&lt;br /&gt;protected void &lt;strong&gt;dgrdAuthors_ItemCreated&lt;/strong&gt;(Object sender, DataGridItemEventArgs e)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;i&gt;// if it is header&lt;/i&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if(e.Item.ItemType == ListItemType.&lt;b&gt;Header&lt;/b&gt;)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;e.Item.Cells.&lt;strong&gt;RemoveAt(2)&lt;/strong&gt;; &lt;i&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Removing 3rd cell&lt;/i&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;e.Item.Cells[1].&lt;strong&gt;ColumnSpan&lt;/strong&gt;=2; &lt;i&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Merging 2nd and 3rd cells &lt;/i&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;e.Item.Cells[0].Text = "Author ID";&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;e.Item.Cells[1].Text = "Author Full Names";&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;else if(e.Item.ItemType == ListItemType.&lt;b&gt;Footer&lt;/b&gt;)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;e.Item.Cells.&lt;strong&gt;RemoveAt(0)&lt;/strong&gt;; &lt;i&gt;  &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Removing the first cell&lt;/i&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;e.Item.Cells.&lt;strong&gt;RemoveAt(0)&lt;/strong&gt;; &lt;i&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Removing the second cell &lt;/i&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;e.Item.Cells[0].HorizontalAlign = HorizontalAlign.Center;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;e.Item.Cells[0].Text = " End of Records";&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;}&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;u&gt;Header part&lt;/u&gt;&lt;/strong&gt;&lt;br/&gt;&lt;br /&gt;In the code above, first, I check whether the current row created is Header of the DataGrid. If it is header, then I remove the 3rd cell (which is au_lname field) of the row by using the &lt;em&gt;&lt;strong&gt;RemoveAt()&lt;/strong&gt;&lt;/em&gt;. This method will remove the particular cell at the specified position. I call &lt;em&gt;&lt;strong&gt;RemoveAt(2)&lt;/strong&gt;&lt;/em&gt;, which removes the 3rd cell (always start with 0). Then, I merge the column 2 and 3 (au_fname and au_lname) by assigning the &lt;em&gt;&lt;strong&gt;ColumnSpan&lt;/strong&gt;&lt;/em&gt; property to 2, which takes up 2 cells in the row. &lt;br /&gt;&lt;br /&gt;As a result, the header eventually has 2 cells. 1 is cell for Author ID field, and another is merged cell for the Author Full Name. Then, I assign the text to the appropriate cells.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;u&gt;Footer part&lt;/u&gt;&lt;/strong&gt;&lt;br/&gt;&lt;br /&gt;At the footer, I would like merge all the 3 cells into 1 cell. Hence, I remove the first cell by calling the &lt;em&gt;&lt;strong&gt;RemoveAt(0)&lt;/strong&gt;&lt;/em&gt;. And you would wondering why I call this method twice. The reason is, &lt;u&gt;when I remove the first cell of the 3 cells, the second cell becomes the first cell.&lt;/u&gt; Therefore, I have to call the &lt;em&gt;&lt;strong&gt;RemoveAt(0)&lt;/strong&gt;&lt;/em&gt; once again to remove the second cell, which is already become the first cell. By now, I can merge all the cells by assigning 3 to &lt;em&gt;&lt;strong&gt;ColumnSpan&lt;/strong&gt;&lt;/em&gt; property. Also, I set the HorizontalAlign to center so that the text would be displayed at the center.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Definitions: &lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwebuiwebcontrolstablecellclasscolumnspantopic.asp" target="_blank"&gt;ColumnSpan&lt;/a&gt; | &lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemWebUIHtmlControlsHtmlTableCellCollectionClassRemoveAtTopic.asp" target="_blank"&gt;RemoveAt()&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;~~ Happy Programming ~~~&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11070696-110943169111124149?l=alvinzc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alvinzc.blogspot.com/feeds/110943169111124149/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=11070696&amp;postID=110943169111124149' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/110943169111124149'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/110943169111124149'/><link rel='alternate' type='text/html' href='http://alvinzc.blogspot.com/2005/02/merging-cells-in-datagrid.html' title='Merging Cells in DataGrid'/><author><name>Alvin Chooi</name><uri>http://www.blogger.com/profile/16063910632877857756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11070696.post-110942473639567264</id><published>2005-02-26T04:50:00.000-08:00</published><updated>2006-10-30T06:54:56.437-08:00</updated><title type='text'>Changing the Row's Background Color in DataGrid When Hovering</title><content type='html'>&lt;span style="font-family:verdana;font-size:8pt;"&gt;&lt;br /&gt;Binding data source to the DataGrid data control is simple, but adding the visual-effect on the DataGrid isn't hard too. Here, I show you the code that changing background color of the particular row when the users move the mouse pointer over the row. Since the DataGrid data control does not have the properties to let us specify the rows' backgroundcolor, thus, we have add the &lt;em&gt;&lt;strong&gt;onmouseover&lt;/strong&gt;&lt;/em&gt; and &lt;em&gt;&lt;strong&gt;onmouseout&lt;/strong&gt;&lt;/em&gt; attributes when it (DataGrid) is created (OnItemCreated event) or its data are bound to the rows.(OnDataBound). First, add the onItemCreated attribute to the DataGrid data control.&lt;br /&gt;&lt;br /&gt;&lt;div style="background-color:#f7f7f7"&gt;&lt;br /&gt;&amp;lt;asp:datagrid id="dgrdAuthors" &lt;em&gt;&lt;strong&gt;onItemCreated="dgrdAuthors_ItemCreated"&lt;/strong&gt;&lt;/em&gt; ........ /&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;then, in the &amp;lt;script&amp;gt; tag or in the code-behind, add this event (I put it in the script tag in my example). As what I have said, it can be done by putting the code in the ItemDataBound event, so just change the event name instead.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="background-color:#f7f7f7"&gt;&amp;lt;script&amp;gt;&lt;br /&gt;private void &lt;b&gt;dgrdAuthors_ItemCreated&lt;/b&gt;(Object sender, &lt;b&gt;DataGridItemEventArgs&lt;/b&gt; e)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if(e.Item.ItemType == ListItemType.&lt;b&gt;Item&lt;/b&gt; || e.Item.ItemType == ListItemType.&lt;b&gt;AlternatingItem&lt;/b&gt;)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;e.Item.Attributes.Add("onmouseover",&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;"this.style.backgroundColor='#f7f7f7';this.style.cursor='hand'");&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;e.Item.Attributes.Add("onmouseout","this.style.backgroundColor='#ffffff'");&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;}&lt;br /&gt;&amp;lt;/script&amp;gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;How does this code work? The &lt;em&gt;&lt;strong&gt;ItemCreated&lt;/strong&gt;&lt;/em&gt; event is fired when each row is created in the datagrid, just before the data is bound to the row. Therefore, it is commonly used to set the appearance of the datagrid's rows here. Whereas, the &lt;em&gt;&lt;strong&gt;ItemDataBound &lt;/strong&gt;&lt;/em&gt;event is fired when each data from the data source bound to the row. &lt;br /&gt;&lt;br /&gt;The &lt;em&gt;&lt;strong&gt;e.Item &lt;/strong&gt;&lt;/em&gt;simply represents the current data row of the datagrid. And, a datagrid consists of header, data items and footer, which are under the ListItemType enumerations. The &lt;em&gt;&lt;strong&gt;Item ItemType&lt;/strong&gt;&lt;/em&gt; represents the odd-number rows in the datagrid, and the &lt;em&gt;&lt;strong&gt;AlternatingItem ItemType&lt;/strong&gt;&lt;/em&gt; represents the even-number rows.&lt;br /&gt;&lt;br /&gt;In the code above, the &lt;em&gt;&lt;strong&gt;ItemCreated&lt;/strong&gt;&lt;/em&gt; event will be fired when each row is created. Since we do not want add the visual effect on the header and footer, we check the &lt;em&gt;&lt;strong&gt;ItemType&lt;/strong&gt;&lt;/em&gt; whether it is &lt;em&gt;&lt;strong&gt;Item&lt;/strong&gt;&lt;/em&gt; or &lt;em&gt;&lt;strong&gt;AlternatingItem&lt;/strong&gt;&lt;/em&gt;. If it is, then we add the current row with the &lt;em&gt;&lt;strong&gt;onmouseover&lt;/strong&gt;&lt;/em&gt; and &lt;em&gt;&lt;strong&gt;onmouseout&lt;/strong&gt;&lt;/em&gt; attributes, which will apply the specified styles to it.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Definitions : &lt;a target="_blank" href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwebuiwebcontrolsdatagridclassonitemcreatedtopic.asp"&gt;OnItemCreated event&lt;/a&gt; | &lt;a target="_blank" href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwebuiwebcontrolsdatagridclassitemdataboundtopic.asp"&gt; OnItemDataBound event&lt;/a&gt; | &lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwebuiwebcontrolsdatalistitemclassitemtypetopic.asp"&gt;DataGrid's ItemTypes&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;u&gt;Alternative way :&lt;/u&gt;&lt;/strong&gt;&lt;br/&gt;&lt;br /&gt;Apart from the doing it in the &lt;em&gt;&lt;strong&gt;ItemCreated&lt;/strong&gt;&lt;/em&gt; and &lt;em&gt;&lt;strong&gt;ItemDataBound&lt;/strong&gt;&lt;/em&gt; events, there is another way to accomplish the job above. In the &lt;em&gt;&lt;strong&gt;Page_Load()&lt;/strong&gt;&lt;/em&gt; event, add this &lt;br /&gt;&lt;br /&gt;&lt;div style="background-color:#f7f7f7"&gt;&lt;br /&gt;&lt;em&gt;protected void &lt;strong&gt;Page_Load()&lt;/strong&gt;&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if(!IsPostBack)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;foreach(&lt;strong&gt;DataGridItem&lt;/strong&gt; item in dgrdAuthors.Items)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;item.Attributes["onmouseover"] = "this.style.backgroundColor='#f7f7f7'";&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;item.Attributes["onmouseout"] = "this.style.backgroundColor='#ffffff'";&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;}&lt;/em&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Simple, The &lt;em&gt;&lt;strong&gt;DataGridItem&lt;/strong&gt;&lt;/em&gt; represents the data items in the datagrid. Therefore, I add the &lt;em&gt;&lt;strong&gt;onmouseover&lt;/strong&gt;&lt;/em&gt; and &lt;em&gt;&lt;strong&gt;onmouseout&lt;/strong&gt;&lt;/em&gt; attributes to every data item in the grid.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Definition: &lt;a target="_blank" href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwebuiwebcontrolsdatagriditemclasstopic.asp"&gt;DataGridItem&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Okay, I have done my first article regarding to the DataGrid Data Control. And soon, I will write more articles, basically more on the data controls in asp.net. :)&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11070696-110942473639567264?l=alvinzc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alvinzc.blogspot.com/feeds/110942473639567264/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=11070696&amp;postID=110942473639567264' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/110942473639567264'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/110942473639567264'/><link rel='alternate' type='text/html' href='http://alvinzc.blogspot.com/2005/02/changing-rows-background-color-in.html' title='Changing the Row&apos;s Background Color in DataGrid When Hovering'/><author><name>Alvin Chooi</name><uri>http://www.blogger.com/profile/16063910632877857756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11070696.post-110931651270897321</id><published>2005-02-24T23:27:00.000-08:00</published><updated>2006-10-30T06:54:56.319-08:00</updated><title type='text'>Welcome to My Blog</title><content type='html'>Hello, in very first place, thanks for visiting this blog. Basically, I will write my own articles regarding to the ASP.NET ( more on Data Controls). Of course, if my information given incorrect, feel free to drop comments here.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11070696-110931651270897321?l=alvinzc.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://alvinzc.blogspot.com/feeds/110931651270897321/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=11070696&amp;postID=110931651270897321' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/110931651270897321'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11070696/posts/default/110931651270897321'/><link rel='alternate' type='text/html' href='http://alvinzc.blogspot.com/2005/02/welcome-to-my-blog.html' title='Welcome to My Blog'/><author><name>Alvin Chooi</name><uri>http://www.blogger.com/profile/16063910632877857756</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
