<?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-7527040749709927669</id><updated>2012-02-16T17:37:07.396-08:00</updated><title type='text'>ASP.NET</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://jaan1762.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://jaan1762.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Mansoor</name><uri>http://www.blogger.com/profile/00473621254256960630</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>77</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-7527040749709927669.post-7508790482344811321</id><published>2011-12-21T02:49:00.000-08:00</published><updated>2011-12-21T02:52:33.013-08:00</updated><title type='text'>Mutually exclusive checkboxes with jQuery</title><content type='html'>&lt;html&gt;&lt;br /&gt;  &lt;head&gt;&lt;br /&gt;      &lt;script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"&gt;&lt;/script&gt;&lt;br /&gt;      &lt;script type="text/javascript" language="javascript"&gt;&lt;br /&gt;          $(document).ready(function() {&lt;br /&gt;              $('.mutuallyexclusive').click(function () {&lt;br /&gt;                  checkedState = $(this).attr('checked');&lt;br /&gt;                  $('.mutuallyexclusive:checked').each(function () {&lt;br /&gt;                      $(this).attr('checked', false);&lt;br /&gt;                  });&lt;br /&gt;                  $(this).attr('checked', checkedState);&lt;br /&gt;              });&lt;br /&gt;          });&lt;br /&gt;      &lt;/script&gt;&lt;br /&gt;  &lt;/head&gt;&lt;br /&gt;  &lt;body&gt;&lt;br /&gt;      &lt;div&gt;&lt;br /&gt;          Red: &lt;input id="chkRed" name="chkRed" type="checkbox" value="red" class="mutuallyexclusive"&gt;&lt;br /&gt;          Blue: &lt;input id="chkBlue" name="chkBlue" type="checkbox" value="blue" class="mutuallyexclusive"&gt;&lt;br /&gt;          Green: &lt;input id="chkGreen" name="chkGreen" type="checkbox" value="green" class="mutuallyexclusive"&gt;&lt;br /&gt;      &lt;/div&gt;&lt;br /&gt;  &lt;/body&gt;&lt;br /&gt;&lt;/html&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7527040749709927669-7508790482344811321?l=jaan1762.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jaan1762.blogspot.com/feeds/7508790482344811321/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7527040749709927669&amp;postID=7508790482344811321' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/7508790482344811321'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/7508790482344811321'/><link rel='alternate' type='text/html' href='http://jaan1762.blogspot.com/2011/12/mutually-exclusive-checkboxes-with.html' title='Mutually exclusive checkboxes with jQuery'/><author><name>Mansoor</name><uri>http://www.blogger.com/profile/00473621254256960630</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-7527040749709927669.post-39884932814202679</id><published>2010-08-31T23:48:00.000-07:00</published><updated>2010-08-31T23:49:17.584-07:00</updated><title type='text'>MS CRM QUestions</title><content type='html'>What is the difference between Role Based and Object Based Security Model in MSCRM?&lt;br /&gt;Code based security is entirely coded in the application itself. Role based security uses one of the authentication/authorization mechanisms of the application server.&lt;br /&gt;The fundamental concept in role-based security is that of privilege, defined at design time, on a system-wide basis. Each user has a set of privileges (there are well over a hundred privileges) that are enabled for that user. However, Policies and Roles grant privileges and simplify the process.&lt;br /&gt;The other form of security applies to individual instances of objects. There is a fundamental difference between an access right and a privilege: an access right is a right granted to a user on an object), but a privilege is a right granted to a user on a class of objects. Access rights apply only after privileges have taken effect. In other words, if a user does not have the privilege to read accounts, the user will not be able to read any account, whether or not it has been shared.&lt;br /&gt;&lt;br /&gt;Difference between Find and Advanced Find? Which one is faster and Why?&lt;br /&gt;Find perform a search on an attribute for which it is defined. Advanced Find perform search on the conditions and the attributes for which user customizes or runs it. Normal Find in faster as it looks for one attributes and matches with that and returns the result whereas Advanced Find searches for all the attributes and conditions while parsing through the records.&lt;br /&gt;Find is applicable on only active records and it finds only on 2 or 3 column which we have defined in the find view and even it returns any those column which is there in the view but advanced find is applicable to all the records and it finds all the columns and even it returns all the column and filter criteria can be on any column and most important - find filters on just one condition but adv find filters on multiple condition at one time.. Find is faster than Advanced Find.&lt;br /&gt;&lt;br /&gt;Difference between CRM Discovery Service and CRM Metadataservice?&lt;br /&gt;CRM service - when we need ORG related information like ORG name, Properties, CRM service path for this ORG -- then we use CRM discovery service..this is only to get the ORG related information&lt;br /&gt;Meta data service - we use this when we need to interact with the CRM records – create, update or delete anything-- it is very specific to the CRM records. When we need to interact with the CRM entity and attribute -- like create an entity (not record) or attribute -- add a value to pick list-- retrieve the pick list value retrieve the entity properties-- attribute property and all we need Meta data service.&lt;br /&gt;&lt;br /&gt;Difference between Plug-in and Workflows?&lt;br /&gt;RequirementPlug-inWorkflowNeeds a synchronous action to happen before or after an event occursXThe same piece of logic will be executed for different events and possibly on different entities XxThe logic needs to be executed while offlineXNeeds elevation of privileges (impersonation)XNeeds to execute on events other than assign, create, update, set stateXThe process/logic may take a long time to complete or will be a persistent process (multiple long running steps)xNeeds an asynchronous actionXxEnd users will need to modify the process logicxChild sub processes will be triggered x&lt;br /&gt;&lt;br /&gt;Whenever you install MSCRM what all databases get created?&lt;br /&gt;MSCRM_Config and MSCRM_orgname&lt;br /&gt;&lt;br /&gt;Whenever you install MSCRM what all user groups get created in Active Directory?&lt;br /&gt;UserGroupAll Microsoft CRM users . This group is updated automatically as users are added and removed from Microsoft CRM. &lt;br /&gt;ReportingGroupA group that contains all users within Microsoft CRM. This group is updated as users are added to Microsoft CRM. Users in this group have read-only access to the filtered views in the Microsoft CRM database. &lt;br /&gt;PrivUserGroupPrivileged Microsoft CRM user group for special administrative functions.  &lt;br /&gt;SQLAccessGroupA group that contains Microsoft CRM ASP.NET account and other service accounts. Members in this group have full access to the Microsoft CRM database and this group is used by the Microsoft CRM platform layer. End users should never be added to this group&lt;br /&gt;&lt;br /&gt;Difference between MSCRM3.0 and MSCRM4.0?&lt;br /&gt;Multiple organizations can now be hosted and WSDL APIs are now unique per organization in MSCRM4.0.&lt;br /&gt;The metadata API service has been extended to retrieve language information in MSCRM4.0.&lt;br /&gt;Plug-ins (callouts) and workflow now use the same event framework, allowing for even more extensibility.&lt;br /&gt;The SDK has been expanded to include offline access.&lt;br /&gt;Now we can programmatically create, read, update and delete the metadata such as entities, attributes and relationship.&lt;br /&gt;There are three services instead of two which we used to have in previous version &lt;br /&gt;Many to Many Relationship was not available in MSCRM3.0&lt;br /&gt;Multicurrency feature was not available in MSCRM3.0&lt;br /&gt;What is 'Append' and 'Append To' privilege in MSCRM? Give one example of it?Ans: 'Append' and 'Append To' priviledges works together. 'Append To' priviledge will allow other entities to get attached with the entity. 'Append' priviledge will allow the entity to attach the records to the entity with 'Append To' privildege.Let us understand this with simple example:Let us say that you want to attach a note to a case then note entity should have 'Append' access right and case entity should have 'Append To' access right.Let us take one more example to understand this. Suppose you have two custom entities called 'TestCustomEntity1' and 'TestCustomEntity2'. You want to attach the 'TestCustomeEntity2' records to 'TestCustomEntity1'records. For this you need to have 'Append' access right on 'TestCustomEntity1' entity and 'Append To' access right on 'TestCustomEntity2'.Now guess will I be able to attach the records? Answer is " NO" because we need to create a 1:N relationship between 'TestCustomEntity1' and 'TestCustomEntity2'. Now the user who has above mentioned access right in his security role will only be able to add 'TestCustomEntity2' records to 'TestCustomEntity1'.&lt;br /&gt;How to create a Custom Entity record using SDK?Using Dynamic Entity.&lt;br /&gt;How to join two table using Query Expression?Using Linked entity. You should always try to minimize the number of SWS calls that we make in the database. Often during code review it is explored that the number of Microsoft CRM web-service could have been reduced by making use of the Linked-entity concept. So we should always look for the opportunity to minimize the effort.&lt;br /&gt;Can we modify the name of Root Business Unit?No; we will have to re-install MSCRM.&lt;br /&gt;Suppose if I have 20 user license and I have created 20users. What will happen if I create 21st User?The 21st User will get created in MSCRM but that user will be in disabled state.&lt;br /&gt;What is the maximum number of tabs allowed on a Microsoft Dynamics CRM 4.0 forms? 8&lt;br /&gt;How to enable/disable the form assistant? How to make sure the form assistant is expanded/collapsed on a form?Navigate to Customization &gt;&gt; Open the Entity &gt;&gt; Open Forms and Views &gt;&gt; Open Form &gt;&gt; Select Form Properties &gt;&gt; Open Display Tab &gt;&gt; Check/Uncheck the " Enable the Form Assistant" and " Expanded by Default" .The interviewer will always try to figure-out whether one is comfortable with the basic concepts of Microsoft CRM (MS CRM) or not and after that; questions will be asked from your previous experience (if you have any experience in CRM). Those questions will be something like this:&lt;br /&gt;What was your role in the MSCRM implementation project that you have worked on?You should be honest while giving answer to this question and should give a brief overview of the project and your role. This is very important question because the answers of this question will trigger so many questions. You should highlight the key skills you have; this way you will divert the attention of the interviewer to your key skills and try not to expose the area in which you are less confident.&lt;br /&gt;What was the most challenging task you have faced till now?Here you should give answer that exhibits your positive attitude. E.g. for a technical consultant it may be something like ... " I was new to the support and during this experience i faced challenging issue related to plug-in that improved my debugging skills. Email-to-case plug-in was really difficult as we had to take care of so many conditions. I have learnt one thing during my previous assignment and that is 'Never give-up'" .&lt;br /&gt;How is CRM changing and what does the business owner need to be aware of?&lt;br /&gt;At the heart of CRM is the benefit of having the customer record at the center of the data universe rather than multiple galaxies of transactions held in separate, transaction-specific apps. So the innovation lies in new and improved visibility for putting information to use in intelligent decision making. Companies that used to serve 100 are serving 10,000, and with this kind of scaling, better top-level tools and custom dashboards are where I see CRM continuing to morph and advance.&lt;br /&gt;19. Who are the newcomers to the CRM landscape?&lt;br /&gt;It is such a hot area right now, there are literally hundreds. But two I have been following are Zoho and HighRise. Both are niche vendors that have garnered great contact lists with their other products and created relatively simple implementations for their clients and others. They both illustrate the fact that CRM is no longer esoteric — it is going mainstream, which is a great thing for business, particularly customer service and data security.&lt;br /&gt;20. How much should I plan to spend on a good solution?&lt;br /&gt;That’s always a tough question, given that applications vary widely in price based on whether it’s a hosted or installed delivery model, user-based or organization-wide subscription model, or a per-gigabyte or other data model. I would use the cost-per-sale and cost-per-lead values to help determine what a system is worth to a business. For most customers, services are going to be anywhere from $20 to $350 per month per user.&lt;br /&gt;What exactly should I be expecting CRM to do for me?&lt;br /&gt;This is an important question, as there are many misconceptions about software and CRM in particular. Besides some fundamentals, like data security and access and ease of use, CRM will primarily help you do what you do anyway, but move it to the next level. If your main focus is customer service, CRM will help you monitor, deliver, and measure your effectiveness. If your goal is a flat organization where the right hand knows immediately what the left hand is doing, CRM will help you be informed about the customer’s world and not just what relates to your department or team.&lt;br /&gt;What are your expectations for CRM in the next five years?&lt;br /&gt;First, I expect CRM to become much more commonplace. Players like Zoho and 37signals (Highrise) are knocking down barriers to entry. I also expect to see some consolidation. I think the bigger players, like Salesforce, Microsoft, and SAP, will buy up some of their smaller rivals to build into their suites and migrate their user bases. As long as the acquiring provider keeps the connections intact during the migration and meets a similar price point, it will be a win-win. I also think we’ll be seeing more mobile-friendly applications, like Salesforce’s Visualforce and NetSuite’s iPhone, to maximize data access and timeliness.&lt;br /&gt;What are the most common mistakes you see companies make with CRM?&lt;br /&gt;Many organizations use Outlook BCM or Excel for managing their contacts, which offer no planning or setup process — just create a column or type in a field and get started. This causes problems when information is related and the flexible aspects of the previous solution are overlooked. There are real benefits that won’t happen without understanding the new vernacular; the specific way the new solution describes the data. For example, an “account” in Salesforce may not be the same as an “account” in Highrise. In fact, it might have another name altogether, such as “company.” Understanding how the particular vendor uses “leads” or “opportunities” will help to avoid a great deal of frustration.&lt;br /&gt;Do you have a few key best practices someone considering CRM can use?&lt;br /&gt;Yes, I have three that anyone can use. First, consider your future needs. Look down the road and ask “How many contacts will I have in five years?” “How many salespeople will I have?” “How many of my people will need real-time access to this information at home or on their phones and PDAs?” “How much would it cost me to replace these contacts?”&lt;br /&gt;Second, take the opportunity to clean up your data now. Moving to a CRM solution is an opportunity to start with a clean version of accurate data. De-duplicate and otherwise scrub the data to minimize the possibility of needing to import twice. For example, the flexibility of Excel and Outlook BCM allow placing incorrectly formatted information in their fields. This data will not import well without some good planning.&lt;br /&gt;Third, be sure to communicate throughout the process and get early buy-in. The biggest focus of Saleforce.com with its customers is adoption. Members of your team are influencers in their departments. Leverage their expertise and influence by building a team to help you make decisions about the solution. Even if you disagree, listening, acknowledging, and respecting will build loyalty and acceptance within the process.&lt;br /&gt;What advantages might CRM have for specific verticals?&lt;br /&gt;The answer to this question is not if but how much. Since CRM helps you do what you do better, if you are in a professional services company with long sales cycles, project terms, and frequent interactions and touch points, CRM will be exponentially more valuable to you. So service businesses, like lawyers, consultants, and accountants, are ripe for CRM but often have a technological aversion and a strong status quo to maintain.&lt;br /&gt;Does CRM fall more to sales or marketing in most organizations?&lt;br /&gt;In my experience, marketing is somewhat of a new concept in CRM. Sales is definitely involved, but most often it is operations leading the charge.&lt;br /&gt;What are my best resources for finding out more about CRM?&lt;br /&gt;One resource I would recommend any company creates for it is a one- to two-page document that answers the best practice questions above and includes input from the team. Send it to five vendors your team has selected and go over the proposals to see which companies address you as a unique business — not just with a customizable offering but as a discrete business. Here are a few good sites I would recommend to anyone considering a solution&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7527040749709927669-39884932814202679?l=jaan1762.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jaan1762.blogspot.com/feeds/39884932814202679/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7527040749709927669&amp;postID=39884932814202679' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/39884932814202679'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/39884932814202679'/><link rel='alternate' type='text/html' href='http://jaan1762.blogspot.com/2010/08/ms-crm-questions.html' title='MS CRM QUestions'/><author><name>Mansoor</name><uri>http://www.blogger.com/profile/00473621254256960630</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-7527040749709927669.post-8774196298370971024</id><published>2010-04-25T10:12:00.001-07:00</published><updated>2010-04-25T22:45:15.191-07:00</updated><title type='text'>additonal email data</title><content type='html'>&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;&lt;br /&gt;&amp;lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:asp="remove"&amp;gt;&lt;br /&gt;  &amp;lt;xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/&amp;gt;&lt;br /&gt;  &amp;lt;xsl:param name="session_name"/&amp;gt;&lt;br /&gt;  &amp;lt;xsl:template match="ServiceName"&amp;gt;&lt;br /&gt;    &amp;lt;table  border="0" cellpadding="0" cellspacing="0" width="700px" &amp;gt;&lt;br /&gt;      &amp;lt;tr&amp;gt;&lt;br /&gt;        &amp;lt;td&amp;gt;&lt;br /&gt;          &amp;lt;div id="content_area"&amp;gt;&lt;br /&gt;            &amp;lt;div class="ControlHeading"&amp;gt;&lt;br /&gt;              &amp;lt;table border="0" cellpadding="0" cellspacing="0" width="700px"&amp;gt;&lt;br /&gt;                &amp;lt;tr&amp;gt;&lt;br /&gt;                  &amp;lt;td&amp;gt;&lt;br /&gt;                    &amp;lt;div id="request_heading" style="text-align:left;"&amp;gt;&lt;br /&gt;                      &amp;lt;!--&amp;lt;xsl:value-of select="@name"/&amp;gt;--&amp;gt;&lt;br /&gt;                    &amp;lt;/div&amp;gt;&lt;br /&gt;                  &amp;lt;/td&amp;gt;&lt;br /&gt;                &amp;lt;/tr&amp;gt;&lt;br /&gt;                &amp;lt;tr&amp;gt;&lt;br /&gt;                  &amp;lt;td&amp;gt;&lt;br /&gt;                    &amp;lt;table  border="0" cellpadding="0" cellspacing="0" class="service_contentTable" style="text-align:left;"&amp;gt;&lt;br /&gt;                      &amp;lt;tr&amp;gt;&lt;br /&gt;                        &amp;lt;td&amp;gt;&lt;br /&gt;                          &amp;lt;table border="0" cellpadding="0" cellspacing="0"&amp;gt;&lt;br /&gt;                            &amp;lt;tr&amp;gt;&lt;br /&gt;                              &amp;lt;td height="5px"&amp;gt;&lt;br /&gt;                              &amp;lt;/td&amp;gt;&lt;br /&gt;                            &amp;lt;/tr&amp;gt;&lt;br /&gt;                            &amp;lt;xsl:for-each select="//Field"&amp;gt;&lt;br /&gt;                              &amp;lt;tr&amp;gt;&lt;br /&gt;                                &amp;lt;td class="labelHeading"&amp;gt;                                  &lt;br /&gt;                                  &amp;lt;xsl:choose&amp;gt;&lt;br /&gt;                                    &amp;lt;xsl:when test="contains(@label, '\n')"&amp;gt;&lt;br /&gt;                                      &amp;lt;xsl:value-of  select="substring-before(@label, '\n')"/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;xsl:value-of  select="substring-after(@label, '\n')"/&amp;gt;                                      &lt;br /&gt;                                    &amp;lt;/xsl:when&amp;gt;&lt;br /&gt;                                    &amp;lt;xsl:otherwise&amp;gt;&lt;br /&gt;                                      &amp;lt;xsl:value-of select="@label"/&amp;gt;&lt;br /&gt;                                    &amp;lt;/xsl:otherwise&amp;gt;&lt;br /&gt;                                  &amp;lt;/xsl:choose&amp;gt;                                  &lt;br /&gt;                                &amp;lt;/td&amp;gt;&lt;br /&gt;                                &amp;lt;td style="width:5px"&amp;gt;&lt;br /&gt;                                &amp;lt;/td&amp;gt;&lt;br /&gt;                                &amp;lt;td &amp;gt;&lt;br /&gt;                                  &amp;lt;xsl:if test="@type = 'TextBox'"&amp;gt;&lt;br /&gt;                     &lt;br /&gt;                                    &amp;lt;xsl:value-of select="@value"/&amp;gt;&lt;br /&gt;                                  &amp;lt;/xsl:if&amp;gt;&lt;br /&gt;                                  &amp;lt;xsl:if test="@type = 'CheckBoxList'"&amp;gt;&lt;br /&gt;                                    &amp;lt;xsl:for-each select="Listitems/Listitem"&amp;gt;&lt;br /&gt;                                      &amp;lt;xsl:if test="@selected = 'True'"&amp;gt;&lt;br /&gt;                                        &amp;lt;xsl:value-of select="@value"/&amp;gt;&lt;br /&gt;                                        &amp;lt;xsl:value-of select="','"/&amp;gt;&lt;br /&gt;                                      &amp;lt;/xsl:if&amp;gt;&lt;br /&gt;                                    &amp;lt;/xsl:for-each&amp;gt;&lt;br /&gt;                                  &amp;lt;/xsl:if&amp;gt;&lt;br /&gt;&lt;br /&gt;                                  &amp;lt;xsl:if test="@type = 'DropDownList'"&amp;gt;&lt;br /&gt;                                    &amp;lt;xsl:for-each select="Listitems/Listitem"&amp;gt;&lt;br /&gt;                                      &amp;lt;xsl:if test="@selected = 'True'"&amp;gt;&lt;br /&gt;                                        &amp;lt;xsl:value-of select="@value"/&amp;gt;&lt;br /&gt;                                        &amp;lt;xsl:value-of select="','"/&amp;gt;&lt;br /&gt;                                      &amp;lt;/xsl:if&amp;gt;&lt;br /&gt;                                    &amp;lt;/xsl:for-each&amp;gt;&lt;br /&gt;                                  &amp;lt;/xsl:if&amp;gt;&lt;br /&gt;&lt;br /&gt;                                  &amp;lt;xsl:if test="@type = 'ListBox'"&amp;gt;&lt;br /&gt;                                    &amp;lt;xsl:for-each select="Listitems/Listitem"&amp;gt;&lt;br /&gt;                                      &amp;lt;xsl:if test="@selected = 'True'"&amp;gt;&lt;br /&gt;                                        &amp;lt;xsl:value-of select="@value"/&amp;gt;&lt;br /&gt;                                        &amp;lt;xsl:value-of select="','"/&amp;gt;&lt;br /&gt;                                      &amp;lt;/xsl:if&amp;gt;&lt;br /&gt;                                    &amp;lt;/xsl:for-each&amp;gt;&lt;br /&gt;                                  &amp;lt;/xsl:if&amp;gt;&lt;br /&gt;&lt;br /&gt;                                  &amp;lt;xsl:if test="@type = 'RadioButtonList'"&amp;gt;&lt;br /&gt;                                    &amp;lt;xsl:for-each select="Listitems/Listitem"&amp;gt;&lt;br /&gt;                                      &amp;lt;xsl:if test="@selected = 'True'"&amp;gt;&lt;br /&gt;                                        &amp;lt;xsl:value-of select="@value"/&amp;gt;&lt;br /&gt;                                        &amp;lt;xsl:value-of select="','"/&amp;gt;&lt;br /&gt;                                      &amp;lt;/xsl:if&amp;gt;&lt;br /&gt;                                    &amp;lt;/xsl:for-each&amp;gt;&lt;br /&gt;                                  &amp;lt;/xsl:if&amp;gt;&lt;br /&gt;&lt;br /&gt;                                &amp;lt;/td&amp;gt;&lt;br /&gt;                              &amp;lt;/tr&amp;gt;&lt;br /&gt;                            &amp;lt;/xsl:for-each&amp;gt;&lt;br /&gt;                          &amp;lt;/table&amp;gt;&lt;br /&gt;                        &amp;lt;/td&amp;gt;&lt;br /&gt;                      &amp;lt;/tr&amp;gt;&lt;br /&gt;                    &amp;lt;/table&amp;gt;&lt;br /&gt;                  &amp;lt;/td&amp;gt;&lt;br /&gt;                &amp;lt;/tr&amp;gt;&lt;br /&gt;              &amp;lt;/table&amp;gt;&lt;br /&gt;            &amp;lt;/div&amp;gt;&lt;br /&gt;          &amp;lt;/div&amp;gt;&lt;br /&gt;        &amp;lt;/td&amp;gt;&lt;br /&gt;      &amp;lt;/tr&amp;gt;&lt;br /&gt;    &amp;lt;/table&amp;gt;&lt;br /&gt;  &amp;lt;/xsl:template&amp;gt;&lt;br /&gt;&amp;lt;/xsl:stylesheet&amp;gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7527040749709927669-8774196298370971024?l=jaan1762.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jaan1762.blogspot.com/feeds/8774196298370971024/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7527040749709927669&amp;postID=8774196298370971024' title='24 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/8774196298370971024'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/8774196298370971024'/><link rel='alternate' type='text/html' href='http://jaan1762.blogspot.com/2010/04/additonal-email-data.html' title='additonal email data'/><author><name>Mansoor</name><uri>http://www.blogger.com/profile/00473621254256960630</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>24</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7527040749709927669.post-2299931131176221384</id><published>2010-04-25T10:10:00.001-07:00</published><updated>2010-04-25T22:46:28.950-07:00</updated><title type='text'>additional info xslt</title><content type='html'>&amp;lt;?xml version="1.0" encoding="UTF-8"? &amp;gt;&lt;br /&gt;&amp;lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:asp="remove" &amp;gt;&lt;br /&gt;  &amp;lt;xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/&amp;gt;&lt;br /&gt;  &amp;lt;xsl:param name="requestoremail"/&amp;gt;&lt;br /&gt;  &amp;lt;xsl:param name="requestorlocation"/&amp;gt;&lt;br /&gt;  &amp;lt;xsl:param name="requestorpassword"/&amp;gt;  &lt;br /&gt;  &amp;lt;xsl:param name="array"/&amp;gt;&lt;br /&gt;  &amp;lt;xsl:param name="strBreak"/&amp;gt;&lt;br /&gt;&lt;br /&gt;  &amp;lt;xsl:param name="strCurrentDate"/&amp;gt;&lt;br /&gt;  &lt;br /&gt;  &amp;lt;xsl:template match="ITRAC/ServiceName"&amp;gt;&lt;br /&gt;    &amp;lt;table  border="0" cellpadding="0" cellspacing="0" width="710px" &amp;gt;&lt;br /&gt;      &amp;lt;tr&amp;gt;&lt;br /&gt;        &amp;lt;td&amp;gt;&lt;br /&gt;          &amp;lt;div id="content_area_Popup"&amp;gt;&lt;br /&gt;            &amp;lt;div class="ControlHeading"&amp;gt;&lt;br /&gt;              &amp;lt;table border="0" cellpadding="0" cellspacing="0" width="710px"&amp;gt;&lt;br /&gt;                &amp;lt;tr&amp;gt;&lt;br /&gt;                  &amp;lt;td&amp;gt;&lt;br /&gt;                    &amp;lt;div id="ModalPopuprequest_heading"&amp;gt;&lt;br /&gt;                      &amp;lt;xsl:value-of select="@name"/&amp;gt;&lt;br /&gt;                    &amp;lt;/div&amp;gt;&lt;br /&gt;                  &amp;lt;/td&amp;gt;&lt;br /&gt;                &amp;lt;/tr&amp;gt;&lt;br /&gt;                &amp;lt;tr&amp;gt;&lt;br /&gt;                  &amp;lt;td&amp;gt;&lt;br /&gt;                    &amp;lt;div id="ModalPopuprequest_Directive"&amp;gt;&lt;br /&gt;                      Please provide the detail request information below:&lt;br /&gt;                    &amp;lt;/div&amp;gt;&lt;br /&gt;                  &amp;lt;/td&amp;gt;&lt;br /&gt;                &amp;lt;/tr&amp;gt;&lt;br /&gt;                &amp;lt;tr&amp;gt;&lt;br /&gt;                  &amp;lt;td&amp;gt;&lt;br /&gt;                    &amp;lt;div id="ServicePopupInner" &amp;gt;&lt;br /&gt;                      &amp;lt;table  border="0" cellpadding="0" cellspacing="0" class="service_contentTable" &amp;gt;&lt;br /&gt;                        &amp;lt;tr&amp;gt;&lt;br /&gt;                          &amp;lt;td&amp;gt;&lt;br /&gt;                            &amp;lt;table border="0" cellpadding="2" cellspacing="0"&amp;gt;&lt;br /&gt;                              &amp;lt;tr&amp;gt;&lt;br /&gt;                                &amp;lt;td height="5px"&amp;gt;&lt;br /&gt;                                &amp;lt;/td&amp;gt;&lt;br /&gt;                              &amp;lt;/tr&amp;gt;&lt;br /&gt;                              &amp;lt;xsl:for-each select="//Field"&amp;gt;&lt;br /&gt;                                &amp;lt;tr&amp;gt;                                  &lt;br /&gt;                                  &amp;lt;xsl:if test="@id!='footername'"&amp;gt;                                    &lt;br /&gt;                                    &amp;lt;xsl:if test="@type = 'LabelHeadcol1'"&amp;gt;&lt;br /&gt;                                      &amp;lt;td colspan="3"&amp;gt;&lt;br /&gt;                                      &amp;lt;asp:Label runat="server" text="{@headtext1}" CssClass="labelHeading" /&amp;gt;&lt;br /&gt;                                      &amp;lt;/td&amp;gt;&lt;br /&gt;                                    &amp;lt;/xsl:if&amp;gt;                                                                        &lt;br /&gt;                                      &amp;lt;xsl:if test="@type = 'LabelHeadcol1'"&amp;gt;&lt;br /&gt;                                        &amp;lt;td colspan="3"&amp;gt;&lt;br /&gt;                                        &amp;lt;asp:Label runat="server" text="{@headtext2}" CssClass="labelHeading" /&amp;gt;&lt;br /&gt;                                        &amp;lt;/td&amp;gt;&lt;br /&gt;                                      &amp;lt;/xsl:if&amp;gt;                                    &lt;br /&gt;                                    &amp;lt;xsl:if test="@type = 'LabelHeadcol2'"&amp;gt;&lt;br /&gt;                                      &amp;lt;td style="width:10px"&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;                                      &amp;lt;td colspan="3"&amp;gt;&lt;br /&gt;                                        &amp;lt;asp:Label runat="server" text="{@headtext1}" CssClass="labelHeading" /&amp;gt;&lt;br /&gt;                                      &amp;lt;/td&amp;gt;&lt;br /&gt;                                    &amp;lt;/xsl:if&amp;gt;&lt;br /&gt;                                  &amp;lt;/xsl:if&amp;gt;&lt;br /&gt;                                &amp;lt;/tr&amp;gt;&lt;br /&gt;                                &amp;lt;tr&amp;gt;&lt;br /&gt;                                  &amp;lt;xsl:if test="@id!='footername'"&amp;gt;                                   &lt;br /&gt;                                    &amp;lt;td   style ="width:10px; padding:3px 3px 3px 3px;" &amp;gt;&lt;br /&gt;                                      &lt;br /&gt;                                      &amp;lt;xsl:if test="@type = 'TextBox' and @IsActiveDirectory='false' and @checkboxType='Checkbox'"&amp;gt;&lt;br /&gt;                                        &amp;lt;asp:CheckBox id="{@checkboxid}"  runat="server"  /&amp;gt;&lt;br /&gt;                                      &amp;lt;/xsl:if&amp;gt;&lt;br /&gt;                                    &amp;lt;/td&amp;gt;&lt;br /&gt;                                    &amp;lt;td&amp;gt;                                                                            &lt;br /&gt;                                      &amp;lt;xsl:if test="@type = 'TextBox' and @IsActiveDirectory='false' and @checkboxType='Checkboxindent1'"&amp;gt;&lt;br /&gt;                                        &amp;lt;asp:CheckBox id="{@checkboxid}"  runat="server"  /&amp;gt;&lt;br /&gt;                                      &amp;lt;/xsl:if&amp;gt;&lt;br /&gt;                                    &amp;lt;/td&amp;gt;&lt;br /&gt;                                    &amp;lt;td  class="labelText" valign="middle" style ="padding-left:5px"&amp;gt;&lt;br /&gt;                                      &amp;lt;xsl:variable name="strNew"&amp;gt;&amp;lt;/xsl:variable&amp;gt;                                      &lt;br /&gt;                                      &amp;lt;xsl:choose&amp;gt;&lt;br /&gt;                                        &amp;lt;xsl:when test="contains(@label, '\n')"&amp;gt;&lt;br /&gt;                                          &amp;lt;xsl:value-of  select="substring-before(@label, '\n')"/&amp;gt;                                          &lt;br /&gt;                                          &amp;lt;br/&amp;gt;&lt;br /&gt;                                          &amp;lt;p class="SubTextInPopUp"&amp;gt;&amp;lt;xsl:value-of  select="substring-after(@label, '\n')"/&amp;gt;&amp;lt;/p&amp;gt;&lt;br /&gt;                                        &amp;lt;/xsl:when&amp;gt;&lt;br /&gt;                                        &amp;lt;xsl:otherwise&amp;gt;&lt;br /&gt;                                          &amp;lt;xsl:value-of select="@label"/&amp;gt;&lt;br /&gt;                                        &amp;lt;/xsl:otherwise&amp;gt;&lt;br /&gt;                                      &amp;lt;/xsl:choose&amp;gt;&lt;br /&gt;                                        &amp;lt;asp:Label runat="server" text="{$strNew}"/&amp;gt;&lt;br /&gt;                                    &amp;lt;/td&amp;gt;&lt;br /&gt;                                    &amp;lt;td style="width:5px"&amp;gt;&lt;br /&gt;                                    &amp;lt;/td&amp;gt;&lt;br /&gt;                                    &amp;lt;td valign="top" style ="padding:3px 3px 3px 3px;" &amp;gt;&lt;br /&gt;                                      &amp;lt;xsl:if test="@type = 'Label' and @SecondColumn='true'"&amp;gt;&lt;br /&gt;                                        &amp;lt;asp:Label id ="{@id}" runat="server" text="{@label}" Font-Bold="true" /&amp;gt;&lt;br /&gt;                                      &amp;lt;/xsl:if&amp;gt;                                      &lt;br /&gt;                                      &amp;lt;xsl:if test="@type = 'TextArea'"&amp;gt;&lt;br /&gt;                                        &amp;lt;asp:TextBox id="{@id}" runat="server" text="" CssClass="inputboxpopup" height="100px" TextMode="MultiLine" /&amp;gt;&lt;br /&gt;                                      &amp;lt;/xsl:if&amp;gt;&lt;br /&gt;                                      &amp;lt;xsl:if test="@type = 'Date'"&amp;gt;&lt;br /&gt;                                        &amp;lt;asp:TextBox id="{@id}" runat="server"  CssClass="date-pick" /&amp;gt;&lt;br /&gt;                                      &amp;lt;/xsl:if&amp;gt;&lt;br /&gt;                                      &amp;lt;xsl:if test="@type = 'TextBox' and @IsActiveDirectory='false'"&amp;gt;&lt;br /&gt;                                        &amp;lt;asp:TextBox id="{@id}" runat="server" text="" CssClass="inputboxpopup"/&amp;gt;&lt;br /&gt;                                      &amp;lt;/xsl:if&amp;gt;&lt;br /&gt;                                      &amp;lt;xsl:if test="@type = 'TextBox' and @IsActiveDirectory='true' and @id='requestoremail'"&amp;gt;&lt;br /&gt;                                        &amp;lt;asp:TextBox id="{@id}" runat="server" text="{$requestoremail}" CssClass="inputboxpopup"/&amp;gt;&lt;br /&gt;                                      &amp;lt;/xsl:if&amp;gt;&lt;br /&gt;                                      &amp;lt;xsl:if test="@type = 'TextBox' and @IsActiveDirectory='true' and @id='requestorlocation'"&amp;gt;&lt;br /&gt;                                        &amp;lt;asp:TextBox id="{@id}" runat="server" text="{$requestorlocation}" CssClass="inputboxpopup"/&amp;gt;&lt;br /&gt;                                      &amp;lt;/xsl:if&amp;gt;&lt;br /&gt;                                      &amp;lt;xsl:if test="@type = 'TextBox' and @IsActiveDirectory='true' and @id='requestorregion'"&amp;gt;&lt;br /&gt;                                        &amp;lt;asp:TextBox id="{@id}" runat="server" text=" " CssClass="inputboxpopup"/&amp;gt;&lt;br /&gt;                                      &amp;lt;/xsl:if&amp;gt;&lt;br /&gt;                                      &amp;lt;xsl:if test="@type = 'TextBox' and @IsActiveDirectory='true' and @id='requestoroffice'"&amp;gt;&lt;br /&gt;                                        &amp;lt;asp:TextBox id="{@id}" runat="server" text=" " CssClass="inputboxpopup"/&amp;gt;&lt;br /&gt;                                      &amp;lt;/xsl:if&amp;gt;&lt;br /&gt;                                      &amp;lt;xsl:if test="@type = 'TextBox' and @IsActiveDirectory='true' and @id='requestordivision'"&amp;gt;&lt;br /&gt;                                        &amp;lt;asp:TextBox id="{@id}" runat="server" text=" " CssClass="inputboxpopup"/&amp;gt;&lt;br /&gt;                                      &amp;lt;/xsl:if&amp;gt;&lt;br /&gt;                                      &amp;lt;xsl:if test="@type = 'TextBox' and @IsActiveDirectory='true' and @id='requestorpassword'"&amp;gt;&lt;br /&gt;                                        &amp;lt;asp:TextBox id="{@id}" runat="server" text="{$requestorpassword}" CssClass="inputboxpopup"  readonly="false" /&amp;gt;&lt;br /&gt;                                      &amp;lt;/xsl:if&amp;gt;&lt;br /&gt;                                      &amp;lt;xsl:if test="@type = 'TextBoxText' and @IsActiveDirectory='true'"&amp;gt;&lt;br /&gt;                                        &amp;lt;asp:TextBox id="{@id}" runat="server" Text="{@text}" CssClass="inputboxpopup" /&amp;gt;&lt;br /&gt;                                      &amp;lt;/xsl:if&amp;gt;&lt;br /&gt;                                      &amp;lt;xsl:if test="@type = 'CheckBoxList'"&amp;gt;&lt;br /&gt;                                        &amp;lt;asp:CheckBoxList id="{@id}" runat="server" RepeatDirection="Vertical" RepeatLayout="Table" RepeatColumns="{@RepeatColumns}"&amp;gt;&lt;br /&gt;                                          &amp;lt;xsl:for-each select="Listitems/Listitem"&amp;gt;&lt;br /&gt;                                            &amp;lt;asp:ListItem value="{@value}" text="{@text}" Selected="{@selected}"  CellSpacing="10px" style="padding:0 35px 8px 1px; vertical-align:top; margin: 0; float:left;"&amp;gt;&amp;lt;/asp:ListItem&amp;gt;&lt;br /&gt;                                          &amp;lt;/xsl:for-each&amp;gt;&lt;br /&gt;                                        &amp;lt;/asp:CheckBoxList&amp;gt;                                        &lt;br /&gt;                                      &amp;lt;/xsl:if&amp;gt;&lt;br /&gt;                                      &amp;lt;xsl:if test="@type = 'DropDownList' and @IsActiveDirectory='false'"&amp;gt;&lt;br /&gt;                                        &amp;lt;asp:DropDownList id="{@id}" runat="server" style="width:209px;"&amp;gt;&lt;br /&gt;                                          &amp;lt;xsl:for-each select="Listitems/Listitem"&amp;gt;&lt;br /&gt;                                            &amp;lt;asp:ListItem value="{@value}" text="{@text}" Selected="{@selected}" &amp;gt;&amp;lt;/asp:ListItem&amp;gt;&lt;br /&gt;                                          &amp;lt;/xsl:for-each&amp;gt;&lt;br /&gt;                                        &amp;lt;/asp:DropDownList&amp;gt;&lt;br /&gt;                                      &amp;lt;/xsl:if&amp;gt;&lt;br /&gt;                                      &amp;lt;xsl:if test="@type = 'ListBox'"&amp;gt;&lt;br /&gt;                                        &amp;lt;asp:ListBox id="{@id}" runat="server" SelectionMode="Multiple" style="width:209px;"&amp;gt;&lt;br /&gt;                                          &amp;lt;xsl:for-each select="Listitems/Listitem"&amp;gt;&lt;br /&gt;                                            &amp;lt;asp:ListItem value="{@value}" text="{@text}" Selected="{@selected}" &amp;gt;&amp;lt;/asp:ListItem&amp;gt;&lt;br /&gt;                                          &amp;lt;/xsl:for-each&amp;gt;&lt;br /&gt;                                        &amp;lt;/asp:ListBox&amp;gt;&lt;br /&gt;                                      &amp;lt;/xsl:if&amp;gt;&lt;br /&gt;&lt;br /&gt;                                      &amp;lt;xsl:if test="@type = 'RadioButtonList'"&amp;gt;&lt;br /&gt;                                        &amp;lt;asp:RadioButtonList id="{@id}" runat="server" RepeatDirection="Vertical" RepeatLayout="Table" RepeatColumns="{@RepeatColumns}"&amp;gt;&lt;br /&gt;                                          &amp;lt;xsl:for-each select="Listitems/Listitem"&amp;gt;&lt;br /&gt;                                            &amp;lt;asp:ListItem value="{@value}" text="{@text}" Selected="{@selected}"  style="padding:0 35px 8px 1px; vertical-align:top; margin: 0;  float:left;" &amp;gt;&amp;lt;/asp:ListItem&amp;gt;&lt;br /&gt;                                          &amp;lt;/xsl:for-each&amp;gt;&lt;br /&gt;                                        &amp;lt;/asp:RadioButtonList&amp;gt;&lt;br /&gt;                                      &amp;lt;/xsl:if&amp;gt;&lt;br /&gt;&lt;br /&gt;                                      &amp;lt;div style="padding-left:20px;"&amp;gt;                                      &lt;br /&gt;                                      &amp;lt;xsl:if test="@type = 'RadioButtonListIndent2'"&amp;gt;&lt;br /&gt;                                        &amp;lt;asp:RadioButtonList id="{@id}" runat="server" RepeatDirection="Vertical" RepeatLayout="Table" RepeatColumns="{@RepeatColumns}"&amp;gt;&lt;br /&gt;                                          &amp;lt;xsl:for-each select="Listitems/Listitem"&amp;gt;&lt;br /&gt;                                            &amp;lt;asp:ListItem value="{@value}" text="{@text}" Selected="{@selected}"  style="padding:0 35px 8px 1px; vertical-align:top; margin: 0;  float:left;" &amp;gt;&amp;lt;/asp:ListItem&amp;gt;&lt;br /&gt;                                          &amp;lt;/xsl:for-each&amp;gt;&lt;br /&gt;                                        &amp;lt;/asp:RadioButtonList&amp;gt;&lt;br /&gt;                                      &amp;lt;/xsl:if&amp;gt;&lt;br /&gt;                                      &amp;lt;/div&amp;gt;&lt;br /&gt;                                    &amp;lt;/td&amp;gt;&lt;br /&gt;                                  &amp;lt;/xsl:if&amp;gt;&lt;br /&gt;                                  &amp;lt;xsl:if test="@type = 'label' and @id='footername'"&amp;gt;&lt;br /&gt;                                    &amp;lt;td class="labelHeading" colspan="6" align="left" style="padding-left:60px;"&amp;gt;&lt;br /&gt;                                      &amp;lt;asp:Label runat="server" text="{@label}"/&amp;gt;&lt;br /&gt;                                    &amp;lt;/td&amp;gt;&lt;br /&gt;                                  &amp;lt;/xsl:if&amp;gt;&lt;br /&gt;                                &amp;lt;/tr&amp;gt;&lt;br /&gt;                              &amp;lt;/xsl:for-each&amp;gt;&lt;br /&gt;                            &amp;lt;/table&amp;gt;&lt;br /&gt;                          &amp;lt;/td&amp;gt;&lt;br /&gt;                        &amp;lt;/tr&amp;gt;&lt;br /&gt;                      &amp;lt;/table&amp;gt;&lt;br /&gt;                    &amp;lt;/div&amp;gt;&lt;br /&gt;                  &amp;lt;/td&amp;gt;&lt;br /&gt;                &amp;lt;/tr&amp;gt;&lt;br /&gt;              &amp;lt;/table&amp;gt;&lt;br /&gt;            &amp;lt;/div&amp;gt;&lt;br /&gt;          &amp;lt;/div&amp;gt;&lt;br /&gt;        &amp;lt;/td&amp;gt;&lt;br /&gt;      &amp;lt;/tr&amp;gt;&lt;br /&gt;    &amp;lt;/table&amp;gt;&lt;br /&gt;  &amp;lt;/xsl:template&amp;gt;&lt;br /&gt;  &amp;lt;xsl:template name="break"&amp;gt;&lt;br /&gt;    &amp;lt;xsl:param name="text" select="."/&amp;gt;&lt;br /&gt;    &amp;lt;xsl:choose&amp;gt;&lt;br /&gt;      &amp;lt;xsl:when test="contains($text, '&amp;#xa;')"&amp;gt;&lt;br /&gt;        &amp;lt;xsl:value-of select="substring-before($text, '&amp;#xa;')"/&amp;gt;&lt;br /&gt;        &amp;lt;br/&amp;gt;&lt;br /&gt;        &amp;lt;xsl:call-template name="break"&amp;gt;&lt;br /&gt;          &amp;lt;xsl:with-param name="label" select="substring-after($text, '&amp;#xa;')"/&amp;gt;&lt;br /&gt;        &amp;lt;/xsl:call-template&amp;gt;&lt;br /&gt;      &amp;lt;/xsl:when&amp;gt;&lt;br /&gt;      &amp;lt;xsl:otherwise&amp;gt;&lt;br /&gt;        &amp;lt;xsl:value-of select="$text"/&amp;gt;&lt;br /&gt;      &amp;lt;/xsl:otherwise&amp;gt;&lt;br /&gt;    &amp;lt;/xsl:choose&amp;gt;&lt;br /&gt;  &amp;lt;/xsl:template&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;/xsl:stylesheet&amp;gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7527040749709927669-2299931131176221384?l=jaan1762.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jaan1762.blogspot.com/feeds/2299931131176221384/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7527040749709927669&amp;postID=2299931131176221384' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/2299931131176221384'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/2299931131176221384'/><link rel='alternate' type='text/html' href='http://jaan1762.blogspot.com/2010/04/additional-info-xslt.html' title='additional info xslt'/><author><name>Mansoor</name><uri>http://www.blogger.com/profile/00473621254256960630</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-7527040749709927669.post-8855108044364268511</id><published>2010-04-25T10:09:00.000-07:00</published><updated>2010-04-25T22:47:10.254-07:00</updated><title type='text'>additional info plain data</title><content type='html'>&amp;lt;p&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:asp="remove"&amp;gt;&lt;br /&gt;  &amp;lt;xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/&amp;gt;&lt;br /&gt;  &amp;lt;xsl:param name="session_name"/&amp;gt;&lt;br /&gt;  &amp;lt;xsl:template match="ServiceName"&amp;gt;&lt;br /&gt; &lt;br /&gt;                            &amp;lt;xsl:for-each select="//Field"&amp;gt;&lt;br /&gt;                           &lt;br /&gt;                              &amp;lt;xsl:text&amp;gt;&lt;br /&gt;        &amp;lt;/xsl:text&amp;gt;&amp;lt;xsl:value-of select="@label"/&amp;gt;&amp;lt;xsl:text&amp;gt; &amp;lt;/xsl:text&amp;gt;&lt;br /&gt;&lt;br /&gt;                              &lt;br /&gt;                                  &amp;lt;xsl:if test="@type = 'TextBox'"&amp;gt;&lt;br /&gt;&lt;br /&gt;                                    &amp;lt;xsl:value-of select="@value"/&amp;gt;&lt;br /&gt;                                  &amp;lt;/xsl:if&amp;gt;&lt;br /&gt;                                  &amp;lt;xsl:if test="@type = 'CheckBoxList'"&amp;gt;&lt;br /&gt;                                    &amp;lt;xsl:for-each select="Listitems/Listitem"&amp;gt;&lt;br /&gt;                                      &amp;lt;xsl:if test="@selected = 'True'"&amp;gt;&lt;br /&gt;                                        &amp;lt;xsl:value-of select="@value"/&amp;gt;&lt;br /&gt;                                        &amp;lt;xsl:value-of select="','"/&amp;gt;&lt;br /&gt;                                      &amp;lt;/xsl:if&amp;gt;&lt;br /&gt;                                    &amp;lt;/xsl:for-each&amp;gt;&lt;br /&gt;                                  &amp;lt;/xsl:if&amp;gt;&lt;br /&gt;&lt;br /&gt;                                  &amp;lt;xsl:if test="@type = 'DropDownList'"&amp;gt;&lt;br /&gt;                                    &amp;lt;xsl:for-each select="Listitems/Listitem"&amp;gt;&lt;br /&gt;                                      &amp;lt;xsl:if test="@selected = 'True'"&amp;gt;&lt;br /&gt;                                        &amp;lt;xsl:value-of select="@value"/&amp;gt;&lt;br /&gt;                                        &amp;lt;xsl:value-of select="','"/&amp;gt;&lt;br /&gt;                                      &amp;lt;/xsl:if&amp;gt;&lt;br /&gt;                                    &amp;lt;/xsl:for-each&amp;gt;&lt;br /&gt;                                  &amp;lt;/xsl:if&amp;gt;&lt;br /&gt;&lt;br /&gt;                                  &amp;lt;xsl:if test="@type = 'ListBox'"&amp;gt;&lt;br /&gt;                                    &amp;lt;xsl:for-each select="Listitems/Listitem"&amp;gt;&lt;br /&gt;                                      &amp;lt;xsl:if test="@selected = 'True'"&amp;gt;&lt;br /&gt;                                        &amp;lt;xsl:value-of select="@value"/&amp;gt;&lt;br /&gt;                                        &amp;lt;xsl:value-of select="','"/&amp;gt;&lt;br /&gt;                                      &amp;lt;/xsl:if&amp;gt;&lt;br /&gt;                                    &amp;lt;/xsl:for-each&amp;gt;&lt;br /&gt;                                  &amp;lt;/xsl:if&amp;gt;&lt;br /&gt;&lt;br /&gt;                                  &amp;lt;xsl:if test="@type = 'RadioButtonList'"&amp;gt;&lt;br /&gt;                                    &amp;lt;xsl:for-each select="Listitems/Listitem"&amp;gt;&lt;br /&gt;                                      &amp;lt;xsl:if test="@selected = 'True'"&amp;gt;&lt;br /&gt;                                        &amp;lt;xsl:value-of select="@value"/&amp;gt;&lt;br /&gt;                                        &amp;lt;xsl:value-of select="','"/&amp;gt;&lt;br /&gt;                                      &amp;lt;/xsl:if&amp;gt;&lt;br /&gt;                                    &amp;lt;/xsl:for-each&amp;gt;&lt;br /&gt;                                  &amp;lt;/xsl:if&amp;gt;&lt;br /&gt;&lt;br /&gt;                           &lt;br /&gt;                      &lt;br /&gt;  &amp;lt;/xsl:template&amp;gt;&lt;br /&gt;&amp;lt;/xsl:stylesheet&amp;gt;&lt;br /&gt;&amp;lt;/p&amp;gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7527040749709927669-8855108044364268511?l=jaan1762.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jaan1762.blogspot.com/feeds/8855108044364268511/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7527040749709927669&amp;postID=8855108044364268511' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/8855108044364268511'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/8855108044364268511'/><link rel='alternate' type='text/html' href='http://jaan1762.blogspot.com/2010/04/additional-info-plain-data.html' title='additional info plain data'/><author><name>Mansoor</name><uri>http://www.blogger.com/profile/00473621254256960630</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-7527040749709927669.post-834252066820785785</id><published>2010-04-25T10:08:00.002-07:00</published><updated>2010-04-25T22:54:28.829-07:00</updated><title type='text'>audit report.xslt</title><content type='html'>&amp;lt;?xml version="1.0" encoding="utf-8"?&amp;gt;&lt;br /&gt;&amp;lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&lt;br /&gt;    xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"&lt;br /&gt;&amp;gt;&lt;br /&gt;    &amp;lt;xsl:output method="xml" indent="yes"/&amp;gt;&lt;br /&gt;&lt;br /&gt;  &amp;lt;xsl:template match="/"&amp;gt;&lt;br /&gt;    &amp;lt;xsl:apply-templates select="Data"/&amp;gt;&lt;br /&gt;&lt;br /&gt;  &amp;lt;/xsl:template&amp;gt;&lt;br /&gt;&lt;br /&gt;  &amp;lt;xsl:template match="Data"&amp;gt;&lt;br /&gt;&lt;br /&gt;    &amp;lt;xsl:processing-instruction name="mso-application"&amp;gt;progid="Excel.Sheet"&amp;lt;/xsl:processing-instruction&amp;gt;&lt;br /&gt;&lt;br /&gt;    &amp;lt;Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"&lt;br /&gt;&lt;br /&gt;     xmlns:o="urn:schemas-microsoft-com:office:office"&lt;br /&gt;&lt;br /&gt;     xmlns:x="urn:schemas-microsoft-com:office:excel"&lt;br /&gt;&lt;br /&gt;     xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"&lt;br /&gt;&lt;br /&gt;     xmlns:html="http://www.w3.org/TR/REC-html40"&amp;gt;      &lt;br /&gt;      &amp;lt;Styles&amp;gt;&lt;br /&gt;      &amp;lt;Style ss:ID="s24"&amp;gt;&lt;br /&gt;        &amp;lt;Interior ss:Color="#083eb8" ss:Pattern="Solid"/&amp;gt;&lt;br /&gt;        &amp;lt;Alignment ss:Horizontal="Left" ss:Vertical="Center" ss:WrapText="1"/&amp;gt;&lt;br /&gt;        &amp;lt;Borders&amp;gt;&lt;br /&gt;          &amp;lt;Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="1"/&amp;gt;&lt;br /&gt;          &amp;lt;Border ss:Position="Left" ss:LineStyle="Continuous" ss:Weight="1"/&amp;gt;&lt;br /&gt;          &amp;lt;Border ss:Position="Right" ss:LineStyle="Continuous" ss:Weight="1"/&amp;gt;&lt;br /&gt;        &amp;lt;/Borders&amp;gt;&lt;br /&gt;        &amp;lt;Font ss:Bold="1" ss:Color="#ffffff"/&amp;gt;&lt;br /&gt;      &lt;br /&gt;      &amp;lt;/Style&amp;gt;&lt;br /&gt;      &amp;lt;/Styles&amp;gt;&lt;br /&gt;&lt;br /&gt;      &amp;lt;Worksheet ss:Name="Audit Report Data"  &amp;gt;       &lt;br /&gt;        &amp;lt;Table x:FullColumns="1" x:FullRows="1"&amp;gt;&lt;br /&gt;          &amp;lt;Column ss:Width="250.25"/&amp;gt;&lt;br /&gt;          &amp;lt;Column ss:Width="100"/&amp;gt;&lt;br /&gt;          &amp;lt;Column ss:Width="150.5"/&amp;gt;&lt;br /&gt;          &amp;lt;Column ss:Width="113.25"/&amp;gt;&lt;br /&gt;          &amp;lt;Column ss:Width="110.25"/&amp;gt;&lt;br /&gt;          &amp;lt;!--&amp;lt;Row &amp;gt;&lt;br /&gt;            &amp;lt;xsl:for-each select="//Fiscal[last()]//FiscalData"&amp;gt;          &lt;br /&gt;           &lt;br /&gt;                &amp;lt;Cell ss:StyleID="s24"&amp;gt;&lt;br /&gt;                  &amp;lt;Data ss:Type="String"&amp;gt;&lt;br /&gt;                    &amp;lt;xsl:value-of select="@Title"/&amp;gt;&lt;br /&gt;                  &amp;lt;/Data&amp;gt;&lt;br /&gt;                &amp;lt;/Cell&amp;gt;          &lt;br /&gt;            &amp;lt;/xsl:for-each&amp;gt;&lt;br /&gt;          &amp;lt;/Row&amp;gt;--&amp;gt;&lt;br /&gt;          &amp;lt;xsl:for-each select="Fiscal"&amp;gt;&lt;br /&gt;            &amp;lt;Row&amp;gt;&lt;br /&gt;              &amp;lt;xsl:for-each select="FiscalData"&amp;gt;            &lt;br /&gt;               &lt;br /&gt;                  &amp;lt;Cell &amp;gt;&lt;br /&gt;                    &amp;lt;Data ss:Type="String"&amp;gt;&lt;br /&gt;                      &amp;lt;xsl:value-of select="text()" /&amp;gt;&lt;br /&gt;                    &amp;lt;/Data&amp;gt;&lt;br /&gt;                  &amp;lt;/Cell&amp;gt;              &lt;br /&gt;              &amp;lt;/xsl:for-each&amp;gt;&lt;br /&gt;            &amp;lt;/Row&amp;gt;&lt;br /&gt;          &amp;lt;/xsl:for-each&amp;gt;&lt;br /&gt;&lt;br /&gt;        &amp;lt;/Table&amp;gt;&lt;br /&gt;        &amp;lt;WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel"&amp;gt;&lt;br /&gt;&lt;br /&gt;          &amp;lt;Print&amp;gt;&lt;br /&gt;&lt;br /&gt;            &amp;lt;ValidPrinterInfo/&amp;gt;&lt;br /&gt;&lt;br /&gt;            &amp;lt;HorizontalResolution&amp;gt;600&amp;lt;/HorizontalResolution&amp;gt;&lt;br /&gt;&lt;br /&gt;            &amp;lt;VerticalResolution&amp;gt;600&amp;lt;/VerticalResolution&amp;gt;&lt;br /&gt;&lt;br /&gt;          &amp;lt;/Print&amp;gt;&lt;br /&gt;&lt;br /&gt;          &amp;lt;Selected/&amp;gt;&lt;br /&gt;&lt;br /&gt;          &amp;lt;Panes&amp;gt;&lt;br /&gt;&lt;br /&gt;            &amp;lt;Pane&amp;gt;&lt;br /&gt;&lt;br /&gt;              &amp;lt;Number&amp;gt;3&amp;lt;/Number&amp;gt;&lt;br /&gt;&lt;br /&gt;              &amp;lt;ActiveRow&amp;gt;12&amp;lt;/ActiveRow&amp;gt;&lt;br /&gt;&lt;br /&gt;              &amp;lt;ActiveCol&amp;gt;1&amp;lt;/ActiveCol&amp;gt;&lt;br /&gt;&lt;br /&gt;            &amp;lt;/Pane&amp;gt;&lt;br /&gt;&lt;br /&gt;          &amp;lt;/Panes&amp;gt;&lt;br /&gt;&lt;br /&gt;          &amp;lt;ProtectObjects&amp;gt;False&amp;lt;/ProtectObjects&amp;gt;&lt;br /&gt;&lt;br /&gt;          &amp;lt;ProtectScenarios&amp;gt;False&amp;lt;/ProtectScenarios&amp;gt;&lt;br /&gt;&lt;br /&gt;        &amp;lt;/WorksheetOptions&amp;gt;&lt;br /&gt;&lt;br /&gt;      &amp;lt;/Worksheet&amp;gt;&lt;br /&gt;    &amp;lt;/Workbook&amp;gt;&lt;br /&gt;  &amp;lt;/xsl:template&amp;gt;&lt;br /&gt;&amp;lt;/xsl:stylesheet&amp;gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7527040749709927669-834252066820785785?l=jaan1762.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jaan1762.blogspot.com/feeds/834252066820785785/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7527040749709927669&amp;postID=834252066820785785' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/834252066820785785'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/834252066820785785'/><link rel='alternate' type='text/html' href='http://jaan1762.blogspot.com/2010/04/audit-reportxslt.html' title='audit report.xslt'/><author><name>Mansoor</name><uri>http://www.blogger.com/profile/00473621254256960630</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-7527040749709927669.post-2877145570327255140</id><published>2010-04-25T10:05:00.001-07:00</published><updated>2010-04-25T22:58:38.999-07:00</updated><title type='text'>update additional info</title><content type='html'>&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;&lt;br /&gt;&amp;lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:asp="remove"&amp;gt;&lt;br /&gt;  &amp;lt;xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/&amp;gt;&lt;br /&gt;  &amp;lt;xsl:param name="requestoremail"/&amp;gt;&lt;br /&gt;  &amp;lt;xsl:param name="requestorlocation"/&amp;gt;&lt;br /&gt;  &amp;lt;xsl:param name="array"/&amp;gt;&lt;br /&gt;  &amp;lt;xsl:template match="ServiceName"&amp;gt;&lt;br /&gt;    &amp;lt;table  border="0" cellpadding="0" cellspacing="0" width="700px"&amp;gt;&lt;br /&gt;      &amp;lt;tr&amp;gt;&lt;br /&gt;        &amp;lt;td&amp;gt;&lt;br /&gt;          &amp;lt;div id="content_area"&amp;gt;&lt;br /&gt;            &amp;lt;div class="ControlHeading"&amp;gt;&lt;br /&gt;              &amp;lt;table border="0" cellpadding="0" cellspacing="0" width="700px"&amp;gt;&lt;br /&gt;                &amp;lt;tr&amp;gt;&lt;br /&gt;                  &amp;lt;td align="left"&amp;gt;&lt;br /&gt;                    &amp;lt;div id="request_heading"&amp;gt;&lt;br /&gt;                      &amp;lt;xsl:value-of select="@name"/&amp;gt;&lt;br /&gt;                    &amp;lt;/div&amp;gt;&lt;br /&gt;                  &amp;lt;/td&amp;gt;&lt;br /&gt;                &amp;lt;/tr&amp;gt;&lt;br /&gt;                &amp;lt;tr&amp;gt;&lt;br /&gt;                  &amp;lt;td align="left"&amp;gt;&lt;br /&gt;                    &amp;lt;table  border="0" cellpadding="0" cellspacing="0" class="service_contentTable"&amp;gt;&lt;br /&gt;                      &amp;lt;tr&amp;gt;&lt;br /&gt;                        &amp;lt;td&amp;gt;a&lt;br /&gt;                          &amp;lt;table border="0" cellpadding="0" cellspacing="0"&amp;gt;&lt;br /&gt;                            &amp;lt;tr&amp;gt;&lt;br /&gt;                              &amp;lt;td height="5px"&amp;gt;&lt;br /&gt;                              &amp;lt;/td&amp;gt;&lt;br /&gt;                            &amp;lt;/tr&amp;gt;&lt;br /&gt;                            &amp;lt;xsl:for-each select="//Field"&amp;gt;&lt;br /&gt;                              &amp;lt;tr&amp;gt;&lt;br /&gt;                                &amp;lt;td class="labelHeading"&amp;gt;&lt;br /&gt;                                  &amp;lt;asp:Label runat="server" text="{@label}"/&amp;gt;&lt;br /&gt;                                &amp;lt;/td&amp;gt;&lt;br /&gt;                                &amp;lt;td style="width:5px"&amp;gt;&lt;br /&gt;                                &amp;lt;/td&amp;gt;&lt;br /&gt;                                &amp;lt;td&amp;gt;&lt;br /&gt;                                  &amp;lt;!--&amp;lt;xsl:choose&amp;gt;                                    &lt;br /&gt;                                    &amp;lt;xsl:when test="@type = 'TextBox' and @IsActiveDirectory='false'" &amp;gt;&lt;br /&gt;                                      &amp;lt;asp:TextBox id="{@id}" runat="server" text=" " CssClass="inputbox"/&amp;gt;&lt;br /&gt;                                    &amp;lt;/xsl:when&amp;gt;&lt;br /&gt;                                    &amp;lt;xsl:when test="@type = 'TextBox' and @IsActiveDirectory='true'" &amp;gt;&lt;br /&gt;                                      &amp;lt;asp:TextBox id="{@id}" runat="server" text="{$requestoremail}" CssClass="inputbox"/&amp;gt;&lt;br /&gt;                                    &amp;lt;/xsl:when&amp;gt;&lt;br /&gt;                                  &amp;lt;/xsl:choose&amp;gt;--&amp;gt;&lt;br /&gt;                                  &amp;lt;xsl:if test="@type = 'TextBox'"&amp;gt;&lt;br /&gt;                                    &amp;lt;asp:TextBox id="{@id}" runat="server" text="{@value}" CssClass="inputbox"/&amp;gt;&lt;br /&gt;                                  &amp;lt;/xsl:if&amp;gt;                                  &lt;br /&gt;&lt;br /&gt;                                  &amp;lt;xsl:if test="@type = 'CheckBoxList'"&amp;gt;&lt;br /&gt;                                    &amp;lt;asp:CheckBoxList id="{@id}" runat="server" RepeatDirection="Horizontal"&amp;gt;&lt;br /&gt;                                      &amp;lt;xsl:for-each select="Listitems/Listitem"&amp;gt;&lt;br /&gt;                                        &amp;lt;asp:ListItem value="{@value}" text="{@text}" Selected="{@selected}"&amp;gt;&amp;lt;/asp:ListItem&amp;gt;&lt;br /&gt;                                      &amp;lt;/xsl:for-each&amp;gt;&lt;br /&gt;                                    &amp;lt;/asp:CheckBoxList&amp;gt;&lt;br /&gt;                                  &amp;lt;/xsl:if&amp;gt;&lt;br /&gt;&lt;br /&gt;                                  &amp;lt;xsl:if test="@type = 'DropDownList'"&amp;gt;&lt;br /&gt;                                    &amp;lt;asp:DropDownList id="{@id}" runat="server"&amp;gt;&lt;br /&gt;                                      &amp;lt;xsl:for-each select="Listitems/Listitem"&amp;gt;&lt;br /&gt;                                        &amp;lt;asp:ListItem value="{@value}" text="{@text}" Selected="{@selected}"&amp;gt;&amp;lt;/asp:ListItem&amp;gt;&lt;br /&gt;                                      &amp;lt;/xsl:for-each&amp;gt;&lt;br /&gt;                                    &amp;lt;/asp:DropDownList&amp;gt;&lt;br /&gt;                                  &amp;lt;/xsl:if&amp;gt;&lt;br /&gt;                                  &amp;lt;!--&amp;lt;xsl:for-each select="$array"&amp;gt;&lt;br /&gt;                                       Suman&lt;br /&gt;                                      &amp;lt;/xsl:for-each&amp;gt;--&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;                                  &amp;lt;xsl:if test="@type = 'ListBox'"&amp;gt;&lt;br /&gt;                                    &amp;lt;asp:ListBox id="{@id}" runat="server" SelectionMode="Multiple"&amp;gt;&lt;br /&gt;                                      &amp;lt;xsl:for-each select="Listitems/Listitem"&amp;gt;&lt;br /&gt;                                        &amp;lt;asp:ListItem value="{@value}" text="{@text}" Selected="{@selected}"&amp;gt;&amp;lt;/asp:ListItem&amp;gt;&lt;br /&gt;                                      &amp;lt;/xsl:for-each&amp;gt;&lt;br /&gt;                                    &amp;lt;/asp:ListBox&amp;gt;&lt;br /&gt;                                  &amp;lt;/xsl:if&amp;gt;&lt;br /&gt;&lt;br /&gt;                                  &amp;lt;xsl:if test="@type = 'RadioButtonList'"&amp;gt;&lt;br /&gt;                                    &amp;lt;asp:RadioButtonList id="{@id}" runat="server" RepeatDirection="Horizontal"&amp;gt;&lt;br /&gt;                                      &amp;lt;xsl:for-each select="Listitems/Listitem"&amp;gt;&lt;br /&gt;                                        &amp;lt;asp:ListItem value="{@value}" text="{@text}" Selected="{@selected}"&amp;gt;&amp;lt;/asp:ListItem&amp;gt;&lt;br /&gt;                                      &amp;lt;/xsl:for-each&amp;gt;&lt;br /&gt;                                    &amp;lt;/asp:RadioButtonList&amp;gt;&lt;br /&gt;                                  &amp;lt;/xsl:if&amp;gt;&lt;br /&gt;&lt;br /&gt;                                  &amp;lt;!--&amp;lt;xsl:if test="@required = 'True'"&amp;gt;&lt;br /&gt;                                    &amp;lt;asp:RequiredFieldValidator ErrorMessage=" Required Field" runat="server" ControlToValidate="{@id}" /&amp;gt;&lt;br /&gt;                                    --&lt;br /&gt;                                  &amp;lt;!--&amp;lt;asp:RequiredFieldValidator ID="RequiredFieldValidator" runat="server" ErrorMessage="please enter the value" ControlToValidate="{@id}" Display="dynamic"&amp;gt;&lt;br /&gt;                                    &amp;lt;/asp:RequiredFieldValidator&amp;gt;--&amp;gt;&lt;br /&gt;                                  &amp;lt;!--&lt;br /&gt;                                  &amp;lt;/xsl:if&amp;gt;--&amp;gt;&lt;br /&gt;&lt;br /&gt;                                &amp;lt;/td&amp;gt;&lt;br /&gt;                              &amp;lt;/tr&amp;gt;&lt;br /&gt;                            &amp;lt;/xsl:for-each&amp;gt;&lt;br /&gt;                          &amp;lt;/table&amp;gt;&lt;br /&gt;                        &amp;lt;/td&amp;gt;&lt;br /&gt;                      &amp;lt;/tr&amp;gt;&lt;br /&gt;                    &amp;lt;/table&amp;gt;&lt;br /&gt;                  &amp;lt;/td&amp;gt;&lt;br /&gt;                &amp;lt;/tr&amp;gt;&lt;br /&gt;              &amp;lt;/table&amp;gt;&lt;br /&gt;            &amp;lt;/div&amp;gt;&lt;br /&gt;          &amp;lt;/div&amp;gt;&lt;br /&gt;        &amp;lt;/td&amp;gt;&lt;br /&gt;      &amp;lt;/tr&amp;gt;&lt;br /&gt;    &amp;lt;/table&amp;gt;&lt;br /&gt;  &amp;lt;/xsl:template&amp;gt;&lt;br /&gt;&amp;lt;/xsl:stylesheet&amp;gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7527040749709927669-2877145570327255140?l=jaan1762.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jaan1762.blogspot.com/feeds/2877145570327255140/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7527040749709927669&amp;postID=2877145570327255140' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/2877145570327255140'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/2877145570327255140'/><link rel='alternate' type='text/html' href='http://jaan1762.blogspot.com/2010/04/update-additional-info.html' title='update additional info'/><author><name>Mansoor</name><uri>http://www.blogger.com/profile/00473621254256960630</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-7527040749709927669.post-1076386074544671038</id><published>2010-04-21T00:29:00.000-07:00</published><updated>2010-04-25T23:01:39.658-07:00</updated><title type='text'>XSL</title><content type='html'>&amp;lt;?xml:namespace prefix = xsl /&amp;gt;&amp;lt;xsl:stylesheet version="1.0" xsl="http://www.w3.org/1999/XSL/Transform" asp="remove"&amp;gt;&lt;br /&gt;&amp;lt;xsl:output version="1.0" indent="yes" encoding="UTF-8" method="xml"&amp;gt;&amp;lt;/xsl:output&amp;gt;&lt;br /&gt;&amp;lt;xsl:param name="session_name"&amp;gt;&amp;lt;/xsl:param&amp;gt;&lt;br /&gt;&amp;lt;xsl:template match="ServiceName"&amp;gt;&lt;br /&gt;&amp;lt;table cellspacing="0" cellpadding="0" width="700" border="0"&amp;gt;&lt;br /&gt;&amp;lt;tbody&amp;gt;&amp;lt;tr&amp;gt;&lt;br /&gt;&amp;lt;td&amp;gt;&lt;br /&gt;&amp;lt;div id="content_area"&amp;gt;&lt;br /&gt;&amp;lt;div class="ControlHeading"&amp;gt;&lt;br /&gt;&amp;lt;table cellspacing="0" cellpadding="0" width="700" border="0"&amp;gt;&lt;br /&gt;&amp;lt;tbody&amp;gt;&amp;lt;tr&amp;gt;&lt;br /&gt;&amp;lt;td&amp;gt;&lt;br /&gt;&amp;lt;div id="request_heading" style="TEXT-ALIGN: left"&amp;gt;&lt;br /&gt;&amp;lt;!--&amp;lt;xsl:value-of select="@name"&amp;gt;--&amp;gt;&lt;br /&gt;&amp;lt;/div&amp;gt;&lt;br /&gt;&amp;lt;/td&amp;gt;&lt;br /&gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;&amp;lt;tr&amp;gt;&lt;br /&gt;&amp;lt;td&amp;gt;&lt;br /&gt;&amp;lt;table class="service_contentTable" style="TEXT-ALIGN: left" cellspacing="0" cellpadding="0" border="0"&amp;gt;&lt;br /&gt;&amp;lt;tbody&amp;gt;&amp;lt;tr&amp;gt;&lt;br /&gt;&amp;lt;td&amp;gt;&lt;br /&gt;&amp;lt;table cellspacing="0" cellpadding="0" border="0"&amp;gt;&lt;br /&gt;&amp;lt;tbody&amp;gt;&amp;lt;tr&amp;gt;&lt;br /&gt;&amp;lt;td height="5"&amp;gt;&lt;br /&gt;&amp;lt;/td&amp;gt;&lt;br /&gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;&amp;lt;xsl:for-each select="//Field"&amp;gt;&lt;br /&gt;&amp;lt;tr&amp;gt;&lt;br /&gt;&amp;lt;td class="labelHeading"&amp;gt;&lt;br /&gt;&amp;lt;xsl:choose&amp;gt;&lt;br /&gt;&amp;lt;xsl:when test="contains(@label, '\n')"&amp;gt;&lt;br /&gt;&amp;lt;xsl:value-of select="substring-before(@label, '\n')"&amp;gt;&amp;lt;/xsl:value-of&amp;gt;&lt;br /&gt;&amp;lt;xsl:value-of select="substring-after(@label, '\n')"&amp;gt;&amp;lt;/xsl:value-of&amp;gt;&lt;br /&gt;&amp;lt;/xsl:when&amp;gt;&lt;br /&gt;&amp;lt;xsl:otherwise&amp;gt;&lt;br /&gt;&amp;lt;xsl:value-of select="@label"&amp;gt;&amp;lt;/xsl:value-of&amp;gt;&lt;br /&gt;&amp;lt;/xsl:otherwise&amp;gt;&lt;br /&gt;&amp;lt;/xsl:choose&amp;gt;&lt;br /&gt;&amp;lt;/td&amp;gt;&lt;br /&gt;&amp;lt;td style="WIDTH: 5px"&amp;gt;&lt;br /&gt;&amp;lt;/td&amp;gt;&lt;br /&gt;&amp;lt;td&amp;gt;&lt;br /&gt;&amp;lt;xsl:if test="@type = 'TextBox'"&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;xsl:value-of select="@value"&amp;gt;&amp;lt;/xsl:value-of&amp;gt;&lt;br /&gt;&amp;lt;/xsl:if&amp;gt;&lt;br /&gt;&amp;lt;xsl:if test="@type = 'CheckBoxList'"&amp;gt;&lt;br /&gt;&amp;lt;xsl:for-each select="Listitems/Listitem"&amp;gt;&lt;br /&gt;&amp;lt;xsl:if test="@selected = 'True'"&amp;gt;&lt;br /&gt;&amp;lt;xsl:value-of select="@value"&amp;gt;&amp;lt;/xsl:value-of&amp;gt;&lt;br /&gt;&amp;lt;xsl:value-of select="','"&amp;gt;&amp;lt;/xsl:value-of&amp;gt;&lt;br /&gt;&amp;lt;/xsl:if&amp;gt;&lt;br /&gt;&amp;lt;/xsl:for-each&amp;gt;&lt;br /&gt;&amp;lt;/xsl:if&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;xsl:if test="@type = 'DropDownList'"&amp;gt;&lt;br /&gt;&amp;lt;xsl:for-each select="Listitems/Listitem"&amp;gt;&lt;br /&gt;&amp;lt;xsl:if test="@selected = 'True'"&amp;gt;&lt;br /&gt;&amp;lt;xsl:value-of select="@value"&amp;gt;&amp;lt;/xsl:value-of&amp;gt;&lt;br /&gt;&amp;lt;xsl:value-of select="','"&amp;gt;&amp;lt;/xsl:value-of&amp;gt;&lt;br /&gt;&amp;lt;/xsl:if&amp;gt;&lt;br /&gt;&amp;lt;/xsl:for-each&amp;gt;&lt;br /&gt;&amp;lt;/xsl:if&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;xsl:if test="@type = 'ListBox'"&amp;gt;&lt;br /&gt;&amp;lt;xsl:for-each select="Listitems/Listitem"&amp;gt;&lt;br /&gt;&amp;lt;xsl:if test="@selected = 'True'"&amp;gt;&lt;br /&gt;&amp;lt;xsl:value-of select="@value"&amp;gt;&amp;lt;/xsl:value-of&amp;gt;&lt;br /&gt;&amp;lt;xsl:value-of select="','"&amp;gt;&amp;lt;/xsl:value-of&amp;gt;&lt;br /&gt;&amp;lt;/xsl:if&amp;gt;&lt;br /&gt;&amp;lt;/xsl:for-each&amp;gt;&lt;br /&gt;&amp;lt;/xsl:if&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;xsl:if test="@type = 'RadioButtonList'"&amp;gt;&lt;br /&gt;&amp;lt;xsl:for-each select="Listitems/Listitem"&amp;gt;&lt;br /&gt;&amp;lt;xsl:if test="@selected = 'True'"&amp;gt;&lt;br /&gt;&amp;lt;xsl:value-of select="@value"&amp;gt;&amp;lt;/xsl:value-of&amp;gt;&lt;br /&gt;&amp;lt;xsl:value-of select="','"&amp;gt;&amp;lt;/xsl:value-of&amp;gt;&lt;br /&gt;&amp;lt;/xsl:if&amp;gt;&lt;br /&gt;&amp;lt;/xsl:for-each&amp;gt;&lt;br /&gt;&amp;lt;/xsl:if&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;/td&amp;gt;&lt;br /&gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;&amp;lt;/xsl:for-each&amp;gt;&lt;br /&gt;&amp;lt;/tbody&amp;gt;&amp;lt;/table&amp;gt;&lt;br /&gt;&amp;lt;/td&amp;gt;&lt;br /&gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;&amp;lt;/tbody&amp;gt;&amp;lt;/table&amp;gt;&lt;br /&gt;&amp;lt;/td&amp;gt;&lt;br /&gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;&amp;lt;/tbody&amp;gt;&amp;lt;/table&amp;gt;&lt;br /&gt;&amp;lt;/div&amp;gt;&lt;br /&gt;&amp;lt;/div&amp;gt;&lt;br /&gt;&amp;lt;/td&amp;gt;&lt;br /&gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;&amp;lt;/tbody&amp;gt;&amp;lt;/table&amp;gt;&lt;br /&gt;&amp;lt;/xsl:template&amp;gt;&lt;br /&gt;&amp;lt;/xsl:stylesheet&amp;gt;&lt;br /&gt;&lt;br /&gt;-----------------------&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;xsl:stylesheet version="1.0" xsl="http://www.w3.org/1999/XSL/Transform" asp="remove"&amp;gt;&lt;br /&gt;&amp;lt;xsl:output version="1.0" indent="yes" encoding="UTF-8" method="xml"&amp;gt;&amp;lt;/xsl:output&amp;gt;&lt;br /&gt;&amp;lt;xsl:param name="requestoremail"&amp;gt;&amp;lt;/xsl:param&amp;gt;&lt;br /&gt;&amp;lt;xsl:param name="requestorlocation"&amp;gt;&amp;lt;/xsl:param&amp;gt;&lt;br /&gt;&amp;lt;xsl:param name="requestorpassword"&amp;gt;&amp;lt;/xsl:param&amp;gt;&lt;br /&gt;&amp;lt;xsl:param name="array"&amp;gt;&amp;lt;/xsl:param&amp;gt;&lt;br /&gt;&amp;lt;xsl:param name="strBreak"&amp;gt;&amp;lt;/xsl:param&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;xsl:param name="strCurrentDate"&amp;gt;&amp;lt;/xsl:param&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;xsl:template match="ITRAC/ServiceName"&amp;gt;&lt;br /&gt;&amp;lt;table cellspacing="0" cellpadding="0" width="710" border="0"&amp;gt;&lt;br /&gt;&amp;lt;tbody&amp;gt;&amp;lt;tr&amp;gt;&lt;br /&gt;&amp;lt;td&amp;gt;&lt;br /&gt;&amp;lt;div id="content_area_Popup"&amp;gt;&lt;br /&gt;&amp;lt;div class="ControlHeading"&amp;gt;&lt;br /&gt;&amp;lt;table cellspacing="0" cellpadding="0" width="710" border="0"&amp;gt;&lt;br /&gt;&amp;lt;tbody&amp;gt;&amp;lt;tr&amp;gt;&lt;br /&gt;&amp;lt;td&amp;gt;&lt;br /&gt;&amp;lt;div id="ModalPopuprequest_heading"&amp;gt;&lt;br /&gt;&amp;lt;xsl:value-of select="@name"&amp;gt;&amp;lt;/xsl:value-of&amp;gt;&lt;br /&gt;&amp;lt;/div&amp;gt;&lt;br /&gt;&amp;lt;/td&amp;gt;&lt;br /&gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;&amp;lt;tr&amp;gt;&lt;br /&gt;&amp;lt;td&amp;gt;&lt;br /&gt;&amp;lt;div id="ModalPopuprequest_Directive"&amp;gt;&lt;br /&gt;Please provide the detail request information below:&lt;br /&gt;&amp;lt;/div&amp;gt;&lt;br /&gt;&amp;lt;/td&amp;gt;&lt;br /&gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;&amp;lt;tr&amp;gt;&lt;br /&gt;&amp;lt;td&amp;gt;&lt;br /&gt;&amp;lt;div id="ServicePopupInner"&amp;gt;&lt;br /&gt;&amp;lt;table class="service_contentTable" cellspacing="0" cellpadding="0" border="0"&amp;gt;&lt;br /&gt;&amp;lt;tbody&amp;gt;&amp;lt;tr&amp;gt;&lt;br /&gt;&amp;lt;td&amp;gt;&lt;br /&gt;&amp;lt;table cellspacing="0" cellpadding="2" border="0"&amp;gt;&lt;br /&gt;&amp;lt;tbody&amp;gt;&amp;lt;tr&amp;gt;&lt;br /&gt;&amp;lt;td height="5"&amp;gt;&lt;br /&gt;&amp;lt;/td&amp;gt;&lt;br /&gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;&amp;lt;xsl:for-each select="//Field"&amp;gt;&lt;br /&gt;&amp;lt;tr&amp;gt;&lt;br /&gt;&amp;lt;xsl:if test="@id!='footername'"&amp;gt;&lt;br /&gt;&amp;lt;xsl:if test="@type = 'LabelHeadcol1'"&amp;gt;&lt;br /&gt;&amp;lt;td colspan="3"&amp;gt;&lt;br /&gt;&amp;lt;?xml:namespace prefix = asp /&amp;gt;&amp;lt;asp:label text="{@headtext1}" runat="server" cssclass="labelHeading"&amp;gt;&amp;lt;/asp:label&amp;gt;&lt;br /&gt;&amp;lt;/td&amp;gt;&lt;br /&gt;&amp;lt;/xsl:if&amp;gt;&lt;br /&gt;&amp;lt;xsl:if test="@type = 'LabelHeadcol1'"&amp;gt;&lt;br /&gt;&amp;lt;td colspan="3"&amp;gt;&lt;br /&gt;&amp;lt;asp:label text="{@headtext2}" runat="server" cssclass="labelHeading"&amp;gt;&amp;lt;/asp:label&amp;gt;&lt;br /&gt;&amp;lt;/td&amp;gt;&lt;br /&gt;&amp;lt;/xsl:if&amp;gt;&lt;br /&gt;&amp;lt;xsl:if test="@type = 'LabelHeadcol2'"&amp;gt;&lt;br /&gt;&amp;lt;td style="WIDTH: 10px"&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;&amp;lt;td colspan="3"&amp;gt;&lt;br /&gt;&amp;lt;asp:label text="{@headtext1}" runat="server" cssclass="labelHeading"&amp;gt;&amp;lt;/asp:label&amp;gt;&lt;br /&gt;&amp;lt;/td&amp;gt;&lt;br /&gt;&amp;lt;/xsl:if&amp;gt;&lt;br /&gt;&amp;lt;/xsl:if&amp;gt;&lt;br /&gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;&amp;lt;tr&amp;gt;&lt;br /&gt;&amp;lt;xsl:if test="@id!='footername'"&amp;gt;&lt;br /&gt;&amp;lt;td style="PADDING-RIGHT: 3px; PADDING-LEFT: 3px; PADDING-BOTTOM: 3px; WIDTH: 10px; PADDING-TOP: 3px"&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;xsl:if test="@type = 'TextBox' and @IsActiveDirectory='false' and @checkboxType='Checkbox'"&amp;gt;&lt;br /&gt;&amp;lt;asp:checkbox id="{@checkboxid}" runat="server"&amp;gt;&amp;lt;/asp:checkbox&amp;gt;&lt;br /&gt;&amp;lt;/xsl:if&amp;gt;&lt;br /&gt;&amp;lt;/td&amp;gt;&lt;br /&gt;&amp;lt;td&amp;gt;&lt;br /&gt;&amp;lt;xsl:if test="@type = 'TextBox' and @IsActiveDirectory='false' and @checkboxType='Checkboxindent1'"&amp;gt;&lt;br /&gt;&amp;lt;asp:checkbox id="{@checkboxid}" runat="server"&amp;gt;&amp;lt;/asp:checkbox&amp;gt;&lt;br /&gt;&amp;lt;/xsl:if&amp;gt;&lt;br /&gt;&amp;lt;/td&amp;gt;&lt;br /&gt;&amp;lt;td class="labelText" style="PADDING-LEFT: 5px" valign="center"&amp;gt;&lt;br /&gt;&amp;lt;xsl:variable name="strNew"&amp;gt;&amp;lt;/xsl:variable&amp;gt;&lt;br /&gt;&amp;lt;xsl:choose&amp;gt;&lt;br /&gt;&amp;lt;xsl:when test="contains(@label, '\n')"&amp;gt;&lt;br /&gt;&amp;lt;xsl:value-of select="substring-before(@label, '\n')"&amp;gt;&amp;lt;/xsl:value-of&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;p class="SubTextInPopUp"&amp;gt;&amp;lt;xsl:value-of select="substring-after(@label, '\n')"&amp;gt;&amp;lt;/xsl:value-of&amp;gt;&amp;lt;/p&amp;gt;&lt;br /&gt;&amp;lt;/xsl:when&amp;gt;&lt;br /&gt;&amp;lt;xsl:otherwise&amp;gt;&lt;br /&gt;&amp;lt;xsl:value-of select="@label"&amp;gt;&amp;lt;/xsl:value-of&amp;gt;&lt;br /&gt;&amp;lt;/xsl:otherwise&amp;gt;&lt;br /&gt;&amp;lt;/xsl:choose&amp;gt;&lt;br /&gt;&amp;lt;asp:label text="{$strNew}" runat="server"&amp;gt;&amp;lt;/asp:label&amp;gt;&lt;br /&gt;&amp;lt;/td&amp;gt;&lt;br /&gt;&amp;lt;td style="WIDTH: 5px"&amp;gt;&lt;br /&gt;&amp;lt;/td&amp;gt;&lt;br /&gt;&amp;lt;td style="PADDING-RIGHT: 3px; PADDING-LEFT: 3px; PADDING-BOTTOM: 3px; PADDING-TOP: 3px" valign="top"&amp;gt;&lt;br /&gt;&amp;lt;xsl:if test="@type = 'Label' and @SecondColumn='true'"&amp;gt;&lt;br /&gt;&amp;lt;asp:label id="{@id}" text="{@label}" runat="server" bold="true"&amp;gt;&amp;lt;/asp:label&amp;gt;&lt;br /&gt;&amp;lt;/xsl:if&amp;gt;&lt;br /&gt;&amp;lt;xsl:if test="@type = 'TextArea'"&amp;gt;&lt;br /&gt;&amp;lt;asp:textbox id="{@id}" text="" runat="server" height="100px" cssclass="inputboxpopup" textmode="MultiLine"&amp;gt;&amp;lt;/asp:textbox&amp;gt;&lt;br /&gt;&amp;lt;/xsl:if&amp;gt;&lt;br /&gt;&amp;lt;xsl:if test="@type = 'Date'"&amp;gt;&lt;br /&gt;&amp;lt;asp:textbox id="{@id}" text="{$strCurrentDate}" runat="server" cssclass="date-pick"&amp;gt;&amp;lt;/asp:textbox&amp;gt;&lt;br /&gt;&amp;lt;/xsl:if&amp;gt;&lt;br /&gt;&amp;lt;xsl:if test="@type = 'TextBox' and @IsActiveDirectory='false'"&amp;gt;&lt;br /&gt;&amp;lt;asp:textbox id="{@id}" text="" runat="server" cssclass="inputboxpopup"&amp;gt;&amp;lt;/asp:textbox&amp;gt;&lt;br /&gt;&amp;lt;/xsl:if&amp;gt;&lt;br /&gt;&amp;lt;xsl:if test="@type = 'TextBox' and @IsActiveDirectory='true' and @id='requestoremail'"&amp;gt;&lt;br /&gt;&amp;lt;asp:textbox id="{@id}" text="{$requestoremail}" runat="server" cssclass="inputboxpopup"&amp;gt;&amp;lt;/asp:textbox&amp;gt;&lt;br /&gt;&amp;lt;/xsl:if&amp;gt;&lt;br /&gt;&amp;lt;xsl:if test="@type = 'TextBox' and @IsActiveDirectory='true' and @id='requestorlocation'"&amp;gt;&lt;br /&gt;&amp;lt;asp:textbox id="{@id}" text="{$requestorlocation}" runat="server" cssclass="inputboxpopup"&amp;gt;&amp;lt;/asp:textbox&amp;gt;&lt;br /&gt;&amp;lt;/xsl:if&amp;gt;&lt;br /&gt;&amp;lt;xsl:if test="@type = 'TextBox' and @IsActiveDirectory='true' and @id='requestorregion'"&amp;gt;&lt;br /&gt;&amp;lt;asp:textbox id="{@id}" text=" " runat="server" cssclass="inputboxpopup"&amp;gt;&amp;lt;/asp:textbox&amp;gt;&lt;br /&gt;&amp;lt;/xsl:if&amp;gt;&lt;br /&gt;&amp;lt;xsl:if test="@type = 'TextBox' and @IsActiveDirectory='true' and @id='requestoroffice'"&amp;gt;&lt;br /&gt;&amp;lt;asp:textbox id="{@id}" text=" " runat="server" cssclass="inputboxpopup"&amp;gt;&amp;lt;/asp:textbox&amp;gt;&lt;br /&gt;&amp;lt;/xsl:if&amp;gt;&lt;br /&gt;&amp;lt;xsl:if test="@type = 'TextBox' and @IsActiveDirectory='true' and @id='requestordivision'"&amp;gt;&lt;br /&gt;&amp;lt;asp:textbox id="{@id}" text=" " runat="server" cssclass="inputboxpopup"&amp;gt;&amp;lt;/asp:textbox&amp;gt;&lt;br /&gt;&amp;lt;/xsl:if&amp;gt;&lt;br /&gt;&amp;lt;xsl:if test="@type = 'TextBox' and @IsActiveDirectory='true' and @id='requestorpassword'"&amp;gt;&lt;br /&gt;&amp;lt;asp:textbox id="{@id}" text="{$requestorpassword}" runat="server" readonly="false" cssclass="inputboxpopup"&amp;gt;&amp;lt;/asp:textbox&amp;gt;&lt;br /&gt;&amp;lt;/xsl:if&amp;gt;&lt;br /&gt;&amp;lt;xsl:if test="@type = 'TextBoxText' and @IsActiveDirectory='true'"&amp;gt;&lt;br /&gt;&amp;lt;asp:textbox id="{@id}" text="{@text}" runat="server" cssclass="inputboxpopup"&amp;gt;&amp;lt;/asp:textbox&amp;gt;&lt;br /&gt;&amp;lt;/xsl:if&amp;gt;&lt;br /&gt;&amp;lt;xsl:if test="@type = 'CheckBoxList'"&amp;gt;&lt;br /&gt;&amp;lt;asp:checkboxlist id="{@id}" runat="server" repeatdirection="Vertical" repeatlayout="Table" repeatcolumns="{@RepeatColumns}"&amp;gt;&lt;br /&gt;&amp;lt;xsl:for-each select="Listitems/Listitem"&amp;gt;&lt;br /&gt;&amp;lt;asp:listitem style="PADDING-RIGHT: 35px; PADDING-LEFT: 1px; FLOAT: left; PADDING-BOTTOM: 8px; MARGIN: 0px; VERTICAL-ALIGN: top; PADDING-TOP: 0px" text="{@text}" value="{@value}" selected="{@selected}" cellspacing="10px"&amp;gt;&amp;lt;/asp:listitem&amp;gt;&lt;br /&gt;&amp;lt;/xsl:for-each&amp;gt;&lt;br /&gt;&amp;lt;/asp:checkboxlist&amp;gt;&lt;br /&gt;&amp;lt;/xsl:if&amp;gt;&lt;br /&gt;&amp;lt;xsl:if test="@type = 'DropDownList' and @IsActiveDirectory='false'"&amp;gt;&lt;br /&gt;&amp;lt;asp:dropdownlist id="{@id}" style="WIDTH: 209px" runat="server"&amp;gt;&lt;br /&gt;&amp;lt;xsl:for-each select="Listitems/Listitem"&amp;gt;&lt;br /&gt;&amp;lt;asp:listitem text="{@text}" value="{@value}" selected="{@selected}"&amp;gt;&amp;lt;/asp:listitem&amp;gt;&lt;br /&gt;&amp;lt;/xsl:for-each&amp;gt;&lt;br /&gt;&amp;lt;/asp:dropdownlist&amp;gt;&lt;br /&gt;&amp;lt;/xsl:if&amp;gt;&lt;br /&gt;&amp;lt;xsl:if test="@type = 'ListBox'"&amp;gt;&lt;br /&gt;&amp;lt;asp:listbox id="{@id}" style="WIDTH: 209px" runat="server" selectionmode="Multiple"&amp;gt;&lt;br /&gt;&amp;lt;xsl:for-each select="Listitems/Listitem"&amp;gt;&lt;br /&gt;&amp;lt;asp:listitem text="{@text}" value="{@value}" selected="{@selected}"&amp;gt;&amp;lt;/asp:listitem&amp;gt;&lt;br /&gt;&amp;lt;/xsl:for-each&amp;gt;&lt;br /&gt;&amp;lt;/asp:listbox&amp;gt;&lt;br /&gt;&amp;lt;/xsl:if&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;xsl:if test="@type = 'RadioButtonList'"&amp;gt;&lt;br /&gt;&amp;lt;asp:radiobuttonlist id="{@id}" runat="server" repeatdirection="Vertical" repeatlayout="Table" repeatcolumns="{@RepeatColumns}"&amp;gt;&lt;br /&gt;&amp;lt;xsl:for-each select="Listitems/Listitem"&amp;gt;&lt;br /&gt;&amp;lt;asp:listitem style="PADDING-RIGHT: 35px; PADDING-LEFT: 1px; FLOAT: left; PADDING-BOTTOM: 8px; MARGIN: 0px; VERTICAL-ALIGN: top; PADDING-TOP: 0px" text="{@text}" value="{@value}" selected="{@selected}"&amp;gt;&amp;lt;/asp:listitem&amp;gt;&lt;br /&gt;&amp;lt;/xsl:for-each&amp;gt;&lt;br /&gt;&amp;lt;/asp:radiobuttonlist&amp;gt;&lt;br /&gt;&amp;lt;/xsl:if&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;div style="PADDING-LEFT: 20px"&amp;gt;&lt;br /&gt;&amp;lt;xsl:if test="@type = 'RadioButtonListIndent2'"&amp;gt;&lt;br /&gt;&amp;lt;asp:radiobuttonlist id="{@id}" runat="server" repeatdirection="Vertical" repeatlayout="Table" repeatcolumns="{@RepeatColumns}"&amp;gt;&lt;br /&gt;&amp;lt;xsl:for-each select="Listitems/Listitem"&amp;gt;&lt;br /&gt;&amp;lt;asp:listitem style="PADDING-RIGHT: 35px; PADDING-LEFT: 1px; FLOAT: left; PADDING-BOTTOM: 8px; MARGIN: 0px; VERTICAL-ALIGN: top; PADDING-TOP: 0px" text="{@text}" value="{@value}" selected="{@selected}"&amp;gt;&amp;lt;/asp:listitem&amp;gt;&lt;br /&gt;&amp;lt;/xsl:for-each&amp;gt;&lt;br /&gt;&amp;lt;/asp:radiobuttonlist&amp;gt;&lt;br /&gt;&amp;lt;/xsl:if&amp;gt;&lt;br /&gt;&amp;lt;/div&amp;gt;&lt;br /&gt;&amp;lt;/td&amp;gt;&lt;br /&gt;&amp;lt;/xsl:if&amp;gt;&lt;br /&gt;&amp;lt;xsl:if test="@type = 'label' and @id='footername'"&amp;gt;&lt;br /&gt;&amp;lt;td class="labelHeading" style="PADDING-LEFT: 60px" align="left" colspan="6"&amp;gt;&lt;br /&gt;&amp;lt;asp:label text="{@label}" runat="server"&amp;gt;&amp;lt;/asp:label&amp;gt;&lt;br /&gt;&amp;lt;/td&amp;gt;&lt;br /&gt;&amp;lt;/xsl:if&amp;gt;&lt;br /&gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;&amp;lt;/xsl:for-each&amp;gt;&lt;br /&gt;&amp;lt;/tbody&amp;gt;&amp;lt;/table&amp;gt;&lt;br /&gt;&amp;lt;/td&amp;gt;&lt;br /&gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;&amp;lt;/tbody&amp;gt;&amp;lt;/table&amp;gt;&lt;br /&gt;&amp;lt;/div&amp;gt;&lt;br /&gt;&amp;lt;/td&amp;gt;&lt;br /&gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;&amp;lt;/tbody&amp;gt;&amp;lt;/table&amp;gt;&lt;br /&gt;&amp;lt;/div&amp;gt;&lt;br /&gt;&amp;lt;/div&amp;gt;&lt;br /&gt;&amp;lt;/td&amp;gt;&lt;br /&gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;&amp;lt;/tbody&amp;gt;&amp;lt;/table&amp;gt;&lt;br /&gt;&amp;lt;/xsl:template&amp;gt;&lt;br /&gt;&amp;lt;xsl:template name="break"&amp;gt;&lt;br /&gt;&amp;lt;xsl:param name="text" select="."&amp;gt;&amp;lt;/xsl:param&amp;gt;&lt;br /&gt;&amp;lt;xsl:choose&amp;gt;&lt;br /&gt;&amp;lt;xsl:when test="contains($text, '&amp;#10;')"&amp;gt;&lt;br /&gt;&amp;lt;xsl:value-of select="substring-before($text, '&amp;#10;')"&amp;gt;&amp;lt;/xsl:value-of&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;xsl:call-template name="break"&amp;gt;&lt;br /&gt;&amp;lt;xsl:with-param name="label" select="substring-after($text, '&amp;#10;')"&amp;gt;&amp;lt;/xsl:with-param&amp;gt;&lt;br /&gt;&amp;lt;/xsl:call-template&amp;gt;&lt;br /&gt;&amp;lt;/xsl:when&amp;gt;&lt;br /&gt;&amp;lt;xsl:otherwise&amp;gt;&lt;br /&gt;&amp;lt;xsl:value-of select="$text"&amp;gt;&amp;lt;/xsl:value-of&amp;gt;&lt;br /&gt;&amp;lt;/xsl:otherwise&amp;gt;&lt;br /&gt;&amp;lt;/xsl:choose&amp;gt;&lt;br /&gt;&amp;lt;/xsl:template&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;/xsl:stylesheet&amp;gt;&lt;br /&gt;&lt;br /&gt;----------------&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7527040749709927669-1076386074544671038?l=jaan1762.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jaan1762.blogspot.com/feeds/1076386074544671038/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7527040749709927669&amp;postID=1076386074544671038' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/1076386074544671038'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/1076386074544671038'/><link rel='alternate' type='text/html' href='http://jaan1762.blogspot.com/2010/04/xsl.html' title='XSL'/><author><name>Mansoor</name><uri>http://www.blogger.com/profile/00473621254256960630</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-7527040749709927669.post-1736735458483743045</id><published>2010-04-21T00:21:00.000-07:00</published><updated>2010-04-25T23:02:29.840-07:00</updated><title type='text'>xsl v</title><content type='html'>&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;&lt;br /&gt;&amp;lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:asp="remove"&amp;gt;&lt;br /&gt;  &amp;lt;xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/&amp;gt;&lt;br /&gt;  &amp;lt;xsl:param name="session_name"/&amp;gt;&lt;br /&gt;  &amp;lt;xsl:template match="ServiceName"&amp;gt;&lt;br /&gt;    &amp;lt;table  border="0" cellpadding="0" cellspacing="0" width="700px" &amp;gt;&lt;br /&gt;      &amp;lt;tr&amp;gt;&lt;br /&gt;        &amp;lt;td&amp;gt;&lt;br /&gt;          &amp;lt;div id="content_area"&amp;gt;&lt;br /&gt;            &amp;lt;div class="ControlHeading"&amp;gt;&lt;br /&gt;              &amp;lt;table border="0" cellpadding="0" cellspacing="0" width="700px"&amp;gt;&lt;br /&gt;                &amp;lt;tr&amp;gt;&lt;br /&gt;                  &amp;lt;td&amp;gt;&lt;br /&gt;                    &amp;lt;div id="request_heading" style="text-align:left;"&amp;gt;&lt;br /&gt;                      &amp;lt;!--&amp;lt;xsl:value-of select="@name"/&amp;gt;--&amp;gt;&lt;br /&gt;                    &amp;lt;/div&amp;gt;&lt;br /&gt;                  &amp;lt;/td&amp;gt;&lt;br /&gt;                &amp;lt;/tr&amp;gt;&lt;br /&gt;                &amp;lt;tr&amp;gt;&lt;br /&gt;                  &amp;lt;td&amp;gt;&lt;br /&gt;                    &amp;lt;table  border="0" cellpadding="0" cellspacing="0" class="service_contentTable" style="text-align:left;"&amp;gt;&lt;br /&gt;                      &amp;lt;tr&amp;gt;&lt;br /&gt;                        &amp;lt;td&amp;gt;&lt;br /&gt;                          &amp;lt;table border="0" cellpadding="0" cellspacing="0"&amp;gt;&lt;br /&gt;                            &amp;lt;tr&amp;gt;&lt;br /&gt;                              &amp;lt;td height="5px"&amp;gt;&lt;br /&gt;                              &amp;lt;/td&amp;gt;&lt;br /&gt;                            &amp;lt;/tr&amp;gt;&lt;br /&gt;                            &amp;lt;xsl:for-each select="//Field"&amp;gt;&lt;br /&gt;                              &amp;lt;tr&amp;gt;&lt;br /&gt;                                &amp;lt;td class="labelHeading"&amp;gt;                                  &lt;br /&gt;                                  &amp;lt;xsl:choose&amp;gt;&lt;br /&gt;                                    &amp;lt;xsl:when test="contains(@label, '\n')"&amp;gt;&lt;br /&gt;                                      &amp;lt;xsl:value-of  select="substring-before(@label, '\n')"/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;xsl:value-of  select="substring-after(@label, '\n')"/&amp;gt;                                      &lt;br /&gt;                                    &amp;lt;/xsl:when&amp;gt;&lt;br /&gt;                                    &amp;lt;xsl:otherwise&amp;gt;&lt;br /&gt;                                      &amp;lt;xsl:value-of select="@label"/&amp;gt;&lt;br /&gt;                                    &amp;lt;/xsl:otherwise&amp;gt;&lt;br /&gt;                                  &amp;lt;/xsl:choose&amp;gt;                                  &lt;br /&gt;                                &amp;lt;/td&amp;gt;&lt;br /&gt;                                &amp;lt;td style="width:5px"&amp;gt;&lt;br /&gt;                                &amp;lt;/td&amp;gt;&lt;br /&gt;                                &amp;lt;td &amp;gt;&lt;br /&gt;                                  &amp;lt;xsl:if test="@type = 'TextBox'"&amp;gt;&lt;br /&gt;                     &lt;br /&gt;                                    &amp;lt;xsl:value-of select="@value"/&amp;gt;&lt;br /&gt;                                  &amp;lt;/xsl:if&amp;gt;&lt;br /&gt;                                  &amp;lt;xsl:if test="@type = 'CheckBoxList'"&amp;gt;&lt;br /&gt;                                    &amp;lt;xsl:for-each select="Listitems/Listitem"&amp;gt;&lt;br /&gt;                                      &amp;lt;xsl:if test="@selected = 'True'"&amp;gt;&lt;br /&gt;                                        &amp;lt;xsl:value-of select="@value"/&amp;gt;&lt;br /&gt;                                        &amp;lt;xsl:value-of select="','"/&amp;gt;&lt;br /&gt;                                      &amp;lt;/xsl:if&amp;gt;&lt;br /&gt;                                    &amp;lt;/xsl:for-each&amp;gt;&lt;br /&gt;                                  &amp;lt;/xsl:if&amp;gt;&lt;br /&gt;&lt;br /&gt;                                  &amp;lt;xsl:if test="@type = 'DropDownList'"&amp;gt;&lt;br /&gt;                                    &amp;lt;xsl:for-each select="Listitems/Listitem"&amp;gt;&lt;br /&gt;                                      &amp;lt;xsl:if test="@selected = 'True'"&amp;gt;&lt;br /&gt;                                        &amp;lt;xsl:value-of select="@value"/&amp;gt;&lt;br /&gt;                                        &amp;lt;xsl:value-of select="','"/&amp;gt;&lt;br /&gt;                                      &amp;lt;/xsl:if&amp;gt;&lt;br /&gt;                                    &amp;lt;/xsl:for-each&amp;gt;&lt;br /&gt;                                  &amp;lt;/xsl:if&amp;gt;&lt;br /&gt;&lt;br /&gt;                                  &amp;lt;xsl:if test="@type = 'ListBox'"&amp;gt;&lt;br /&gt;                                    &amp;lt;xsl:for-each select="Listitems/Listitem"&amp;gt;&lt;br /&gt;                                      &amp;lt;xsl:if test="@selected = 'True'"&amp;gt;&lt;br /&gt;                                        &amp;lt;xsl:value-of select="@value"/&amp;gt;&lt;br /&gt;                                        &amp;lt;xsl:value-of select="','"/&amp;gt;&lt;br /&gt;                                      &amp;lt;/xsl:if&amp;gt;&lt;br /&gt;                                    &amp;lt;/xsl:for-each&amp;gt;&lt;br /&gt;                                  &amp;lt;/xsl:if&amp;gt;&lt;br /&gt;&lt;br /&gt;                                  &amp;lt;xsl:if test="@type = 'RadioButtonList'"&amp;gt;&lt;br /&gt;                                    &amp;lt;xsl:for-each select="Listitems/Listitem"&amp;gt;&lt;br /&gt;                                      &amp;lt;xsl:if test="@selected = 'True'"&amp;gt;&lt;br /&gt;                                        &amp;lt;xsl:value-of select="@value"/&amp;gt;&lt;br /&gt;                                        &amp;lt;xsl:value-of select="','"/&amp;gt;&lt;br /&gt;                                      &amp;lt;/xsl:if&amp;gt;&lt;br /&gt;                                    &amp;lt;/xsl:for-each&amp;gt;&lt;br /&gt;                                  &amp;lt;/xsl:if&amp;gt;&lt;br /&gt;&lt;br /&gt;                                &amp;lt;/td&amp;gt;&lt;br /&gt;                              &amp;lt;/tr&amp;gt;&lt;br /&gt;                            &amp;lt;/xsl:for-each&amp;gt;&lt;br /&gt;                          &amp;lt;/table&amp;gt;&lt;br /&gt;                        &amp;lt;/td&amp;gt;&lt;br /&gt;                      &amp;lt;/tr&amp;gt;&lt;br /&gt;                    &amp;lt;/table&amp;gt;&lt;br /&gt;                  &amp;lt;/td&amp;gt;&lt;br /&gt;                &amp;lt;/tr&amp;gt;&lt;br /&gt;              &amp;lt;/table&amp;gt;&lt;br /&gt;            &amp;lt;/div&amp;gt;&lt;br /&gt;          &amp;lt;/div&amp;gt;&lt;br /&gt;        &amp;lt;/td&amp;gt;&lt;br /&gt;      &amp;lt;/tr&amp;gt;&lt;br /&gt;    &amp;lt;/table&amp;gt;&lt;br /&gt;  &amp;lt;/xsl:template&amp;gt;&lt;br /&gt;&amp;lt;/xsl:stylesheet&amp;gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7527040749709927669-1736735458483743045?l=jaan1762.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jaan1762.blogspot.com/feeds/1736735458483743045/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7527040749709927669&amp;postID=1736735458483743045' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/1736735458483743045'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/1736735458483743045'/><link rel='alternate' type='text/html' href='http://jaan1762.blogspot.com/2010/04/xsl-v.html' title='xsl v'/><author><name>Mansoor</name><uri>http://www.blogger.com/profile/00473621254256960630</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-7527040749709927669.post-4841744293769092978</id><published>2010-02-22T23:23:00.000-08:00</published><updated>2010-02-22T23:26:55.280-08:00</updated><title type='text'>A potentially dangerous Request.Form value was detected from the client (TextBoxN="...")</title><content type='html'>Set  ValidateRequest="false"&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Unless you actually need users to be able to enter HTML you must convert the string to its html encoding equivalent - basically this means that certain characters (like "&lt;") are converted to codes (so "&lt;" is converted to "&amp;lt;"). To perform this conversion use HttpUtility.HtmlEncode, for example: &lt;br /&gt;MyLabel.Text := HttpUtility.HtmlEncode(MyTextBox.Text);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; public static string ConvertStringToHTML(string OldString)&lt;br /&gt;    {&lt;br /&gt;        string NewString="";&lt;br /&gt;        NewString=OldString.Replace("&amp;","&amp;amp;");//this should be first, next &amp; will come for &lt; and &gt;.&lt;br /&gt;        NewString=NewString.Replace("&lt;","&amp;lt;").Replace("&gt;","&amp;gt;");&lt;br /&gt;        return NewString;&lt;br /&gt;    }&lt;br /&gt;    public static string ConvertHTMLToString(string OldString)&lt;br /&gt;    {&lt;br /&gt;        string NewString="";&lt;br /&gt;        NewString=OldString.Replace("&amp;amp;","&amp;");&lt;br /&gt;        NewString=NewString.Replace("&amp;lt;","&lt;").Replace("&amp;gt;","&gt;");&lt;br /&gt;        return NewString;&lt;br /&gt;    }&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7527040749709927669-4841744293769092978?l=jaan1762.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jaan1762.blogspot.com/feeds/4841744293769092978/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7527040749709927669&amp;postID=4841744293769092978' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/4841744293769092978'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/4841744293769092978'/><link rel='alternate' type='text/html' href='http://jaan1762.blogspot.com/2010/02/potentially-dangerous-requestform-value.html' title='A potentially dangerous Request.Form value was detected from the client (TextBoxN=&quot;...&quot;)'/><author><name>Mansoor</name><uri>http://www.blogger.com/profile/00473621254256960630</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-7527040749709927669.post-6103287899255853572</id><published>2010-02-16T08:52:00.000-08:00</published><updated>2010-02-16T08:54:46.061-08:00</updated><title type='text'>How to format datetime &amp; date in Sql Server 2005</title><content type='html'>Execute the following Microsoft SQL Server T-SQL datetime and date formatting scripts in Management Studio Query Editor to demonstrate the multitude of temporal data formats available in SQL Server.&lt;br /&gt;&lt;br /&gt;First we start with the conversion options available for sql datetime formats with century (YYYY or CCYY format). Subtracting 100 from the Style (format) number will transform dates without century (YY). For example Style 103 is with century, Style 3 is without century. The default Style values – Style 0 or 100, 9 or 109, 13 or 113, 20 or 120, and 21 or 121 – always return the century (yyyy) format.&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;– Microsoft SQL Server T-SQL date and datetime formats&lt;br /&gt;&lt;br /&gt;– Date time formats – mssql datetime &lt;br /&gt;&lt;br /&gt;– MSSQL getdate returns current system date and time in standard internal format&lt;br /&gt;&lt;br /&gt;SELECT convert(varchar, getdate(), 100) – mon dd yyyy hh:mmAM (or PM)&lt;br /&gt;&lt;br /&gt;                                        – Oct  2 2008 11:01AM          &lt;br /&gt;&lt;br /&gt;SELECT convert(varchar, getdate(), 101) – mm/dd/yyyy - 10/02/2008                  &lt;br /&gt;&lt;br /&gt;SELECT convert(varchar, getdate(), 102) – yyyy.mm.dd – 2008.10.02           &lt;br /&gt;&lt;br /&gt;SELECT convert(varchar, getdate(), 103) – dd/mm/yyyy&lt;br /&gt;&lt;br /&gt;SELECT convert(varchar, getdate(), 104) – dd.mm.yyyy&lt;br /&gt;&lt;br /&gt;SELECT convert(varchar, getdate(), 105) – dd-mm-yyyy&lt;br /&gt;&lt;br /&gt;SELECT convert(varchar, getdate(), 106) – dd mon yyyy&lt;br /&gt;&lt;br /&gt;SELECT convert(varchar, getdate(), 107) – mon dd, yyyy&lt;br /&gt;&lt;br /&gt;SELECT convert(varchar, getdate(), 108) – hh:mm:ss&lt;br /&gt;&lt;br /&gt;SELECT convert(varchar, getdate(), 109) – mon dd yyyy hh:mm:ss:mmmAM (or PM)&lt;br /&gt;&lt;br /&gt;                                        – Oct  2 2008 11:02:44:013AM   &lt;br /&gt;&lt;br /&gt;SELECT convert(varchar, getdate(), 110) – mm-dd-yyyy&lt;br /&gt;&lt;br /&gt;SELECT convert(varchar, getdate(), 111) – yyyy/mm/dd&lt;br /&gt;&lt;br /&gt;SELECT convert(varchar, getdate(), 112) – yyyymmdd&lt;br /&gt;&lt;br /&gt;SELECT convert(varchar, getdate(), 113) – dd mon yyyy hh:mm:ss:mmm&lt;br /&gt;&lt;br /&gt;                                        – 02 Oct 2008 11:02:07:577     &lt;br /&gt;&lt;br /&gt;SELECT convert(varchar, getdate(), 114) – hh:mm:ss:mmm(24h)&lt;br /&gt;&lt;br /&gt;SELECT convert(varchar, getdate(), 120) – yyyy-mm-dd hh:mm:ss(24h)&lt;br /&gt;&lt;br /&gt;SELECT convert(varchar, getdate(), 121) – yyyy-mm-dd hh:mm:ss.mmm&lt;br /&gt;&lt;br /&gt;SELECT convert(varchar, getdate(), 126) – yyyy-mm-ddThh:mm:ss.mmm&lt;br /&gt;&lt;br /&gt;                                        – 2008-10-02T10:52:47.513&lt;br /&gt;&lt;br /&gt;– SQL create different date styles with t-sql string functions&lt;br /&gt;&lt;br /&gt;SELECT replace(convert(varchar, getdate(), 111), ‘/’, ‘ ‘) – yyyy mm dd&lt;br /&gt;&lt;br /&gt;SELECT convert(varchar(7), getdate(), 126)                 – yyyy-mm&lt;br /&gt;&lt;br /&gt;SELECT right(convert(varchar, getdate(), 106), 8)          – mon yyyy&lt;br /&gt;&lt;br /&gt;————&lt;br /&gt;&lt;br /&gt;– SQL Server date formatting function – convert datetime to string&lt;br /&gt;&lt;br /&gt;————&lt;br /&gt;&lt;br /&gt;– SQL datetime functions&lt;br /&gt;&lt;br /&gt;– SQL Server date formats&lt;br /&gt;&lt;br /&gt;– T-SQL convert dates&lt;br /&gt;&lt;br /&gt;– Formatting dates sql server&lt;br /&gt;&lt;br /&gt;CREATE FUNCTION dbo.fnFormatDate (@Datetime DATETIME, @FormatMask VARCHAR(32))&lt;br /&gt;&lt;br /&gt;RETURNS VARCHAR(32)&lt;br /&gt;&lt;br /&gt;AS&lt;br /&gt;&lt;br /&gt;BEGIN&lt;br /&gt;&lt;br /&gt;    DECLARE @StringDate VARCHAR(32)&lt;br /&gt;&lt;br /&gt;    SET @StringDate = @FormatMask&lt;br /&gt;&lt;br /&gt;    IF (CHARINDEX (‘YYYY’,@StringDate) &gt; 0)&lt;br /&gt;&lt;br /&gt;       SET @StringDate = REPLACE(@StringDate, ‘YYYY’,&lt;br /&gt;&lt;br /&gt;                         DATENAME(YY, @Datetime))&lt;br /&gt;&lt;br /&gt;    IF (CHARINDEX (‘YY’,@StringDate) &gt; 0)&lt;br /&gt;&lt;br /&gt;       SET @StringDate = REPLACE(@StringDate, ‘YY’,&lt;br /&gt;&lt;br /&gt;                         RIGHT(DATENAME(YY, @Datetime),2))&lt;br /&gt;&lt;br /&gt;    IF (CHARINDEX (‘Month’,@StringDate) &gt; 0)&lt;br /&gt;&lt;br /&gt;       SET @StringDate = REPLACE(@StringDate, ‘Month’,&lt;br /&gt;&lt;br /&gt;                         DATENAME(MM, @Datetime))&lt;br /&gt;&lt;br /&gt;    IF (CHARINDEX (‘MON’,@StringDate COLLATE SQL_Latin1_General_CP1_CS_AS)&gt;0)&lt;br /&gt;&lt;br /&gt;       SET @StringDate = REPLACE(@StringDate, ‘MON’,&lt;br /&gt;&lt;br /&gt;                         LEFT(UPPER(DATENAME(MM, @Datetime)),3))&lt;br /&gt;&lt;br /&gt;    IF (CHARINDEX (‘Mon’,@StringDate) &gt; 0)&lt;br /&gt;&lt;br /&gt;       SET @StringDate = REPLACE(@StringDate, ‘Mon’,&lt;br /&gt;&lt;br /&gt;                                     LEFT(DATENAME(MM, @Datetime),3))&lt;br /&gt;&lt;br /&gt;    IF (CHARINDEX (‘MM’,@StringDate) &gt; 0)&lt;br /&gt;&lt;br /&gt;       SET @StringDate = REPLACE(@StringDate, ‘MM’,&lt;br /&gt;&lt;br /&gt;                  RIGHT(‘0′+CONVERT(VARCHAR,DATEPART(MM, @Datetime)),2))&lt;br /&gt;&lt;br /&gt;    IF (CHARINDEX (‘M’,@StringDate) &gt; 0)&lt;br /&gt;&lt;br /&gt;       SET @StringDate = REPLACE(@StringDate, ‘M’,&lt;br /&gt;&lt;br /&gt;                         CONVERT(VARCHAR,DATEPART(MM, @Datetime)))&lt;br /&gt;&lt;br /&gt;    IF (CHARINDEX (‘DD’,@StringDate) &gt; 0)&lt;br /&gt;&lt;br /&gt;       SET @StringDate = REPLACE(@StringDate, ‘DD’,&lt;br /&gt;&lt;br /&gt;                         RIGHT(‘0′+DATENAME(DD, @Datetime),2))&lt;br /&gt;&lt;br /&gt;    IF (CHARINDEX (‘D’,@StringDate) &gt; 0)&lt;br /&gt;&lt;br /&gt;       SET @StringDate = REPLACE(@StringDate, ‘D’,&lt;br /&gt;&lt;br /&gt;                                     DATENAME(DD, @Datetime))   &lt;br /&gt;&lt;br /&gt;RETURN @StringDate&lt;br /&gt;&lt;br /&gt;END&lt;br /&gt;&lt;br /&gt;GO&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;– Microsoft SQL Server date format function test&lt;br /&gt;&lt;br /&gt;– MSSQL formatting dates&lt;br /&gt;&lt;br /&gt;SELECT dbo.fnFormatDate (getdate(), ‘MM/DD/YYYY’)           – 01/03/2012&lt;br /&gt;&lt;br /&gt;SELECT dbo.fnFormatDate (getdate(), ‘DD/MM/YYYY’)           – 03/01/2012&lt;br /&gt;&lt;br /&gt;SELECT dbo.fnFormatDate (getdate(), ‘M/DD/YYYY’)            – 1/03/2012&lt;br /&gt;&lt;br /&gt;SELECT dbo.fnFormatDate (getdate(), ‘M/D/YYYY’)             – 1/3/2012&lt;br /&gt;&lt;br /&gt;SELECT dbo.fnFormatDate (getdate(), ‘M/D/YY’)               – 1/3/12&lt;br /&gt;&lt;br /&gt;SELECT dbo.fnFormatDate (getdate(), ‘MM/DD/YY’)             – 01/03/12&lt;br /&gt;&lt;br /&gt;SELECT dbo.fnFormatDate (getdate(), ‘MON DD, YYYY’)         – JAN 03, 2012&lt;br /&gt;&lt;br /&gt;SELECT dbo.fnFormatDate (getdate(), ‘Mon DD, YYYY’)         – Jan 03, 2012&lt;br /&gt;&lt;br /&gt;SELECT dbo.fnFormatDate (getdate(), ‘Month DD, YYYY’)       – January 03, 2012&lt;br /&gt;&lt;br /&gt;SELECT dbo.fnFormatDate (getdate(), ‘YYYY/MM/DD’)           – 2012/01/03&lt;br /&gt;&lt;br /&gt;SELECT dbo.fnFormatDate (getdate(), ‘YYYYMMDD’)             – 20120103&lt;br /&gt;&lt;br /&gt;SELECT dbo.fnFormatDate (getdate(), ‘YYYY-MM-DD’)           – 2012-01-03&lt;br /&gt;&lt;br /&gt;– CURRENT_TIMESTAMP returns current system date and time in standard internal format&lt;br /&gt;&lt;br /&gt;SELECT dbo.fnFormatDate (CURRENT_TIMESTAMP,‘YY.MM.DD’)      – 12.01.03&lt;br /&gt;&lt;br /&gt;GO&lt;br /&gt;&lt;br /&gt;————&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;/***** SELECTED SQL DATE/DATETIME FORMATS WITH NAMES *****/&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;– SQL format datetime&lt;br /&gt;&lt;br /&gt;– Default format: Oct 23 2006 10:40AM&lt;br /&gt;&lt;br /&gt;SELECT [Default]=CONVERT(varchar,GETDATE(),100)&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;– US-Style format: 10/23/2006&lt;br /&gt;&lt;br /&gt;SELECT [US-Style]=CONVERT(char,GETDATE(),101)&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;– ANSI format: 2006.10.23&lt;br /&gt;&lt;br /&gt;SELECT [ANSI]=CONVERT(char,CURRENT_TIMESTAMP,102)&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;– UK-Style format: 23/10/2006&lt;br /&gt;&lt;br /&gt;SELECT [UK-Style]=CONVERT(char,GETDATE(),103)&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;– German format: 23.10.2006&lt;br /&gt;&lt;br /&gt;SELECT [German]=CONVERT(varchar,GETDATE(),104)&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;– ISO format: 20061023&lt;br /&gt;&lt;br /&gt;SELECT ISO=CONVERT(varchar,GETDATE(),112)&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;– ISO8601 format: 2008-10-23T19:20:16.003&lt;br /&gt;&lt;br /&gt;SELECT [ISO8601]=CONVERT(varchar,GETDATE(),126)&lt;br /&gt;&lt;br /&gt;————&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;– SQL Server datetime formats&lt;br /&gt;&lt;br /&gt;– Century date format MM/DD/YYYY usage in a query&lt;br /&gt;&lt;br /&gt;– Format dates SQL Server 2005&lt;br /&gt;&lt;br /&gt;SELECT TOP (1)&lt;br /&gt;&lt;br /&gt;      SalesOrderID,&lt;br /&gt;&lt;br /&gt;      OrderDate = CONVERT(char(10), OrderDate, 101),&lt;br /&gt;&lt;br /&gt;      OrderDateTime = OrderDate&lt;br /&gt;&lt;br /&gt;FROM AdventureWorks.Sales.SalesOrderHeader&lt;br /&gt;&lt;br /&gt;/* Result&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;SalesOrderID      OrderDate               OrderDateTime&lt;br /&gt;&lt;br /&gt;43697             07/01/2001          2001-07-01 00:00:00.000&lt;br /&gt;&lt;br /&gt;*/&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;– SQL update datetime column&lt;br /&gt;&lt;br /&gt;– SQL datetime DATEADD&lt;br /&gt;&lt;br /&gt;UPDATE Production.Product&lt;br /&gt;&lt;br /&gt;SET ModifiedDate=DATEADD(dd,1, ModifiedDate)&lt;br /&gt;&lt;br /&gt;WHERE ProductID = 1001&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;– MM/DD/YY date format&lt;br /&gt;&lt;br /&gt;– Datetime format sql&lt;br /&gt;&lt;br /&gt;SELECT TOP (1)&lt;br /&gt;&lt;br /&gt;      SalesOrderID,&lt;br /&gt;&lt;br /&gt;      OrderDate = CONVERT(varchar(8), OrderDate, 1),&lt;br /&gt;&lt;br /&gt;      OrderDateTime = OrderDate&lt;br /&gt;&lt;br /&gt;FROM AdventureWorks.Sales.SalesOrderHeader&lt;br /&gt;&lt;br /&gt;ORDER BY SalesOrderID desc&lt;br /&gt;&lt;br /&gt;/* Result&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;SalesOrderID      OrderDate         OrderDateTime&lt;br /&gt;&lt;br /&gt;75123             07/31/04          2004-07-31 00:00:00.000&lt;br /&gt;&lt;br /&gt;*/&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;– Combining different style formats for date &amp; time&lt;br /&gt;&lt;br /&gt;– Datetime formats&lt;br /&gt;&lt;br /&gt;– Datetime formats sql&lt;br /&gt;&lt;br /&gt;DECLARE @Date DATETIME&lt;br /&gt;&lt;br /&gt;SET @Date = ‘2015-12-22 03:51 PM’&lt;br /&gt;&lt;br /&gt;SELECT CONVERT(CHAR(10),@Date,110) + SUBSTRING(CONVERT(varchar,@Date,0),12,8)&lt;br /&gt;&lt;br /&gt;– Result: 12-22-2015  3:51PM&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;– Microsoft SQL Server cast datetime to string&lt;br /&gt;&lt;br /&gt;SELECT stringDateTime=CAST (getdate() as varchar)&lt;br /&gt;&lt;br /&gt;– Result: Dec 29 2012  3:47AM&lt;br /&gt;&lt;br /&gt;————&lt;br /&gt;&lt;br /&gt;– SQL Server date and time functions overview&lt;br /&gt;&lt;br /&gt;————&lt;br /&gt;&lt;br /&gt;– SQL Server CURRENT_TIMESTAMP function&lt;br /&gt;&lt;br /&gt;– SQL Server datetime functions&lt;br /&gt;&lt;br /&gt;– local NYC – EST – Eastern Standard Time zone&lt;br /&gt;&lt;br /&gt;– SQL DATEADD function – SQL DATEDIFF function&lt;br /&gt;&lt;br /&gt;SELECT CURRENT_TIMESTAMP                        – 2012-01-05 07:02:10.577&lt;br /&gt;&lt;br /&gt;– SQL Server DATEADD function&lt;br /&gt;&lt;br /&gt;SELECT DATEADD(month,2,‘2012-12-09′)            – 2013-02-09 00:00:00.000&lt;br /&gt;&lt;br /&gt;– SQL Server DATEDIFF function&lt;br /&gt;&lt;br /&gt;SELECT DATEDIFF(day,‘2012-12-09′,‘2013-02-09′)  – 62&lt;br /&gt;&lt;br /&gt;– SQL Server DATENAME function&lt;br /&gt;&lt;br /&gt;SELECT DATENAME(month,   ‘2012-12-09′)          – December&lt;br /&gt;&lt;br /&gt;SELECT DATENAME(weekday, ‘2012-12-09′)          – Sunday&lt;br /&gt;&lt;br /&gt;– SQL Server DATEPART function&lt;br /&gt;&lt;br /&gt;SELECT DATEPART(month, ‘2012-12-09′)            – 12&lt;br /&gt;&lt;br /&gt;– SQL Server DAY function&lt;br /&gt;&lt;br /&gt;SELECT DAY(‘2012-12-09′)                        – 9&lt;br /&gt;&lt;br /&gt;– SQL Server GETDATE function&lt;br /&gt;&lt;br /&gt;– local NYC – EST – Eastern Standard Time zone&lt;br /&gt;&lt;br /&gt;SELECT GETDATE()                                – 2012-01-05 07:02:10.577&lt;br /&gt;&lt;br /&gt;– SQL Server GETUTCDATE function&lt;br /&gt;&lt;br /&gt;– London – Greenwich Mean Time&lt;br /&gt;&lt;br /&gt;SELECT GETUTCDATE()                             – 2012-01-05 12:02:10.577&lt;br /&gt;&lt;br /&gt;– SQL Server MONTH function&lt;br /&gt;&lt;br /&gt;SELECT MONTH(‘2012-12-09′)                      – 12&lt;br /&gt;&lt;br /&gt;– SQL Server YEAR function&lt;br /&gt;&lt;br /&gt;SELECT YEAR(‘2012-12-09′)                       – 2012&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;————&lt;br /&gt;&lt;br /&gt;– T-SQL Date and time function application&lt;br /&gt;&lt;br /&gt;– CURRENT_TIMESTAMP and getdate() are the same in T-SQL&lt;br /&gt;&lt;br /&gt;————&lt;br /&gt;&lt;br /&gt;– SQL first day of the month&lt;br /&gt;&lt;br /&gt;– SQL first date of the month&lt;br /&gt;&lt;br /&gt;– SQL first day of current month – 2012-01-01 00:00:00.000&lt;br /&gt;&lt;br /&gt;SELECT DATEADD(dd,0,DATEADD(mm, DATEDIFF(mm,0,CURRENT_TIMESTAMP),0))&lt;br /&gt;&lt;br /&gt;– SQL last day of the month&lt;br /&gt;&lt;br /&gt;– SQL last date of the month&lt;br /&gt;&lt;br /&gt;– SQL last day of current month – 2012-01-31 00:00:00.000&lt;br /&gt;&lt;br /&gt;SELECT DATEADD(dd,-1,DATEADD(mm, DATEDIFF(mm,0,CURRENT_TIMESTAMP)+1,0))&lt;br /&gt;&lt;br /&gt;– SQL first day of last month&lt;br /&gt;&lt;br /&gt;– SQL first day of previous month – 2011-12-01 00:00:00.000&lt;br /&gt;&lt;br /&gt;SELECT DATEADD(mm,-1,DATEADD(mm, DATEDIFF(mm,0,CURRENT_TIMESTAMP),0))&lt;br /&gt;&lt;br /&gt;– SQL last day of last month&lt;br /&gt;&lt;br /&gt;– SQL last day of previous month – 2011-12-31 00:00:00.000&lt;br /&gt;&lt;br /&gt;SELECT DATEADD(dd,-1,DATEADD(mm, DATEDIFF(mm,0,DATEADD(MM,-1,GETDATE()))+1,0))&lt;br /&gt;&lt;br /&gt;– SQL first day of next month – 2012-02-01 00:00:00.000&lt;br /&gt;&lt;br /&gt;SELECT DATEADD(mm,1,DATEADD(mm, DATEDIFF(mm,0,CURRENT_TIMESTAMP),0))&lt;br /&gt;&lt;br /&gt;– SQL last day of next month – 2012-02-28 00:00:00.000&lt;br /&gt;&lt;br /&gt;SELECT DATEADD(dd,-1,DATEADD(mm, DATEDIFF(mm,0,DATEADD(MM,1,GETDATE()))+1,0))&lt;br /&gt;&lt;br /&gt;GO&lt;br /&gt;&lt;br /&gt;– SQL first day of a month – 2012-10-01 00:00:00.000&lt;br /&gt;&lt;br /&gt;DECLARE @Date datetime; SET @Date = ‘2012-10-23′&lt;br /&gt;&lt;br /&gt;SELECT DATEADD(dd,0,DATEADD(mm, DATEDIFF(mm,0,@Date),0))&lt;br /&gt;&lt;br /&gt;GO&lt;br /&gt;&lt;br /&gt;– SQL last day of a month – 2012-03-31 00:00:00.000&lt;br /&gt;&lt;br /&gt;DECLARE @Date datetime; SET @Date = ‘2012-03-15′&lt;br /&gt;&lt;br /&gt;SELECT DATEADD(dd,-1,DATEADD(mm, DATEDIFF(mm,0,@Date)+1,0))&lt;br /&gt;&lt;br /&gt;GO&lt;br /&gt;&lt;br /&gt;– SQL first day of year &lt;br /&gt;&lt;br /&gt;– SQL first day of the year  -  2012-01-01 00:00:00.000&lt;br /&gt;&lt;br /&gt;SELECT DATEADD(yy, DATEDIFF(yy,0,CURRENT_TIMESTAMP), 0)&lt;br /&gt;&lt;br /&gt;– SQL last day of year  &lt;br /&gt;&lt;br /&gt;– SQL last day of the year   – 2012-12-31 00:00:00.000&lt;br /&gt;&lt;br /&gt;SELECT DATEADD(yy,1, DATEADD(dd, -1, DATEADD(yy,&lt;br /&gt;&lt;br /&gt;                     DATEDIFF(yy,0,CURRENT_TIMESTAMP), 0)))&lt;br /&gt;&lt;br /&gt;– SQL last day of last year&lt;br /&gt;&lt;br /&gt;– SQL last day of previous year   – 2011-12-31 00:00:00.000&lt;br /&gt;&lt;br /&gt;SELECT DATEADD(dd,-1,DATEADD(yy,DATEDIFF(yy,0,CURRENT_TIMESTAMP), 0))&lt;br /&gt;&lt;br /&gt;GO&lt;br /&gt;&lt;br /&gt;– SQL calculate age in years, months, days&lt;br /&gt;&lt;br /&gt;– SQL table-valued function&lt;br /&gt;&lt;br /&gt;– SQL user-defined function – UDF&lt;br /&gt;&lt;br /&gt;– SQL Server age calculation – date difference&lt;br /&gt;&lt;br /&gt;– Format dates SQL Server 2008&lt;br /&gt;&lt;br /&gt;USE AdventureWorks2008;&lt;br /&gt;&lt;br /&gt;GO&lt;br /&gt;&lt;br /&gt;CREATE FUNCTION fnAge  (@BirthDate DATETIME)&lt;br /&gt;&lt;br /&gt;RETURNS @Age TABLE(Years  INT,&lt;br /&gt;&lt;br /&gt;                   Months INT,&lt;br /&gt;&lt;br /&gt;                   Days   INT)&lt;br /&gt;&lt;br /&gt;AS&lt;br /&gt;&lt;br /&gt;  BEGIN&lt;br /&gt;&lt;br /&gt;    DECLARE  @EndDate     DATETIME, @Anniversary DATETIME&lt;br /&gt;&lt;br /&gt;    SET @EndDate = Getdate()&lt;br /&gt;&lt;br /&gt;    SET @Anniversary = Dateadd(yy,Datediff(yy,@BirthDate,@EndDate),@BirthDate)&lt;br /&gt;&lt;br /&gt;    &lt;br /&gt;&lt;br /&gt;    INSERT @Age&lt;br /&gt;&lt;br /&gt;    SELECT Datediff(yy,@BirthDate,@EndDate) - (CASE&lt;br /&gt;&lt;br /&gt;                                                 WHEN @Anniversary &gt; @EndDate THEN 1&lt;br /&gt;&lt;br /&gt;                                                 ELSE 0&lt;br /&gt;&lt;br /&gt;                                               END), 0, 0&lt;br /&gt;&lt;br /&gt;     UPDATE @Age     SET    Months = Month(@EndDate - @Anniversary) - 1&lt;br /&gt;&lt;br /&gt;    UPDATE @Age     SET    Days = Day(@EndDate - @Anniversary) - 1&lt;br /&gt;&lt;br /&gt;    RETURN&lt;br /&gt;&lt;br /&gt;  END&lt;br /&gt;&lt;br /&gt;GO&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;– Test table-valued UDF&lt;br /&gt;&lt;br /&gt;SELECT * FROM   fnAge(‘1956-10-23′)&lt;br /&gt;&lt;br /&gt;SELECT * FROM   dbo.fnAge(‘1956-10-23′)&lt;br /&gt;&lt;br /&gt;/* Results&lt;br /&gt;&lt;br /&gt;Years       Months      Days&lt;br /&gt;&lt;br /&gt;52          4           1&lt;br /&gt;&lt;br /&gt;*/&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;———-&lt;br /&gt;&lt;br /&gt;– SQL date range between&lt;br /&gt;&lt;br /&gt;———-&lt;br /&gt;&lt;br /&gt;– SQL between dates&lt;br /&gt;&lt;br /&gt;USE AdventureWorks;&lt;br /&gt;&lt;br /&gt;– SQL between&lt;br /&gt;&lt;br /&gt;SELECT POs=COUNT(*) FROM Purchasing.PurchaseOrderHeader&lt;br /&gt;&lt;br /&gt;WHERE OrderDate BETWEEN ‘20040301′ AND ‘20040315′&lt;br /&gt;&lt;br /&gt;– Result: 108&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;– BETWEEN operator is equivalent to &gt;=…AND….&lt;=&lt;br /&gt;&lt;br /&gt;SELECT POs=COUNT(*) FROM Purchasing.PurchaseOrderHeader&lt;br /&gt;&lt;br /&gt;WHERE OrderDate&lt;br /&gt;&lt;br /&gt;BETWEEN ‘2004-03-01 00:00:00.000′ AND ‘2004-03-15  00:00:00.000′&lt;br /&gt;&lt;br /&gt;/*&lt;br /&gt;&lt;br /&gt;Orders with OrderDates&lt;br /&gt;&lt;br /&gt;‘2004-03-15  00:00:01.000′  – 1 second after midnight (12:00AM)&lt;br /&gt;&lt;br /&gt;‘2004-03-15  00:01:00.000′  – 1 minute after midnight&lt;br /&gt;&lt;br /&gt;‘2004-03-15  01:00:00.000′  – 1 hour after midnight&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;are not included in the two queries above.&lt;br /&gt;&lt;br /&gt;*/&lt;br /&gt;&lt;br /&gt;– To include the entire day of 2004-03-15 use the following two solutions&lt;br /&gt;&lt;br /&gt;SELECT POs=COUNT(*) FROM Purchasing.PurchaseOrderHeader&lt;br /&gt;&lt;br /&gt;WHERE OrderDate &gt;= ‘20040301′ AND OrderDate &lt; ‘20040316′&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;– SQL between with DATE type (SQL Server 2008)&lt;br /&gt;&lt;br /&gt;SELECT POs=COUNT(*) FROM Purchasing.PurchaseOrderHeader&lt;br /&gt;&lt;br /&gt;WHERE CONVERT(DATE, OrderDate) BETWEEN ‘20040301′ AND ‘20040315′&lt;br /&gt;&lt;br /&gt;———-&lt;br /&gt;&lt;br /&gt;– Non-standard format conversion: 2011 December 14&lt;br /&gt;&lt;br /&gt;– SQL datetime to string&lt;br /&gt;&lt;br /&gt;SELECT [YYYY Month DD] =&lt;br /&gt;&lt;br /&gt;CAST(YEAR(GETDATE()) AS VARCHAR(4))+ ‘ ‘+&lt;br /&gt;&lt;br /&gt;DATENAME(MM, GETDATE()) + ‘ ‘ +&lt;br /&gt;&lt;br /&gt;CAST(DAY(GETDATE()) AS VARCHAR(2))&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;– Converting datetime to YYYYMMDDHHMMSS format: 20121214172638&lt;br /&gt;&lt;br /&gt;SELECT replace(convert(varchar, getdate(),111),‘/’,”) +&lt;br /&gt;&lt;br /&gt;replace(convert(varchar, getdate(),108),‘:’,”)&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;– Datetime custom format conversion to YYYY_MM_DD&lt;br /&gt;&lt;br /&gt;select CurrentDate=rtrim(year(getdate())) + ‘_’ +&lt;br /&gt;&lt;br /&gt;right(‘0′ + rtrim(month(getdate())),2) + ‘_’ +&lt;br /&gt;&lt;br /&gt;right(‘0′ + rtrim(day(getdate())),2)&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;– Converting seconds to HH:MM:SS format&lt;br /&gt;&lt;br /&gt;declare @Seconds int&lt;br /&gt;&lt;br /&gt;set @Seconds = 10000&lt;br /&gt;&lt;br /&gt;select TimeSpan=right(‘0′ +rtrim(@Seconds / 3600),2) + ‘:’ +&lt;br /&gt;&lt;br /&gt;right(‘0′ + rtrim((@Seconds % 3600) / 60),2) + ‘:’ +&lt;br /&gt;&lt;br /&gt;right(‘0′ + rtrim(@Seconds % 60),2)&lt;br /&gt;&lt;br /&gt;– Result: 02:46:40&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;– Test result&lt;br /&gt;&lt;br /&gt;select 2*3600 + 46*60 + 40&lt;br /&gt;&lt;br /&gt;– Result: 10000&lt;br /&gt;&lt;br /&gt;– Set the time portion of a datetime value to 00:00:00.000&lt;br /&gt;&lt;br /&gt;– SQL strip time from date&lt;br /&gt;&lt;br /&gt;– SQL strip time from datetime&lt;br /&gt;&lt;br /&gt;SELECT CURRENT_TIMESTAMP ,DATEADD(dd, DATEDIFF(dd, 0, CURRENT_TIMESTAMP), 0)&lt;br /&gt;&lt;br /&gt;– Results: 2014-01-23 05:35:52.793 2014-01-23 00:00:00.000&lt;br /&gt;&lt;br /&gt;/*******&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;VALID DATE RANGES FOR DATE/DATETIME DATA TYPES&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;SMALLDATETIME date range:&lt;br /&gt;&lt;br /&gt;January 1, 1900 through June 6, 2079&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;DATETIME date range:&lt;br /&gt;&lt;br /&gt;January 1, 1753 through December 31, 9999&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;DATETIME2 date range (SQL Server 2008):&lt;br /&gt;&lt;br /&gt;January 1,1 AD through December 31, 9999 AD&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;DATE date range (SQL Server 2008):&lt;br /&gt;&lt;br /&gt;January 1, 1 AD through December 31, 9999 AD&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;*******/&lt;br /&gt;&lt;br /&gt;– Selecting with CONVERT into different styles&lt;br /&gt;&lt;br /&gt;– Note: Only Japan &amp; ISO styles can be used in ORDER BY&lt;br /&gt;&lt;br /&gt;SELECT TOP(1)&lt;br /&gt;&lt;br /&gt;     Italy  = CONVERT(varchar, OrderDate, 105)&lt;br /&gt;&lt;br /&gt;   , USA    = CONVERT(varchar, OrderDate, 110)&lt;br /&gt;&lt;br /&gt;   , Japan  = CONVERT(varchar, OrderDate, 111)&lt;br /&gt;&lt;br /&gt;   , ISO    = CONVERT(varchar, OrderDate, 112)&lt;br /&gt;&lt;br /&gt;FROM AdventureWorks.Purchasing.PurchaseOrderHeader&lt;br /&gt;&lt;br /&gt;ORDER BY PurchaseOrderID DESC&lt;br /&gt;&lt;br /&gt;/* Results&lt;br /&gt;&lt;br /&gt;Italy       USA         Japan       ISO&lt;br /&gt;&lt;br /&gt;25-07-2004  07-25-2004  2004/07/25  20040725&lt;br /&gt;&lt;br /&gt;*/&lt;br /&gt;&lt;br /&gt;– SQL Server convert date to integer&lt;br /&gt;&lt;br /&gt;DECLARE @Datetime datetime&lt;br /&gt;&lt;br /&gt;SET @Datetime = ‘2012-10-23 10:21:05.345′&lt;br /&gt;&lt;br /&gt;SELECT DateAsInteger = CAST (CONVERT(varchar,@Datetime,112) as INT)&lt;br /&gt;&lt;br /&gt;– Result: 20121023&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;– SQL Server convert integer to datetime&lt;br /&gt;&lt;br /&gt;DECLARE @intDate int&lt;br /&gt;&lt;br /&gt;SET @intDate = 20120315&lt;br /&gt;&lt;br /&gt;SELECT IntegerToDatetime = CAST(CAST(@intDate as varchar) as datetime)&lt;br /&gt;&lt;br /&gt;– Result: 2012-03-15 00:00:00.000&lt;br /&gt;&lt;br /&gt;————&lt;br /&gt;&lt;br /&gt;– SQL Server CONVERT script applying table INSERT/UPDATE&lt;br /&gt;&lt;br /&gt;————&lt;br /&gt;&lt;br /&gt;– SQL Server convert date&lt;br /&gt;&lt;br /&gt;– Datetime column is converted into date only string column&lt;br /&gt;&lt;br /&gt;USE tempdb;&lt;br /&gt;&lt;br /&gt;GO&lt;br /&gt;&lt;br /&gt;CREATE TABLE sqlConvertDateTime   (&lt;br /&gt;&lt;br /&gt;            DatetimeCol datetime,&lt;br /&gt;&lt;br /&gt;            DateCol char(8));&lt;br /&gt;&lt;br /&gt;INSERT sqlConvertDateTime (DatetimeCol) SELECT GETDATE()&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;UPDATE sqlConvertDateTime&lt;br /&gt;&lt;br /&gt;SET DateCol = CONVERT(char(10), DatetimeCol, 112)&lt;br /&gt;&lt;br /&gt;SELECT * FROM sqlConvertDateTime&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;– SQL Server convert datetime&lt;br /&gt;&lt;br /&gt;– The string date column is converted into datetime column&lt;br /&gt;&lt;br /&gt;UPDATE sqlConvertDateTime&lt;br /&gt;&lt;br /&gt;SET DatetimeCol = CONVERT(Datetime, DateCol, 112)&lt;br /&gt;&lt;br /&gt;SELECT * FROM sqlConvertDateTime&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;– Adding a day to the converted datetime column with DATEADD&lt;br /&gt;&lt;br /&gt;UPDATE sqlConvertDateTime&lt;br /&gt;&lt;br /&gt;SET DatetimeCol = DATEADD(day, 1, CONVERT(Datetime, DateCol, 112))&lt;br /&gt;&lt;br /&gt;SELECT * FROM sqlConvertDateTime&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;– Equivalent formulation&lt;br /&gt;&lt;br /&gt;– SQL Server cast datetime&lt;br /&gt;&lt;br /&gt;UPDATE sqlConvertDateTime&lt;br /&gt;&lt;br /&gt;SET DatetimeCol = DATEADD(dd, 1, CAST(DateCol AS datetime))&lt;br /&gt;&lt;br /&gt;SELECT * FROM sqlConvertDateTime&lt;br /&gt;&lt;br /&gt;GO&lt;br /&gt;&lt;br /&gt;DROP TABLE sqlConvertDateTime&lt;br /&gt;&lt;br /&gt;GO&lt;br /&gt;&lt;br /&gt;/* First results&lt;br /&gt;&lt;br /&gt;DatetimeCol                   DateCol&lt;br /&gt;&lt;br /&gt;2014-12-25 16:04:15.373       20141225 */&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;/* Second results:&lt;br /&gt;&lt;br /&gt;DatetimeCol                   DateCol&lt;br /&gt;&lt;br /&gt;2014-12-25 00:00:00.000       20141225  */&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;/* Third results:&lt;br /&gt;&lt;br /&gt;DatetimeCol                   DateCol&lt;br /&gt;&lt;br /&gt;2014-12-26 00:00:00.000       20141225  */&lt;br /&gt;&lt;br /&gt;————&lt;br /&gt;&lt;br /&gt;– SQL month sequence – SQL date sequence generation with table variable&lt;br /&gt;&lt;br /&gt;– SQL Server cast string to datetime – SQL Server cast datetime to string&lt;br /&gt;&lt;br /&gt;– SQL Server insert default values method&lt;br /&gt;&lt;br /&gt;DECLARE @Sequence table (Sequence int identity(1,1))&lt;br /&gt;&lt;br /&gt;DECLARE @i int; SET @i = 0&lt;br /&gt;&lt;br /&gt;DECLARE @StartDate datetime;&lt;br /&gt;&lt;br /&gt;SET @StartDate = CAST(CONVERT(varchar, year(getdate()))+&lt;br /&gt;&lt;br /&gt;                 RIGHT(‘0′+convert(varchar,month(getdate())),2) + ‘01′ AS DATETIME)&lt;br /&gt;&lt;br /&gt;WHILE ( @i &lt; 120)&lt;br /&gt;&lt;br /&gt;BEGIN&lt;br /&gt;&lt;br /&gt;      INSERT @Sequence DEFAULT VALUES&lt;br /&gt;&lt;br /&gt;      SET @i = @i + 1&lt;br /&gt;&lt;br /&gt;END&lt;br /&gt;&lt;br /&gt;SELECT MonthSequence = CAST(DATEADD(month, Sequence,@StartDate) AS varchar)&lt;br /&gt;&lt;br /&gt;FROM @Sequence&lt;br /&gt;&lt;br /&gt;GO&lt;br /&gt;&lt;br /&gt;/* Partial results:&lt;br /&gt;&lt;br /&gt;MonthSequence&lt;br /&gt;&lt;br /&gt;Jan  1 2012 12:00AM&lt;br /&gt;&lt;br /&gt;Feb  1 2012 12:00AM&lt;br /&gt;&lt;br /&gt;Mar  1 2012 12:00AM&lt;br /&gt;&lt;br /&gt;Apr  1 2012 12:00AM&lt;br /&gt;&lt;br /&gt;*/&lt;br /&gt;&lt;br /&gt;————&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;————&lt;br /&gt;&lt;br /&gt;– SQL Server Server datetime internal storage&lt;br /&gt;&lt;br /&gt;– SQL Server datetime formats&lt;br /&gt;&lt;br /&gt;————&lt;br /&gt;&lt;br /&gt;– SQL Server datetime to hex&lt;br /&gt;&lt;br /&gt;SELECT Now=CURRENT_TIMESTAMP, HexNow=CAST(CURRENT_TIMESTAMP AS BINARY(8))&lt;br /&gt;&lt;br /&gt;/* Results&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;Now                     HexNow&lt;br /&gt;&lt;br /&gt;2009-01-02 17:35:59.297 0×00009B850122092D&lt;br /&gt;&lt;br /&gt;*/&lt;br /&gt;&lt;br /&gt;– SQL Server date part – left 4 bytes – Days since 1900-01-01&lt;br /&gt;&lt;br /&gt;SELECT Now=DATEADD(DAY, CONVERT(INT, 0×00009B85), ‘19000101′)&lt;br /&gt;&lt;br /&gt;GO&lt;br /&gt;&lt;br /&gt;– Result: 2009-01-02 00:00:00.000&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;– SQL time part – right 4 bytes – milliseconds since midnight&lt;br /&gt;&lt;br /&gt;– 1000/300 is an adjustment factor&lt;br /&gt;&lt;br /&gt;– SQL dateadd to Midnight&lt;br /&gt;&lt;br /&gt;SELECT Now=DATEADD(MS, (1000.0/300)* CONVERT(BIGINT, 0×0122092D), ‘2009-01-02′)&lt;br /&gt;&lt;br /&gt;GO&lt;br /&gt;&lt;br /&gt;– Result: 2009-01-02 17:35:59.290&lt;br /&gt;&lt;br /&gt;————&lt;br /&gt;&lt;br /&gt;————&lt;br /&gt;&lt;br /&gt;– String date and datetime date&amp;time columns usage&lt;br /&gt;&lt;br /&gt;– SQL Server datetime formats in tables&lt;br /&gt;&lt;br /&gt;————&lt;br /&gt;&lt;br /&gt;USE tempdb;&lt;br /&gt;&lt;br /&gt;SET NOCOUNT ON;&lt;br /&gt;&lt;br /&gt;– SQL Server select into table create&lt;br /&gt;&lt;br /&gt;SELECT TOP (5)&lt;br /&gt;&lt;br /&gt;      FullName=convert(nvarchar(50),FirstName+‘ ‘+LastName),&lt;br /&gt;&lt;br /&gt;      BirthDate = CONVERT(char(8), BirthDate,112),&lt;br /&gt;&lt;br /&gt;      ModifiedDate = getdate()&lt;br /&gt;&lt;br /&gt;INTO Employee&lt;br /&gt;&lt;br /&gt;FROM AdventureWorks.HumanResources.Employee e&lt;br /&gt;&lt;br /&gt;INNER JOIN AdventureWorks.Person.Contact c&lt;br /&gt;&lt;br /&gt;ON c.ContactID = e.ContactID&lt;br /&gt;&lt;br /&gt;ORDER BY EmployeeID&lt;br /&gt;&lt;br /&gt;GO&lt;br /&gt;&lt;br /&gt;– SQL Server alter table&lt;br /&gt;&lt;br /&gt;ALTER TABLE Employee ALTER COLUMN FullName nvarchar(50) NOT NULL&lt;br /&gt;&lt;br /&gt;GO&lt;br /&gt;&lt;br /&gt;ALTER TABLE Employee&lt;br /&gt;&lt;br /&gt;ADD CONSTRAINT [PK_Employee] PRIMARY KEY (FullName )&lt;br /&gt;&lt;br /&gt;GO&lt;br /&gt;&lt;br /&gt;/* Results&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;Table definition for the Employee table&lt;br /&gt;&lt;br /&gt;Note: BirthDate is string date (only)&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;CREATE TABLE dbo.Employee(&lt;br /&gt;&lt;br /&gt;      FullName nvarchar(50) NOT NULL PRIMARY KEY,&lt;br /&gt;&lt;br /&gt;      BirthDate char(8) NULL,&lt;br /&gt;&lt;br /&gt;      ModifiedDate datetime NOT NULL&lt;br /&gt;&lt;br /&gt;      )&lt;br /&gt;&lt;br /&gt;*/&lt;br /&gt;&lt;br /&gt;SELECT * FROM Employee ORDER BY FullName&lt;br /&gt;&lt;br /&gt;GO&lt;br /&gt;&lt;br /&gt;/* Results&lt;br /&gt;&lt;br /&gt;FullName                BirthDate   ModifiedDate&lt;br /&gt;&lt;br /&gt;Guy Gilbert             19720515    2009-01-03 10:10:19.217&lt;br /&gt;&lt;br /&gt;Kevin Brown             19770603    2009-01-03 10:10:19.217&lt;br /&gt;&lt;br /&gt;Rob Walters             19650123    2009-01-03 10:10:19.217&lt;br /&gt;&lt;br /&gt;Roberto Tamburello      19641213    2009-01-03 10:10:19.217&lt;br /&gt;&lt;br /&gt;Thierry D’Hers          19490829    2009-01-03 10:10:19.217&lt;br /&gt;&lt;br /&gt;*/&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;– SQL Server age&lt;br /&gt;&lt;br /&gt;SELECT FullName, Age = DATEDIFF(YEAR, BirthDate, GETDATE()),&lt;br /&gt;&lt;br /&gt;       RowMaintenanceDate = CAST (ModifiedDate AS varchar)&lt;br /&gt;&lt;br /&gt;FROM Employee ORDER BY FullName&lt;br /&gt;&lt;br /&gt;GO&lt;br /&gt;&lt;br /&gt;/* Results&lt;br /&gt;&lt;br /&gt;FullName                Age   RowMaintenanceDate&lt;br /&gt;&lt;br /&gt;Guy Gilbert             37    Jan  3 2009 10:10AM&lt;br /&gt;&lt;br /&gt;Kevin Brown             32    Jan  3 2009 10:10AM&lt;br /&gt;&lt;br /&gt;Rob Walters             44    Jan  3 2009 10:10AM&lt;br /&gt;&lt;br /&gt;Roberto Tamburello      45    Jan  3 2009 10:10AM&lt;br /&gt;&lt;br /&gt;Thierry D’Hers          60    Jan  3 2009 10:10AM&lt;br /&gt;&lt;br /&gt;*/&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;– SQL Server age of Rob Walters on specific dates&lt;br /&gt;&lt;br /&gt;– SQL Server string to datetime implicit conversion with DATEADD&lt;br /&gt;&lt;br /&gt;SELECT AGE50DATE = DATEADD(YY, 50, ‘19650123′)&lt;br /&gt;&lt;br /&gt;GO&lt;br /&gt;&lt;br /&gt;– Result: 2015-01-23 00:00:00.000&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;– SQL Server datetime to string, Italian format for ModifiedDate&lt;br /&gt;&lt;br /&gt;– SQL Server string to datetime implicit conversion with DATEDIFF&lt;br /&gt;&lt;br /&gt;SELECT FullName,&lt;br /&gt;&lt;br /&gt;         AgeDEC31 = DATEDIFF(YEAR, BirthDate, ‘20141231′),&lt;br /&gt;&lt;br /&gt;         AgeJAN01 = DATEDIFF(YEAR, BirthDate, ‘20150101′),&lt;br /&gt;&lt;br /&gt;         AgeJAN23 = DATEDIFF(YEAR, BirthDate, ‘20150123′),&lt;br /&gt;&lt;br /&gt;         AgeJAN24 = DATEDIFF(YEAR, BirthDate, ‘20150124′),&lt;br /&gt;&lt;br /&gt;       ModDate = CONVERT(varchar, ModifiedDate, 105)&lt;br /&gt;&lt;br /&gt;FROM Employee&lt;br /&gt;&lt;br /&gt;WHERE FullName = ‘Rob Walters’&lt;br /&gt;&lt;br /&gt;ORDER BY FullName&lt;br /&gt;&lt;br /&gt;GO&lt;br /&gt;&lt;br /&gt;/* Results&lt;br /&gt;&lt;br /&gt;Important Note: age increments on Jan 1 (not as commonly calculated)&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;FullName    AgeDEC31    AgeJAN01    AgeJAN23    AgeJAN24    ModDate&lt;br /&gt;&lt;br /&gt;Rob Walters 49          50          50          50          03-01-2009&lt;br /&gt;&lt;br /&gt;*/&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;————&lt;br /&gt;&lt;br /&gt;– SQL combine integer date &amp; time into datetime&lt;br /&gt;&lt;br /&gt;————&lt;br /&gt;&lt;br /&gt;– Datetime format sql&lt;br /&gt;&lt;br /&gt;– SQL stuff&lt;br /&gt;&lt;br /&gt;DECLARE @DateTimeAsINT TABLE ( ID int identity(1,1) primary key, &lt;br /&gt;&lt;br /&gt;   DateAsINT int, &lt;br /&gt;&lt;br /&gt;   TimeAsINT int &lt;br /&gt;&lt;br /&gt;) &lt;br /&gt;&lt;br /&gt;– NOTE: leading zeroes in time is for readability only!  &lt;br /&gt;&lt;br /&gt;INSERT @DateTimeAsINT (DateAsINT, TimeAsINT) VALUES (20121023, 235959)  &lt;br /&gt;&lt;br /&gt;INSERT @DateTimeAsINT (DateAsINT, TimeAsINT) VALUES (20121023, 010204)  &lt;br /&gt;&lt;br /&gt;INSERT @DateTimeAsINT (DateAsINT, TimeAsINT) VALUES (20121023, 002350)&lt;br /&gt;&lt;br /&gt;INSERT @DateTimeAsINT (DateAsINT, TimeAsINT) VALUES (20121023, 000244)  &lt;br /&gt;&lt;br /&gt;INSERT @DateTimeAsINT (DateAsINT, TimeAsINT) VALUES (20121023, 000050)  &lt;br /&gt;&lt;br /&gt;INSERT @DateTimeAsINT (DateAsINT, TimeAsINT) VALUES (20121023, 000006)  &lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;SELECT DateAsINT, TimeAsINT,&lt;br /&gt;&lt;br /&gt;  CONVERT(datetime, CONVERT(varchar(8), DateAsINT) + ‘ ‘+&lt;br /&gt;&lt;br /&gt;  STUFF(STUFF ( RIGHT(REPLICATE(‘0′, 6) + CONVERT(varchar(6), TimeAsINT), 6),&lt;br /&gt;&lt;br /&gt;                  3, 0, ‘:’), 6, 0, ‘:’))  AS DateTimeValue&lt;br /&gt;&lt;br /&gt;FROM   @DateTimeAsINT &lt;br /&gt;&lt;br /&gt;ORDER BY ID&lt;br /&gt;&lt;br /&gt;GO&lt;br /&gt;&lt;br /&gt;/* Results&lt;br /&gt;&lt;br /&gt;DateAsINT   TimeAsINT   DateTimeValue&lt;br /&gt;&lt;br /&gt;20121023    235959      2012-10-23 23:59:59.000&lt;br /&gt;&lt;br /&gt;20121023    10204       2012-10-23 01:02:04.000&lt;br /&gt;&lt;br /&gt;20121023    2350        2012-10-23 00:23:50.000&lt;br /&gt;&lt;br /&gt;20121023    244         2012-10-23 00:02:44.000&lt;br /&gt;&lt;br /&gt;20121023    50          2012-10-23 00:00:50.000&lt;br /&gt;&lt;br /&gt;20121023    6           2012-10-23 00:00:06.000&lt;br /&gt;&lt;br /&gt;*/&lt;br /&gt;&lt;br /&gt;————&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;– SQL Server string to datetime, implicit conversion with assignment&lt;br /&gt;&lt;br /&gt;UPDATE Employee SET ModifiedDate = ‘20150123′&lt;br /&gt;&lt;br /&gt;WHERE FullName = ‘Rob Walters’&lt;br /&gt;&lt;br /&gt;GO&lt;br /&gt;&lt;br /&gt;SELECT ModifiedDate FROM Employee WHERE FullName = ‘Rob Walters’&lt;br /&gt;&lt;br /&gt;GO&lt;br /&gt;&lt;br /&gt;– Result: 2015-01-23 00:00:00.000&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;/* SQL string date, assemble string date from datetime parts  */&lt;br /&gt;&lt;br /&gt;– SQL Server cast string to datetime – sql convert string date&lt;br /&gt;&lt;br /&gt;– SQL Server number to varchar conversion&lt;br /&gt;&lt;br /&gt;– SQL Server leading zeroes for month and day&lt;br /&gt;&lt;br /&gt;– SQL Server right string function&lt;br /&gt;&lt;br /&gt;UPDATE Employee SET BirthDate =&lt;br /&gt;&lt;br /&gt;      CONVERT(char(4),YEAR(CAST(‘1965-01-23′ as DATETIME)))+&lt;br /&gt;&lt;br /&gt;      RIGHT(‘0′+CONVERT(varchar,MONTH(CAST(‘1965-01-23′ as DATETIME))),2)+&lt;br /&gt;&lt;br /&gt;      RIGHT(‘0′+CONVERT(varchar,DAY(CAST(‘1965-01-23′ as DATETIME))),2)&lt;br /&gt;&lt;br /&gt;      WHERE FullName = ‘Rob Walters’&lt;br /&gt;&lt;br /&gt;GO&lt;br /&gt;&lt;br /&gt;SELECT BirthDate FROM Employee WHERE FullName = ‘Rob Walters’&lt;br /&gt;&lt;br /&gt;GO&lt;br /&gt;&lt;br /&gt;– Result: 19650123&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;– Perform cleanup action&lt;br /&gt;&lt;br /&gt;DROP TABLE Employee&lt;br /&gt;&lt;br /&gt;– SQL nocount&lt;br /&gt;&lt;br /&gt;SET NOCOUNT OFF;&lt;br /&gt;&lt;br /&gt;GO&lt;br /&gt;&lt;br /&gt;————&lt;br /&gt;&lt;br /&gt;————&lt;br /&gt;&lt;br /&gt;– sql isdate function&lt;br /&gt;&lt;br /&gt;————&lt;br /&gt;&lt;br /&gt;USE tempdb;&lt;br /&gt;&lt;br /&gt;– sql newid – random sort&lt;br /&gt;&lt;br /&gt;SELECT top(3) SalesOrderID,&lt;br /&gt;&lt;br /&gt;stringOrderDate = CAST (OrderDate AS varchar)&lt;br /&gt;&lt;br /&gt;INTO DateValidation&lt;br /&gt;&lt;br /&gt;FROM AdventureWorks.Sales.SalesOrderHeader&lt;br /&gt;&lt;br /&gt;ORDER BY NEWID()&lt;br /&gt;&lt;br /&gt;GO&lt;br /&gt;&lt;br /&gt;SELECT * FROM DateValidation&lt;br /&gt;&lt;br /&gt;/* Results&lt;br /&gt;&lt;br /&gt;SalesOrderID      stringOrderDate&lt;br /&gt;&lt;br /&gt;56720             Oct 26 2003 12:00AM&lt;br /&gt;&lt;br /&gt;73737             Jun 25 2004 12:00AM&lt;br /&gt;&lt;br /&gt;70573             May 14 2004 12:00AM&lt;br /&gt;&lt;br /&gt;*/&lt;br /&gt;&lt;br /&gt;– SQL update with top&lt;br /&gt;&lt;br /&gt;UPDATE TOP(1) DateValidation&lt;br /&gt;&lt;br /&gt;SET stringOrderDate = ‘Apb 29 2004 12:00AM’&lt;br /&gt;&lt;br /&gt;GO&lt;br /&gt;&lt;br /&gt;– SQL string to datetime fails without validation&lt;br /&gt;&lt;br /&gt;SELECT SalesOrderID, OrderDate = CAST (stringOrderDate as datetime)&lt;br /&gt;&lt;br /&gt;FROM DateValidation&lt;br /&gt;&lt;br /&gt;GO&lt;br /&gt;&lt;br /&gt;/* Msg 242, Level 16, State 3, Line 1&lt;br /&gt;&lt;br /&gt;The conversion of a varchar data type to a datetime data type resulted in an&lt;br /&gt;&lt;br /&gt;out-of-range value.&lt;br /&gt;&lt;br /&gt;*/&lt;br /&gt;&lt;br /&gt;– sql isdate – filter for valid dates&lt;br /&gt;&lt;br /&gt;SELECT SalesOrderID, OrderDate = CAST (stringOrderDate as datetime)&lt;br /&gt;&lt;br /&gt;FROM DateValidation&lt;br /&gt;&lt;br /&gt;WHERE ISDATE(stringOrderDate) = 1&lt;br /&gt;&lt;br /&gt;GO&lt;br /&gt;&lt;br /&gt;/* Results&lt;br /&gt;&lt;br /&gt;SalesOrderID      OrderDate&lt;br /&gt;&lt;br /&gt;73737             2004-06-25 00:00:00.000&lt;br /&gt;&lt;br /&gt;70573             2004-05-14 00:00:00.000&lt;br /&gt;&lt;br /&gt;*/&lt;br /&gt;&lt;br /&gt;– SQL drop table&lt;br /&gt;&lt;br /&gt;DROP TABLE DateValidation&lt;br /&gt;&lt;br /&gt;Go&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;————&lt;br /&gt;&lt;br /&gt;– SELECT between two specified dates – assumption TIME part is 00:00:00.000&lt;br /&gt;&lt;br /&gt;————&lt;br /&gt;&lt;br /&gt;– SQL datetime between&lt;br /&gt;&lt;br /&gt;– SQL select between two dates&lt;br /&gt;&lt;br /&gt;SELECT EmployeeID, RateChangeDate&lt;br /&gt;&lt;br /&gt;FROM AdventureWorks.HumanResources.EmployeePayHistory&lt;br /&gt;&lt;br /&gt;WHERE RateChangeDate &gt;= ‘1997-11-01′ AND &lt;br /&gt;&lt;br /&gt;      RateChangeDate &lt; DATEADD(dd,1,‘1998-01-05′)&lt;br /&gt;&lt;br /&gt;GO&lt;br /&gt;&lt;br /&gt;/* Results&lt;br /&gt;&lt;br /&gt;EmployeeID  RateChangeDate&lt;br /&gt;&lt;br /&gt;3           1997-12-12 00:00:00.000&lt;br /&gt;&lt;br /&gt;4           1998-01-05 00:00:00.000&lt;br /&gt;&lt;br /&gt;*/&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;/* Equivalent to&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;– SQL datetime range&lt;br /&gt;&lt;br /&gt;SELECT EmployeeID, RateChangeDate&lt;br /&gt;&lt;br /&gt;FROM AdventureWorks.HumanResources.EmployeePayHistory&lt;br /&gt;&lt;br /&gt;WHERE RateChangeDate &gt;= ‘1997-11-01 00:00:00′ AND &lt;br /&gt;&lt;br /&gt;      RateChangeDate &lt;  ‘1998-01-06 00:00:00′&lt;br /&gt;&lt;br /&gt;GO&lt;br /&gt;&lt;br /&gt;*/&lt;br /&gt;&lt;br /&gt;————&lt;br /&gt;&lt;br /&gt;– SQL datetime language setting&lt;br /&gt;&lt;br /&gt;– SQL Nondeterministic function usage – result varies with language settings&lt;br /&gt;&lt;br /&gt;SET LANGUAGE  ‘us_english’;  –– Jan 12 2015 12:00AM &lt;br /&gt;&lt;br /&gt;SELECT US = convert(VARCHAR,convert(DATETIME,‘01/12/2015′));&lt;br /&gt;&lt;br /&gt;SET LANGUAGE  ‘British’;     –– Dec  1 2015 12:00AM &lt;br /&gt;&lt;br /&gt;SELECT UK = convert(VARCHAR,convert(DATETIME,‘01/12/2015′));&lt;br /&gt;&lt;br /&gt;SET LANGUAGE  ‘German’;      –– Dez  1 2015 12:00AM &lt;br /&gt;&lt;br /&gt;SET LANGUAGE  ‘Deutsch’;     –– Dez  1 2015 12:00AM &lt;br /&gt;&lt;br /&gt;SELECT Germany = convert(VARCHAR,convert(DATETIME,‘01/12/2015′));&lt;br /&gt;&lt;br /&gt;SET LANGUAGE  ‘French’;      –– déc  1 2015 12:00AM &lt;br /&gt;&lt;br /&gt;SELECT France = convert(VARCHAR,convert(DATETIME,‘01/12/2015′));&lt;br /&gt;&lt;br /&gt;SET LANGUAGE  ‘Spanish’;     –– Dic  1 2015 12:00AM &lt;br /&gt;&lt;br /&gt;SELECT Spain = convert(VARCHAR,convert(DATETIME,‘01/12/2015′));&lt;br /&gt;&lt;br /&gt;SET LANGUAGE  ‘Hungarian’;   –– jan 12 2015 12:00AM &lt;br /&gt;&lt;br /&gt;SELECT Hungary = convert(VARCHAR,convert(DATETIME,‘01/12/2015′));&lt;br /&gt;&lt;br /&gt;SET LANGUAGE  ‘us_english’;&lt;br /&gt;&lt;br /&gt;GO&lt;br /&gt;&lt;br /&gt;————&lt;br /&gt;&lt;br /&gt;————&lt;br /&gt;&lt;br /&gt;– Function for Monday dates calculation&lt;br /&gt;&lt;br /&gt;————&lt;br /&gt;&lt;br /&gt;USE AdventureWorks2008;&lt;br /&gt;&lt;br /&gt;GO&lt;br /&gt;&lt;br /&gt;– SQL user-defined function&lt;br /&gt;&lt;br /&gt;– SQL scalar function – UDF&lt;br /&gt;&lt;br /&gt;CREATE FUNCTION fnMondayDate&lt;br /&gt;&lt;br /&gt;               (@Year          INT,&lt;br /&gt;&lt;br /&gt;                @Month         INT,&lt;br /&gt;&lt;br /&gt;                @MondayOrdinal INT)&lt;br /&gt;&lt;br /&gt;RETURNS DATETIME&lt;br /&gt;&lt;br /&gt;AS&lt;br /&gt;&lt;br /&gt;  BEGIN&lt;br /&gt;&lt;br /&gt;    DECLARE  @FirstDayOfMonth CHAR(10),&lt;br /&gt;&lt;br /&gt;             @SeedDate        CHAR(10)&lt;br /&gt;&lt;br /&gt;    &lt;br /&gt;&lt;br /&gt;    SET @FirstDayOfMonth = convert(VARCHAR,@Year) + ‘-’ + convert(VARCHAR,@Month) + ‘-01′&lt;br /&gt;&lt;br /&gt;    SET @SeedDate = ‘1900-01-01′&lt;br /&gt;&lt;br /&gt;    &lt;br /&gt;&lt;br /&gt;    RETURN DATEADD(DD,DATEDIFF(DD,@SeedDate,DATEADD(DD,(@MondayOrdinal * 7) - 1,&lt;br /&gt;&lt;br /&gt;                  @FirstDayOfMonth)) / 7 * 7,  @SeedDate)&lt;br /&gt;&lt;br /&gt;  END&lt;br /&gt;&lt;br /&gt;GO&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;– Test Datetime UDF&lt;br /&gt;&lt;br /&gt;– Third Monday in Feb, 2015&lt;br /&gt;&lt;br /&gt;SELECT dbo.fnMondayDate(2016,2,3)&lt;br /&gt;&lt;br /&gt;– 2015-02-16 00:00:00.000&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;– First Monday of current month&lt;br /&gt;&lt;br /&gt;SELECT dbo.fnMondayDate(Year(getdate()),Month(getdate()),1)&lt;br /&gt;&lt;br /&gt;– 2009-02-02 00:00:00.000  &lt;br /&gt;&lt;br /&gt;————&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7527040749709927669-6103287899255853572?l=jaan1762.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jaan1762.blogspot.com/feeds/6103287899255853572/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7527040749709927669&amp;postID=6103287899255853572' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/6103287899255853572'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/6103287899255853572'/><link rel='alternate' type='text/html' href='http://jaan1762.blogspot.com/2010/02/how-to-format-datetime-date-in-sql.html' title='How to format datetime &amp; date in Sql Server 2005'/><author><name>Mansoor</name><uri>http://www.blogger.com/profile/00473621254256960630</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-7527040749709927669.post-8489591702136038081</id><published>2009-11-08T23:33:00.000-08:00</published><updated>2009-11-09T00:25:58.398-08:00</updated><title type='text'>Gridview Footer Page</title><content type='html'>#region Namespaces&lt;br /&gt;using System;&lt;br /&gt;using System.Data;&lt;br /&gt;using System.Configuration;&lt;br /&gt;using System.Linq;&lt;br /&gt;using System.Web;&lt;br /&gt;using System.Web.Security;&lt;br /&gt;using System.Web.UI;&lt;br /&gt;using System.Web.UI.HtmlControls;&lt;br /&gt;using System.Web.UI.WebControls;&lt;br /&gt;using System.Web.UI.WebControls.WebParts;&lt;br /&gt;using System.Text;&lt;br /&gt;#endregion&lt;br /&gt;&lt;br /&gt;/// &amp;lt;summary&amp;rt;&lt;br /&gt;/// Summary description for GridViewPageFooter&lt;br /&gt;/// &amp;lt;/summary&amp;rt;&lt;br /&gt;public class GridViewPageFooter&lt;br /&gt;{&lt;br /&gt;    public GridViewPageFooter()&lt;br /&gt;    {&lt;br /&gt;        //&lt;br /&gt;        // TODO: Add constructor logic here&lt;br /&gt;        //&lt;br /&gt;    }&lt;br /&gt;    public static void GetGridViewPager(GridView gv, GridViewRow gvr)&lt;br /&gt;    {&lt;br /&gt;        if ((PlaceHolder)gvr.FindControl("phPager") == null)&lt;br /&gt;        {&lt;br /&gt;            throw new ApplicationException("A placeholder with an ID=\"phPager\" is required for this to work");&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        PlaceHolder ph = (PlaceHolder)gvr.FindControl("phPager");&lt;br /&gt;&lt;br /&gt;        // html markup and style&lt;br /&gt;        StringBuilder sb = new StringBuilder();&lt;br /&gt;        sb.Append("&amp;lt;div style=\"float:left;\"&amp;rt;");&lt;br /&gt;        sb.Append(string.Format("&amp;lt;span class=\"pagerCurrentPage\"&amp;rt;Page: {0} of {1}&amp;lt;/span&amp;rt;", (gv.PageIndex + 1).ToString(), gv.PageCount));&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        Literal lit = new Literal();&lt;br /&gt;        lit.Text = sb.ToString();&lt;br /&gt;        ph.Controls.Add(lit);&lt;br /&gt;&lt;br /&gt;        //adding the table &lt;br /&gt;        //StringBuilder sbTable = new StringBuilder();&lt;br /&gt;        //sbTable.Append("width=\"100\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\" align=\"left\"&amp;rt;");&lt;br /&gt;        //sbTable.Append("&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        // Previous page button&lt;br /&gt;        ImageButton btnImage = new ImageButton();&lt;br /&gt;        btnImage.ID = "btnPrevPage";&lt;br /&gt;        btnImage.CommandName = "Page";&lt;br /&gt;        btnImage.CommandArgument = "Prev";&lt;br /&gt;        btnImage.ToolTip = "Previous Page";&lt;br /&gt;        //btnImage.ImageAlign = ImageAlign.Middle;&lt;br /&gt;&lt;br /&gt;        if (gv.PageIndex == 0)&lt;br /&gt;        {&lt;br /&gt;            btnImage.Enabled = false;&lt;br /&gt;            btnImage.ImageUrl = "~/Images/prev_icon.jpg";&lt;br /&gt;        }&lt;br /&gt;        else&lt;br /&gt;        {&lt;br /&gt;            btnImage.Enabled = true;&lt;br /&gt;            btnImage.ImageUrl = "~/Images/prev_icon.jpg";&lt;br /&gt;            //btnImage.OnClientClick = "GeneaSys.Common.addProgressText('Previous grid page...');";&lt;br /&gt;            btnImage.Click += new ImageClickEventHandler(btn_Click2);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        ph.Controls.Add(btnImage);&lt;br /&gt;&lt;br /&gt;        // Pager page links&lt;br /&gt;        LinkButton lnb;&lt;br /&gt;        int numberOfPageLinks = gv.PagerSettings.PageButtonCount;&lt;br /&gt;        int startPage = (((gv.PageIndex) / numberOfPageLinks) * numberOfPageLinks) + 1;&lt;br /&gt;        if (startPage &amp;rt; gv.PageCount - numberOfPageLinks &amp;&amp; startPage &amp;rt; numberOfPageLinks) startPage = (gv.PageCount - numberOfPageLinks) + 1;&lt;br /&gt;        for (int i = startPage; i &amp;lt; numberOfPageLinks + startPage &amp;&amp; i &amp;lt;= gv.PageCount; i++)&lt;br /&gt;        {&lt;br /&gt;            if (i &amp;rt; startPage)&lt;br /&gt;            {&lt;br /&gt;                lit = new Literal();&lt;br /&gt;                lit.Text = " &amp;lt;span class=\"pageSeperator\"&amp;rt;|&amp;lt;/span&amp;rt; ";&lt;br /&gt;                ph.Controls.Add(lit);&lt;br /&gt;            }&lt;br /&gt;            else&lt;br /&gt;            {&lt;br /&gt;                lit = new Literal();&lt;br /&gt;                lit.Text = "&amp;lt;span class=\"pagerPageNumbers\"&amp;rt;";&lt;br /&gt;                ph.Controls.Add(lit);&lt;br /&gt;            }&lt;br /&gt;            if (gv.PageIndex + 1 == i)&lt;br /&gt;            {&lt;br /&gt;                lit = new Literal();&lt;br /&gt;                lit.Text = i.ToString();&lt;br /&gt;                ph.Controls.Add(lit);&lt;br /&gt;            }&lt;br /&gt;            else&lt;br /&gt;            {&lt;br /&gt;                lnb = new LinkButton();&lt;br /&gt;                lnb.CommandName = "Page";&lt;br /&gt;                lnb.CommandArgument = i.ToString();&lt;br /&gt;                lnb.Text = i.ToString();&lt;br /&gt;                ph.Controls.Add(lnb);&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;        lit = new Literal();&lt;br /&gt;        lit.Text = "&amp;lt;/span&amp;rt;";&lt;br /&gt;        ph.Controls.Add(lit);&lt;br /&gt;&lt;br /&gt;        // Next page button&lt;br /&gt;        btnImage = new ImageButton();&lt;br /&gt;        btnImage.ID = "btnNextPage";&lt;br /&gt;        btnImage.CommandName = "Page";&lt;br /&gt;        btnImage.CommandArgument = "Next";&lt;br /&gt;        btnImage.ToolTip = "Next Page";&lt;br /&gt;        //btnImage.ImageAlign = ImageAlign.Middle;&lt;br /&gt;        if (gv.PageIndex == gv.PageCount - 1)&lt;br /&gt;        {&lt;br /&gt;            btnImage.Enabled = false;&lt;br /&gt;            btnImage.ImageUrl = "~/images/next_icon.jpg";&lt;br /&gt;        }&lt;br /&gt;        else&lt;br /&gt;        {&lt;br /&gt;            btnImage.Enabled = true;&lt;br /&gt;            btnImage.ImageUrl = "~/Images/next_icon.jpg";&lt;br /&gt;            btnImage.Click += new ImageClickEventHandler(btn_Click1);&lt;br /&gt;            //btnImage.OnClientClick = "GeneaSys.Common.addProgressText('Next grid page...');";&lt;br /&gt;        }&lt;br /&gt;        ph.Controls.Add(btnImage);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        lit = new Literal();&lt;br /&gt;        lit.Text = "&amp;lt;span class=\"EmptySpan\"&amp;rt;&amp;nbsp;&amp;lt;/span&amp;rt;";&lt;br /&gt;        ph.Controls.Add(lit);&lt;br /&gt;&lt;br /&gt;        lit = new Literal();&lt;br /&gt;        lit.Text = "&amp;lt;span class=\"EmptySpan\"&amp;rt;&amp;nbsp;&amp;lt;/span&amp;rt;";&lt;br /&gt;        ph.Controls.Add(lit);&lt;br /&gt;&lt;br /&gt;        lit = new Literal();&lt;br /&gt;        lit.Text = "&amp;lt;span style=\"width:600px;\"&amp;rt;&amp;nbsp;Go to page:&amp;nbsp;";&lt;br /&gt;        ph.Controls.Add(lit);&lt;br /&gt;&lt;br /&gt;        TextBox tb = new TextBox();&lt;br /&gt;        tb.ID = "txtGoToPage";&lt;br /&gt;        tb.ToolTip = "Enter the Page Number";&lt;br /&gt;        tb.Width = Unit.Pixel(30);&lt;br /&gt;        tb.CausesValidation = true;&lt;br /&gt;        tb.ValidationGroup = "GoToPage";&lt;br /&gt;        ph.Controls.Add(tb);&lt;br /&gt;&lt;br /&gt;        lit = new Literal();&lt;br /&gt;        lit.Text = "&amp;lt;span class=\"EmptySpan\"&amp;rt;&amp;nbsp;&amp;lt;/span&amp;rt;";&lt;br /&gt;        ph.Controls.Add(lit);&lt;br /&gt;&lt;br /&gt;        ImageButton btn = new ImageButton();&lt;br /&gt;        btn.ID = "btnGoToPage";&lt;br /&gt;        //btn.Text = "Go";&lt;br /&gt;        btn.ImageUrl = "~/Images/go_btn.gif";&lt;br /&gt;        btn.CausesValidation = true;&lt;br /&gt;        btn.ValidationGroup = "GoToPage";&lt;br /&gt;        btn.ToolTip = "Go To Page";&lt;br /&gt;        btn.Click += new ImageClickEventHandler(btn_Click);&lt;br /&gt;        //btn.OnClientClick = "GeneaSys.Common.addProgressText('Going to grid page...');";&lt;br /&gt;        ph.Controls.Add(btn);&lt;br /&gt;&lt;br /&gt;        RangeValidator rv = new RangeValidator();&lt;br /&gt;        rv.ID = "valPager";&lt;br /&gt;        rv.Type = ValidationDataType.Integer;&lt;br /&gt;        rv.MinimumValue = "1";&lt;br /&gt;        rv.MaximumValue = gv.PageCount.ToString();&lt;br /&gt;        rv.Text = "not a page";&lt;br /&gt;        rv.EnableClientScript = true;&lt;br /&gt;        rv.ValidationGroup = "GoToPage";&lt;br /&gt;        rv.ControlToValidate = "txtGoToPage";&lt;br /&gt;        rv.SetFocusOnError = true;&lt;br /&gt;        ph.Controls.Add(rv);&lt;br /&gt;        // html markup&lt;br /&gt;        lit = new Literal();&lt;br /&gt;        lit.Text = "&amp;lt;/div&amp;rt;&amp;lt;div style=\"float:right;\"&amp;rt;";&lt;br /&gt;        ph.Controls.Add(lit);&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;        lit = new Literal();&lt;br /&gt;        lit.Text = "&amp;lt;span class=\"EmptySpan\"&amp;rt;&amp;nbsp;&amp;lt;/span&amp;rt;";&lt;br /&gt;        ph.Controls.Add(lit);&lt;br /&gt;&lt;br /&gt;        RangeValidator rv1 = new RangeValidator();&lt;br /&gt;        rv1.ID = "valPager1";&lt;br /&gt;        rv1.Type = ValidationDataType.Integer;&lt;br /&gt;        rv1.MinimumValue = "1";&lt;br /&gt;&lt;br /&gt;        rv1.MaximumValue = "100";&lt;br /&gt;&lt;br /&gt;        rv1.Text = "not a page";&lt;br /&gt;        rv1.EnableClientScript = true;&lt;br /&gt;        rv1.ValidationGroup = "PageSize";&lt;br /&gt;        rv1.ControlToValidate = "txtPageSize";&lt;br /&gt;        rv1.SetFocusOnError = true;&lt;br /&gt;&lt;br /&gt;        ph.Controls.Add(rv1);&lt;br /&gt;&lt;br /&gt;        lit = new Literal();&lt;br /&gt;        lit.Text = "&amp;lt;span style=\" margin: 0pt; width: 200px; padding-left: 35px;\"&amp;rt;Results per page:&amp;nbsp;";&lt;br /&gt;        ph.Controls.Add(lit);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        TextBox tb1 = new TextBox();&lt;br /&gt;        tb1.ID = "txtPageSize";&lt;br /&gt;        tb1.Text = gv.PageSize.ToString();&lt;br /&gt;        tb1.ToolTip = "Enter the Page Size";&lt;br /&gt;        tb1.Width = Unit.Pixel(30);&lt;br /&gt;        tb1.CausesValidation = true;&lt;br /&gt;        tb1.ValidationGroup = "PageSize";&lt;br /&gt;        ph.Controls.Add(tb1);&lt;br /&gt;&lt;br /&gt;        lit = new Literal();&lt;br /&gt;        lit.Text = "&amp;lt;span class=\"EmptySpan\"&amp;rt;&amp;nbsp;&amp;nbsp;&amp;lt;/span&amp;rt;";&lt;br /&gt;        ph.Controls.Add(lit);&lt;br /&gt;&lt;br /&gt;        ImageButton btn1 = new ImageButton();&lt;br /&gt;        btn1.ID = "btnGoToPageSize";&lt;br /&gt;        //btn.Text = "Go";&lt;br /&gt;        btn1.ImageUrl = "~/Images/go_btn.gif";&lt;br /&gt;        btn1.CausesValidation = true;&lt;br /&gt;        btn1.ValidationGroup = "PageSize";&lt;br /&gt;        btn1.ToolTip = " Page Size";&lt;br /&gt;        btn1.Click += new ImageClickEventHandler(btn2_Click);&lt;br /&gt;        //btn.OnClientClick = "GeneaSys.Common.addProgressText('Going to grid page...');";&lt;br /&gt;        ph.Controls.Add(btn1);&lt;br /&gt;&lt;br /&gt;      &lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    /// &amp;lt;summary&amp;rt;&lt;br /&gt;    /// Developer: Mansoor: Purpose : Method used to set a gridview footer with Go to page and results per page feature&lt;br /&gt;    /// &amp;lt;/summary&amp;rt;&lt;br /&gt;    /// &amp;lt;param name="gv"&amp;rt;&amp;lt;/param&amp;rt;&lt;br /&gt;    /// &amp;lt;param name="gvr"&amp;rt;&amp;lt;/param&amp;rt;&lt;br /&gt;    /// &amp;lt;param name="GridRecordCount"&amp;rt;&amp;lt;/param&amp;rt;&lt;br /&gt;    public static void GetGridViewPager(GridView gv, GridViewRow gvr,string GridRecordCount)&lt;br /&gt;    {&lt;br /&gt;        if ((PlaceHolder)gvr.FindControl("phPager") == null)&lt;br /&gt;        {&lt;br /&gt;            throw new ApplicationException("A placeholder with an ID=\"phPager\" is required for this to work");&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        PlaceHolder ph = (PlaceHolder)gvr.FindControl("phPager");&lt;br /&gt;&lt;br /&gt;        // html markup and style&lt;br /&gt;        StringBuilder sb = new StringBuilder();&lt;br /&gt;        sb.Append("&amp;lt;div style=\"float:left;\"&amp;rt;");&lt;br /&gt;        sb.Append(string.Format("&amp;lt;span class=\"pagerCurrentPage\"&amp;rt;Page: {0} of {1}&amp;lt;/span&amp;rt;", (gv.PageIndex + 1).ToString(), gv.PageCount));&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        Literal lit = new Literal();&lt;br /&gt;        lit.Text = sb.ToString();&lt;br /&gt;        ph.Controls.Add(lit);&lt;br /&gt;&lt;br /&gt;        //adding the table &lt;br /&gt;        //StringBuilder sbTable = new StringBuilder();&lt;br /&gt;        //sbTable.Append("width=\"100\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\" align=\"left\"&amp;rt;");&lt;br /&gt;        //sbTable.Append("&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        // Previous page button&lt;br /&gt;        ImageButton btnImage = new ImageButton();&lt;br /&gt;        btnImage.ID = "btnPrevPage";&lt;br /&gt;        btnImage.CommandName = "Page";&lt;br /&gt;        btnImage.CommandArgument = "Prev";&lt;br /&gt;        btnImage.ToolTip = "Previous Page";&lt;br /&gt;        //btnImage.ImageAlign = ImageAlign.Middle;&lt;br /&gt;&lt;br /&gt;        if (gv.PageIndex == 0)&lt;br /&gt;        {&lt;br /&gt;            btnImage.Enabled = false;&lt;br /&gt;            btnImage.ImageUrl = "~/Images/prev_icon.jpg";&lt;br /&gt;        }&lt;br /&gt;        else&lt;br /&gt;        {&lt;br /&gt;            btnImage.Enabled = true;&lt;br /&gt;            btnImage.ImageUrl = "~/Images/prev_icon.jpg";&lt;br /&gt;            //btnImage.OnClientClick = "GeneaSys.Common.addProgressText('Previous grid page...');";&lt;br /&gt;            btnImage.Click += new ImageClickEventHandler(btn_Click2);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        ph.Controls.Add(btnImage);&lt;br /&gt;&lt;br /&gt;        // Pager page links&lt;br /&gt;        LinkButton lnb;&lt;br /&gt;        int numberOfPageLinks = gv.PagerSettings.PageButtonCount;&lt;br /&gt;        int startPage = (((gv.PageIndex) / numberOfPageLinks) * numberOfPageLinks) + 1;&lt;br /&gt;        if (startPage &amp;rt; gv.PageCount - numberOfPageLinks &amp;&amp; startPage &amp;rt; numberOfPageLinks) startPage = (gv.PageCount - numberOfPageLinks) + 1;&lt;br /&gt;        for (int i = startPage; i &amp;lt; numberOfPageLinks + startPage &amp;&amp; i &amp;lt;= gv.PageCount; i++)&lt;br /&gt;        {&lt;br /&gt;            if (i &amp;rt; startPage)&lt;br /&gt;            {&lt;br /&gt;                lit = new Literal();&lt;br /&gt;                lit.Text = " &amp;lt;span class=\"pageSeperator\"&amp;rt;|&amp;lt;/span&amp;rt; ";&lt;br /&gt;                ph.Controls.Add(lit);&lt;br /&gt;            }&lt;br /&gt;            else&lt;br /&gt;            {&lt;br /&gt;                lit = new Literal();&lt;br /&gt;                lit.Text = "&amp;lt;span class=\"pagerPageNumbers\"&amp;rt;";&lt;br /&gt;                ph.Controls.Add(lit);&lt;br /&gt;            }&lt;br /&gt;            if (gv.PageIndex + 1 == i)&lt;br /&gt;            {&lt;br /&gt;                lit = new Literal();&lt;br /&gt;                lit.Text = i.ToString();&lt;br /&gt;                ph.Controls.Add(lit);&lt;br /&gt;            }&lt;br /&gt;            else&lt;br /&gt;            {&lt;br /&gt;                lnb = new LinkButton();&lt;br /&gt;                lnb.CommandName = "Page";&lt;br /&gt;                lnb.CommandArgument = i.ToString();&lt;br /&gt;                lnb.Text = i.ToString();&lt;br /&gt;                ph.Controls.Add(lnb);&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;        lit = new Literal();&lt;br /&gt;        lit.Text = "&amp;lt;/span&amp;rt;";&lt;br /&gt;        ph.Controls.Add(lit);&lt;br /&gt;&lt;br /&gt;        // Next page button&lt;br /&gt;        btnImage = new ImageButton();&lt;br /&gt;        btnImage.ID = "btnNextPage";&lt;br /&gt;        btnImage.CommandName = "Page";&lt;br /&gt;        btnImage.CommandArgument = "Next";&lt;br /&gt;        btnImage.ToolTip = "Next Page";&lt;br /&gt;        //btnImage.ImageAlign = ImageAlign.Middle;&lt;br /&gt;        if (gv.PageIndex == gv.PageCount - 1)&lt;br /&gt;        {&lt;br /&gt;            btnImage.Enabled = false;&lt;br /&gt;            btnImage.ImageUrl = "~/images/next_icon.jpg";&lt;br /&gt;        }&lt;br /&gt;        else&lt;br /&gt;        {&lt;br /&gt;            btnImage.Enabled = true;&lt;br /&gt;            btnImage.ImageUrl = "~/Images/next_icon.jpg";&lt;br /&gt;            btnImage.Click += new ImageClickEventHandler(btn_Click1);&lt;br /&gt;            //btnImage.OnClientClick = "GeneaSys.Common.addProgressText('Next grid page...');";&lt;br /&gt;        }&lt;br /&gt;        ph.Controls.Add(btnImage);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        lit = new Literal();&lt;br /&gt;        lit.Text = "&amp;lt;span class=\"EmptySpan\"&amp;rt;&amp;nbsp;&amp;lt;/span&amp;rt;";&lt;br /&gt;        ph.Controls.Add(lit);&lt;br /&gt;&lt;br /&gt;        lit = new Literal();&lt;br /&gt;        lit.Text = "&amp;lt;span class=\"EmptySpan\"&amp;rt;&amp;nbsp;&amp;lt;/span&amp;rt;";&lt;br /&gt;        ph.Controls.Add(lit);&lt;br /&gt;&lt;br /&gt;        lit = new Literal();&lt;br /&gt;        lit.Text = "&amp;lt;span style=\"width:600px;\"&amp;rt;&amp;nbsp;Go to page:&amp;nbsp;";&lt;br /&gt;        ph.Controls.Add(lit);&lt;br /&gt;&lt;br /&gt;        TextBox tb = new TextBox();&lt;br /&gt;        tb.ID = "txtGoToPage";&lt;br /&gt;        tb.ToolTip = "Enter the Page Number";&lt;br /&gt;        tb.Width = Unit.Pixel(30);&lt;br /&gt;        tb.CausesValidation = true;&lt;br /&gt;        tb.ValidationGroup = "GoToPage";&lt;br /&gt;        ph.Controls.Add(tb);&lt;br /&gt;&lt;br /&gt;        lit = new Literal();&lt;br /&gt;        lit.Text = "&amp;lt;span class=\"EmptySpan\"&amp;rt;&amp;nbsp;&amp;lt;/span&amp;rt;";&lt;br /&gt;        ph.Controls.Add(lit);&lt;br /&gt;&lt;br /&gt;        ImageButton btn = new ImageButton();&lt;br /&gt;        btn.ID = "btnGoToPage";&lt;br /&gt;        //btn.Text = "Go";&lt;br /&gt;        btn.ImageUrl = "~/Images/go_btn.gif";&lt;br /&gt;        btn.CausesValidation = true;&lt;br /&gt;        btn.ValidationGroup = "GoToPage";&lt;br /&gt;        btn.ToolTip = "Go To Page";&lt;br /&gt;        btn.Click += new ImageClickEventHandler(btn_Click);&lt;br /&gt;        //btn.OnClientClick = "GeneaSys.Common.addProgressText('Going to grid page...');";&lt;br /&gt;        ph.Controls.Add(btn);&lt;br /&gt;&lt;br /&gt;        RangeValidator rv = new RangeValidator();&lt;br /&gt;        rv.ID = "valPager";&lt;br /&gt;        rv.Type = ValidationDataType.Integer;&lt;br /&gt;        rv.MinimumValue = "1";&lt;br /&gt;        rv.MaximumValue = gv.PageCount.ToString();&lt;br /&gt;        rv.Text = "not a page";&lt;br /&gt;        rv.EnableClientScript = true;&lt;br /&gt;        rv.ValidationGroup = "GoToPage";&lt;br /&gt;        rv.ControlToValidate = "txtGoToPage";&lt;br /&gt;        rv.SetFocusOnError = true;&lt;br /&gt;        ph.Controls.Add(rv);&lt;br /&gt;        // html markup&lt;br /&gt;        lit = new Literal();&lt;br /&gt;        lit.Text = "&amp;lt;/div&amp;rt;&amp;lt;div style=\"float:right;\"&amp;rt;";&lt;br /&gt;        ph.Controls.Add(lit);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        lit = new Literal();&lt;br /&gt;        lit.Text = "&amp;lt;span class=\"EmptySpan\"&amp;rt;&amp;nbsp;&amp;lt;/span&amp;rt;";&lt;br /&gt;        ph.Controls.Add(lit);&lt;br /&gt;&lt;br /&gt;        RangeValidator rv1 = new RangeValidator();&lt;br /&gt;        rv1.ID = "valPager1";&lt;br /&gt;        rv1.Type = ValidationDataType.Integer;&lt;br /&gt;        rv1.MinimumValue = "1";&lt;br /&gt;&lt;br /&gt;        rv1.MaximumValue = GridRecordCount;&lt;br /&gt;&lt;br /&gt;        rv1.Text = "Exceeds max records";&lt;br /&gt;        rv1.EnableClientScript = true;&lt;br /&gt;        rv1.ValidationGroup = "PageSize";&lt;br /&gt;        rv1.ControlToValidate = "txtPageSize";&lt;br /&gt;        rv1.SetFocusOnError = true;&lt;br /&gt;&lt;br /&gt;        ph.Controls.Add(rv1);&lt;br /&gt;&lt;br /&gt;        lit = new Literal();&lt;br /&gt;        lit.Text = "&amp;lt;span style=\" margin: 0pt; width: 200px; padding-left: 35px;\"&amp;rt;Results per page:&amp;nbsp;";&lt;br /&gt;        ph.Controls.Add(lit);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        TextBox tb1 = new TextBox();&lt;br /&gt;        tb1.ID = "txtPageSize";&lt;br /&gt;        tb1.Text = gv.PageSize.ToString();&lt;br /&gt;        tb1.ToolTip = "Enter the results per Page Size";&lt;br /&gt;        tb1.Width = Unit.Pixel(30);&lt;br /&gt;        tb1.CausesValidation = true;&lt;br /&gt;        tb1.ValidationGroup = "PageSize";&lt;br /&gt;        ph.Controls.Add(tb1);&lt;br /&gt;&lt;br /&gt;        lit = new Literal();&lt;br /&gt;        lit.Text = "&amp;lt;span class=\"EmptySpan\"&amp;rt;&amp;nbsp;&amp;nbsp;&amp;lt;/span&amp;rt;";&lt;br /&gt;        ph.Controls.Add(lit);&lt;br /&gt;&lt;br /&gt;        ImageButton btn1 = new ImageButton();&lt;br /&gt;        btn1.ID = "btnGoToPageSize";&lt;br /&gt;        //btn.Text = "Go";&lt;br /&gt;        btn1.ImageUrl = "~/Images/go_btn.gif";&lt;br /&gt;        btn1.CausesValidation = true;&lt;br /&gt;        btn1.ValidationGroup = "PageSize";&lt;br /&gt;        btn1.ToolTip = " Page Size";&lt;br /&gt;        btn1.Click += new ImageClickEventHandler(btn2_Click);&lt;br /&gt;        //btn.OnClientClick = "GeneaSys.Common.addProgressText('Going to grid page...');";&lt;br /&gt;        ph.Controls.Add(btn1);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;   &lt;br /&gt;    private static void btn2_Click(object sender, EventArgs e)&lt;br /&gt;    {&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        GridViewRow gvr = (GridViewRow)((ImageButton)sender).NamingContainer;&lt;br /&gt;        TextBox tb = (TextBox)gvr.FindControl("txtPageSize");&lt;br /&gt;        GridView gv = (GridView)gvr.NamingContainer;&lt;br /&gt;&lt;br /&gt;        int pageSize;&lt;br /&gt;&lt;br /&gt;        if (int.TryParse(tb.Text, out pageSize))&lt;br /&gt;        {&lt;br /&gt;            if (pageSize &amp;lt;= 0)&lt;br /&gt;            {&lt;br /&gt;                //gv.PageIndex = 0;&lt;br /&gt;            }&lt;br /&gt;            else&lt;br /&gt;            {&lt;br /&gt;&lt;br /&gt;                gv.PageSize = int.Parse(tb.Text);&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;    private static void btn_Click(object sender, EventArgs e)&lt;br /&gt;    {&lt;br /&gt;        //GridViewRow gvr = (GridViewRow)((ImageButton)sender).NamingContainer;&lt;br /&gt;        //TextBox tb = (TextBox)gvr.FindControl("txtGoToPage");&lt;br /&gt;        //GridView gv = (GridView)gvr.NamingContainer;&lt;br /&gt;&lt;br /&gt;        //int pageNumber;&lt;br /&gt;&lt;br /&gt;        //if (int.TryParse(tb.Text, out pageNumber))&lt;br /&gt;        //{&lt;br /&gt;        //    gv.PageIndex = (pageNumber - 1);&lt;br /&gt;        //}&lt;br /&gt;&lt;br /&gt;        GridViewRow gvr = (GridViewRow)((ImageButton)sender).NamingContainer;&lt;br /&gt;        TextBox tb = (TextBox)gvr.FindControl("txtGoToPage");&lt;br /&gt;        GridView gv = (GridView)gvr.NamingContainer;&lt;br /&gt;&lt;br /&gt;        int pageNumber;&lt;br /&gt;&lt;br /&gt;        if (int.TryParse(tb.Text, out pageNumber))&lt;br /&gt;        {&lt;br /&gt;            if (pageNumber &amp;lt;= 0)&lt;br /&gt;            {&lt;br /&gt;                //gv.PageIndex = 0;&lt;br /&gt;            }&lt;br /&gt;            else if (pageNumber &amp;lt;= gv.PageCount)&lt;br /&gt;            {&lt;br /&gt;                gv.PageIndex = (pageNumber - 1);&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;    private static void btn_Click1(object sender, EventArgs e)&lt;br /&gt;    {&lt;br /&gt;&lt;br /&gt;        GridViewRow gvr = (GridViewRow)((ImageButton)sender).NamingContainer;&lt;br /&gt;        TextBox tb = (TextBox)gvr.FindControl("txtGoToPage");&lt;br /&gt;        GridView gv = (GridView)gvr.NamingContainer;&lt;br /&gt;        int pageNumber = gv.PageIndex;&lt;br /&gt;        gv.PageIndex = pageNumber + 1;&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;    private static void btn_Click2(object sender, EventArgs e)&lt;br /&gt;    {&lt;br /&gt;&lt;br /&gt;        GridViewRow gvr = (GridViewRow)((ImageButton)sender).NamingContainer;&lt;br /&gt;        TextBox tb = (TextBox)gvr.FindControl("txtGoToPage");&lt;br /&gt;        GridView gv = (GridView)gvr.NamingContainer;&lt;br /&gt;        int pageNumber = gv.PageIndex;&lt;br /&gt;        if (pageNumber != 0)&lt;br /&gt;            gv.PageIndex = pageNumber - 1;&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Coding in CS page&lt;br /&gt;&lt;br /&gt; /// &amp;lt;summary&amp;rt;&lt;br /&gt;        /// Method for prerender of grid grvManageRequest&lt;br /&gt;     /// &amp;lt;/summary&amp;rt;&lt;br /&gt;     /// &amp;lt;param name="sender"&amp;rt;&amp;lt;/param&amp;rt;&lt;br /&gt;     /// &amp;lt;param name="e"&amp;rt;&amp;lt;/param&amp;rt;&lt;br /&gt;        protected void grvManageRequest_PreRender(object sender, EventArgs e)&lt;br /&gt;        {&lt;br /&gt;            try&lt;br /&gt;            {&lt;br /&gt;                //SetGridHeaderSortDirectionArrow((GridView)sender, "SharedEquipmentName");&lt;br /&gt;                if (!Page.IsPostBack &amp;&amp; !string.IsNullOrEmpty(Request.Params["pgn"]))&lt;br /&gt;                {&lt;br /&gt;                    grvManageRequest.PageIndex = Convert.ToInt32(Request.Params["pgn"]);&lt;br /&gt;                }&lt;br /&gt;            }&lt;br /&gt;            catch (Exception ex)&lt;br /&gt;            {&lt;br /&gt;                SetResultMessageToLabel("Error :" + ex.Source + " &amp;lt;BR/&amp;rt;Error Message : Error Occured while loading the data to the grid view " + ex.Message, false);&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;----------------&lt;br /&gt;     protected void grvManageRequest_RowCreated(object sender, GridViewRowEventArgs e)&lt;br /&gt;        {&lt;br /&gt;            try&lt;br /&gt;            {&lt;br /&gt;                GridView gv = (GridView)sender;&lt;br /&gt;                // This is for the custom grid pager.&lt;br /&gt;                if (e.Row.RowType == DataControlRowType.Pager)&lt;br /&gt;                {&lt;br /&gt;                    TotalRecordCount = ocdsManageRequest.Items.Count;&lt;br /&gt;                    GridViewPageFooter.GetGridViewPager(gv, e.Row);&lt;br /&gt;                }&lt;br /&gt;            }&lt;br /&gt;          catch(Exception ex)&lt;br /&gt;            {&lt;br /&gt;            }&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7527040749709927669-8489591702136038081?l=jaan1762.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jaan1762.blogspot.com/feeds/8489591702136038081/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7527040749709927669&amp;postID=8489591702136038081' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/8489591702136038081'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/8489591702136038081'/><link rel='alternate' type='text/html' href='http://jaan1762.blogspot.com/2009/11/gridview-footer-page.html' title='Gridview Footer Page'/><author><name>Mansoor</name><uri>http://www.blogger.com/profile/00473621254256960630</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-7527040749709927669.post-2858124915055756340</id><published>2009-09-16T04:53:00.000-07:00</published><updated>2009-09-16T04:54:44.383-07:00</updated><title type='text'>restrict Backspace and Delete in textbox</title><content type='html'>// This is for the Key Press Event&lt;br /&gt;function Keypress_Event()&lt;br /&gt;{&lt;br /&gt;     // This is for Getting the Source Element..&lt;br /&gt;    var objTxtBox = window.event.srcElement; &lt;br /&gt;    // declare the variable for the bool value.&lt;br /&gt;    var isOk = false;&lt;br /&gt;    // Here we need not backspace keycode = 8 and the delete keycode 46&lt;br /&gt;    isOk = ( event.keyCode == 8 || event.keyCode == 46 ) ? false:true;          event.returnValue=isOk;&lt;br /&gt;} And in your aspx call the keypress as &lt;br /&gt;&lt;br /&gt;asp:TextBox ID="txtTest" runat="server" onkeydown="Keypress_Event()"&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7527040749709927669-2858124915055756340?l=jaan1762.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jaan1762.blogspot.com/feeds/2858124915055756340/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7527040749709927669&amp;postID=2858124915055756340' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/2858124915055756340'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/2858124915055756340'/><link rel='alternate' type='text/html' href='http://jaan1762.blogspot.com/2009/09/restrict-backspace-and-delete-in.html' title='restrict Backspace and Delete in textbox'/><author><name>Mansoor</name><uri>http://www.blogger.com/profile/00473621254256960630</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-7527040749709927669.post-4926250484772819676</id><published>2009-08-12T00:14:00.001-07:00</published><updated>2009-08-12T00:14:23.790-07:00</updated><title type='text'>Get a Filename from a Path in Javascript</title><content type='html'>Here's a quick Javascript function that will parse the filename from a path using regex.  It looks for any letter or digit, hyphen, or underscore followed by a dot (.) followed by a letters or numbers for the extension.&lt;br /&gt;&lt;br /&gt;function getFileName(path) {&lt;br /&gt;    return path.match(/[-_\w]+[.][\w]+$/i)[0];&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7527040749709927669-4926250484772819676?l=jaan1762.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jaan1762.blogspot.com/feeds/4926250484772819676/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7527040749709927669&amp;postID=4926250484772819676' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/4926250484772819676'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/4926250484772819676'/><link rel='alternate' type='text/html' href='http://jaan1762.blogspot.com/2009/08/get-filename-from-path-in-javascript.html' title='Get a Filename from a Path in Javascript'/><author><name>Mansoor</name><uri>http://www.blogger.com/profile/00473621254256960630</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-7527040749709927669.post-8067991433717175562</id><published>2009-08-04T07:37:00.000-07:00</published><updated>2009-08-04T07:39:29.385-07:00</updated><title type='text'>Way to get  Email Value from web.config in asp text box</title><content type='html'>&amp;lt;asp:TextBox ID="txtReportTo" runat="server" CssClass="inputbox" Text='&amp;lt;%# System.Configuration.ConfigurationManager.AppSettings["FromMailID"].ToString()%&amp;rt;'&lt;br /&gt;                                                                                                                            ReadOnly="true"&amp;rt;&amp;lt;/asp:TextBox&amp;rt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7527040749709927669-8067991433717175562?l=jaan1762.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jaan1762.blogspot.com/feeds/8067991433717175562/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7527040749709927669&amp;postID=8067991433717175562' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/8067991433717175562'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/8067991433717175562'/><link rel='alternate' type='text/html' href='http://jaan1762.blogspot.com/2009/08/way-to-get-email-value-from-webconfig.html' title='Way to get  Email Value from web.config in asp text box'/><author><name>Mansoor</name><uri>http://www.blogger.com/profile/00473621254256960630</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-7527040749709927669.post-5410466349560128426</id><published>2009-07-29T02:25:00.001-07:00</published><updated>2009-07-29T02:34:03.900-07:00</updated><title type='text'>Using XSLT to Transform XML Using ASP.NET</title><content type='html'>This article gives a brief introduction on XML, XSLT and provides a step-by-step procedure on how XML can be transformed using ASP.NET with the help of code samples in C#.&lt;br /&gt;&lt;br /&gt;This article demonstrates how to transform XML using XSLT in ASP.NET using C#. It explains the basics of XML, XSLT and how we could take advantage of XSLT in the web pages that use ASP.NET.&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;What is XML (eXtensible Markup Language)?&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;XML has become one of the popular standards for data storage and data transfer. XML does not define tags like other markup languages. Instead, it lets you define your own tags. &lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;What is XSLT (eXtensible Stylesheet Language Transformation)?&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt; to display the XML data there is a need for a language to transform the data. To accommodate this process, XSLT was created. XSLT can be applied to transform XML data into different formats, such as HTML. &lt;br /&gt;&lt;br /&gt;The figure below illustrates the transformation process.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_URzpGoyPbng/SnAVqbJofdI/AAAAAAAAC9w/UE4VhSN-TKM/s1600-h/image001.gif"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 320px; height: 111px;" src="http://4.bp.blogspot.com/_URzpGoyPbng/SnAVqbJofdI/AAAAAAAAC9w/UE4VhSN-TKM/s320/image001.gif" border="0" alt=""id="BLOGGER_PHOTO_ID_5363810974785109458" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;What is the difference between XSL and XSLT? &lt;br /&gt;[ Back To Top ]&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;I have seen XSL and XSLT used interchangeably in the Web developer world. It is, however, helpful to know the difference. XSL (Extensible Stylesheet Language) is the superset of XSLT as it includes XSLT and XSL formatting objects. By using the term XSL, they implicitly mean XSLT. &lt;br /&gt; &lt;br /&gt;Transforming XML data using ASP.NET &lt;br /&gt;[ Back To Top ]&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Step 1: Create the XML file&lt;br /&gt;&lt;br /&gt;XML can be in memory representation or a flat file. The XML file that I will be using for this illustration is shown below. This file has the population data of different countries along with the names of cities and percentage of population.&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&amp;lt;countries&amp;rt;&lt;br /&gt;      &amp;lt;country name="USA" continent="North America"&amp;rt;&lt;br /&gt;            &amp;lt;stats&amp;rt;&lt;br /&gt;                  &amp;lt;Population&amp;rt;301,139,947&amp;lt;/Population&amp;rt;&lt;br /&gt;                  &amp;lt;cities&amp;rt;&lt;br /&gt;                        &amp;lt;city name="NYC" percentage="2.72"/&amp;rt;&lt;br /&gt;                        &amp;lt;city name="Los Angeles" percentage="1.15"/&amp;rt;&lt;br /&gt;                        &amp;lt;city name="Chicago" percentage="0.94"/&amp;rt;&lt;br /&gt;                  &amp;lt;/cities&amp;rt;&lt;br /&gt;            &amp;lt;/stats&amp;rt;&lt;br /&gt;      &amp;lt;/country&amp;rt;&lt;br /&gt;      &amp;lt;country name="India" continent="Asia"&amp;rt;&lt;br /&gt;            &amp;lt;stats&amp;rt;&lt;br /&gt;                  &amp;lt;Population&amp;rt;1,129,866,154&amp;lt;/Population&amp;rt;&lt;br /&gt;                  &amp;lt;cities&amp;rt;&lt;br /&gt;                        &amp;lt;city name="Bangalore" percentage="0.50"/&amp;rt;&lt;br /&gt;                        &amp;lt;city name="Chennai" percentage="0.58"/&amp;rt;&lt;br /&gt;                        &amp;lt;city name="Kolkata" percentage="0.60"/&amp;rt;&lt;br /&gt;                  &amp;lt;/cities&amp;rt;&lt;br /&gt;            &amp;lt;/stats&amp;rt;&lt;br /&gt;      &amp;lt;/country&amp;rt;&lt;br /&gt;      &amp;lt;country name="China" continent="Asia"&amp;rt;&lt;br /&gt;            &amp;lt;stats&amp;rt;&lt;br /&gt;                  &amp;lt;Population&amp;rt;1,321,851,888&amp;lt;/Population&amp;rt;&lt;br /&gt;                  &amp;lt;cities&amp;rt;&lt;br /&gt;                        &amp;lt;city name="Beijing" percentage="1.10"/&amp;rt;&lt;br /&gt;                        &amp;lt;city name="Shanghai" percentage="1.51"/&amp;rt;&lt;br /&gt;                        &amp;lt;city name="Tianjin" percentage="0.51"/&amp;rt;&lt;br /&gt;                  &amp;lt;/cities&amp;rt;&lt;br /&gt;            &amp;lt;/stats&amp;rt;&lt;br /&gt;      &amp;lt;/country&amp;rt;&lt;br /&gt;&amp;lt;/countries&amp;rt;&lt;br /&gt;&lt;br /&gt;Copy this data into a file and name it aspalliance.xml.&lt;br /&gt;&lt;br /&gt;Step 2: Create the XSLT file &lt;br /&gt;&lt;br /&gt;The XSLT file can be created using your favorite editor. I recommend XML Spy because it has very good support for XML and XSLT. The stylesheet for this example is shown below.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;rt;&lt;br /&gt;&amp;lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&amp;rt;&lt;br /&gt;      &amp;lt;xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/&amp;rt;&lt;br /&gt;      &amp;lt;xsl:template match="/"&amp;rt;&lt;br /&gt;            &amp;lt;html&amp;rt;&lt;br /&gt;                  &amp;lt;head/&amp;rt;&lt;br /&gt;                  &amp;lt;body&amp;rt;&lt;br /&gt;                        &amp;lt;h1&amp;rt;Countries&amp;lt;/h1&amp;rt;&lt;br /&gt;                        &amp;lt;xsl:apply-templates/&amp;rt;&lt;br /&gt;                  &amp;lt;/body&amp;rt;&lt;br /&gt;            &amp;lt;/html&amp;rt;&lt;br /&gt;      &amp;lt;/xsl:template&amp;rt;&lt;br /&gt;      &amp;lt;xsl:template match="countries"&amp;rt;&lt;br /&gt;            &amp;lt;xsl:apply-templates/&amp;rt;&lt;br /&gt;      &amp;lt;/xsl:template&amp;rt;&lt;br /&gt;      &amp;lt;xsl:template match="country"&amp;rt;&lt;br /&gt;            &amp;lt;h3&amp;rt;&lt;br /&gt;                  &amp;lt;xsl:value-of select="@name"/&amp;rt; (&amp;lt;xsl:value-of select="@continent"/&amp;rt;)&lt;br /&gt;            &amp;lt;/h3&amp;rt;&lt;br /&gt;            &amp;lt;xsl:apply-templates/&amp;rt;&lt;br /&gt;      &amp;lt;/xsl:template&amp;rt;&lt;br /&gt;      &amp;lt;xsl:template match="stats"&amp;rt;&lt;br /&gt;            Population : &amp;lt;xsl:value-of select="@Population"/&amp;rt;&lt;br /&gt;            &amp;lt;xsl:apply-templates/&amp;rt;&lt;br /&gt;      &amp;lt;/xsl:template&amp;rt;&lt;br /&gt;      &amp;lt;xsl:template match="cities"&amp;rt;&lt;br /&gt;            &amp;lt;table border="1" &amp;rt;&lt;br /&gt;                  &amp;lt;tr&amp;rt;&lt;br /&gt;                        &amp;lt;td&amp;rt;Name&amp;lt;/td&amp;rt;&lt;br /&gt;                        &amp;lt;td&amp;rt;Percentage&amp;lt;/td&amp;rt;&lt;br /&gt;                  &amp;lt;/tr&amp;rt;&lt;br /&gt;                  &amp;lt;xsl:apply-templates/&amp;rt;&lt;br /&gt;            &amp;lt;/table&amp;rt;&lt;br /&gt;      &amp;lt;/xsl:template&amp;rt;&lt;br /&gt;      &amp;lt;xsl:template match="city"&amp;rt;&lt;br /&gt;            &amp;lt;tr&amp;rt;&lt;br /&gt;                  &amp;lt;td&amp;rt;&lt;br /&gt;                        &amp;lt;xsl:value-of select="@name"/&amp;rt;&lt;br /&gt;                  &amp;lt;/td&amp;rt;&lt;br /&gt;                  &amp;lt;td&amp;rt;&lt;br /&gt;                        &amp;lt;xsl:value-of select="@percentage"/&amp;rt;&lt;br /&gt;                  &amp;lt;/td&amp;rt;&lt;br /&gt;            &amp;lt;/tr&amp;rt;&lt;br /&gt;            &amp;lt;xsl:apply-templates/&amp;rt;&lt;br /&gt;      &amp;lt;/xsl:template&amp;rt;&lt;br /&gt;&amp;lt;/xsl:stylesheet&amp;rt;&lt;br /&gt;&lt;br /&gt;Some important notes about XSLT&lt;br /&gt;&lt;br /&gt;You will have noticed that I have a template section for every XML element. When the XSLT processor encounters the statement &lt;xsl:apply-templates/&gt;, it searches for the template that matches (ex: &lt;xsl:template match="city"&gt; ) and applies it.&lt;br /&gt;&lt;br /&gt;The syntax &lt;xsl:value-of select="@percentage"/&gt; is used to print the value of the element/attribute.&lt;br /&gt;&lt;br /&gt;Copy this XSLT into a file and name it aspalliance.xslt.&lt;br /&gt;&lt;br /&gt;Step 3: Create a web page that displays the XML using XSLT in ASP.NET &lt;br /&gt;&lt;br /&gt;ASP.NET has excellent support for XML and XSLT. First, import the necessary namespaces.&lt;br /&gt;&lt;br /&gt;Listing 3&lt;br /&gt;&lt;br /&gt;using System.Xml;&lt;br /&gt;using System.Xml.Xsl;&lt;br /&gt;using System.Xml.XPath;&lt;br /&gt;using System.IO;Add the XML and XSLT files into the web project. Create an aspx page (or a ascx control) and use the method (ApplyXSLTransformation()) below that will read the XML and the XSLT document and return a string that is the HTML representation of the transformed XML data.&lt;br /&gt;&lt;br /&gt;Listing 4&lt;br /&gt;&lt;br /&gt;private string ApplyXSLTransformation()&lt;br /&gt;{&lt;br /&gt;    string strHtml;&lt;br /&gt; &lt;br /&gt;    string strXstFile = Server.MapPath("aspalliance.xslt");&lt;br /&gt;    XslCompiledTransform x = new XslCompiledTransform();&lt;br /&gt; &lt;br /&gt;    // Load the XML &lt;br /&gt;    XPathDocument doc = new XPathDocument(Server.MapPath("aspalliance.xml"));&lt;br /&gt; &lt;br /&gt;    // Load the style sheet.&lt;br /&gt;    XslCompiledTransform xslt = new XslCompiledTransform();&lt;br /&gt;    xslt.Load(strXstFile);&lt;br /&gt;    MemoryStream ms = new MemoryStream();&lt;br /&gt;    XmlTextWriter writer = new XmlTextWriter(ms, Encoding.ASCII);&lt;br /&gt;    StreamReader rd = new StreamReader(ms);&lt;br /&gt;    xslt.Transform(doc, writer);&lt;br /&gt;    ms.Position = 0;&lt;br /&gt;    strHtml = rd.ReadToEnd();&lt;br /&gt;    rd.Close();&lt;br /&gt;    ms.Close();&lt;br /&gt;    return strHtml;&lt;br /&gt;}You can use the string (strHtml) that is returned in this method in anyway useful for your application. Ex: You can assign it to a label or process it further as needed.&lt;br /&gt;&lt;br /&gt;Step 4: View the Output&lt;br /&gt;&lt;br /&gt;The output of transformation is shown in the figure below.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_URzpGoyPbng/SnAVvnJGEoI/AAAAAAAAC94/WPWTSFCOQqQ/s1600-h/image002.jpg"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 320px; height: 200px;" src="http://3.bp.blogspot.com/_URzpGoyPbng/SnAVvnJGEoI/AAAAAAAAC94/WPWTSFCOQqQ/s320/image002.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5363811063903425154" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;In this article I covered the basics of XML and XSLT. I also illustrated how to transform XML data using XSLT in ASP.NET. Happy Coding!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7527040749709927669-5410466349560128426?l=jaan1762.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jaan1762.blogspot.com/feeds/5410466349560128426/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7527040749709927669&amp;postID=5410466349560128426' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/5410466349560128426'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/5410466349560128426'/><link rel='alternate' type='text/html' href='http://jaan1762.blogspot.com/2009/07/using-xslt-to-transform-xml-using.html' title='Using XSLT to Transform XML Using ASP.NET'/><author><name>Mansoor</name><uri>http://www.blogger.com/profile/00473621254256960630</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/_URzpGoyPbng/SnAVqbJofdI/AAAAAAAAC9w/UE4VhSN-TKM/s72-c/image001.gif' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7527040749709927669.post-8817669522250725941</id><published>2009-07-28T04:02:00.000-07:00</published><updated>2009-07-28T04:15:30.271-07:00</updated><title type='text'>Model-view-presenter</title><content type='html'>Model-view-presenter is a software pattern, considered a derivative of the model-view-controller.&lt;br /&gt;&lt;br /&gt;Model-view-presenter is a user interface design pattern engineered to facilitate automated unit testing and improve the separation of concerns in presentation logic.&lt;br /&gt;&lt;br /&gt;The model is an interface defining the data to be displayed or otherwise acted upon in the user interface.&lt;br /&gt;&lt;br /&gt;The view is an interface that displays data (the model) and routes user commands to the presenter to act upon that data.&lt;br /&gt;&lt;br /&gt;The presenter acts upon the model and the view. It retrieves data from repositories, persists it, manipulates it, and determines how it will be displayed in the view.&lt;br /&gt;&lt;br /&gt;Normally, the view implementation instantiates the concrete presenter object, providing a reference to itself. The following C# code demonstrates a simple view constructor, where ConcreteDomainPresenter implements the IDomainPresenter interface:&lt;br /&gt;&lt;br /&gt;public class DomainView: IDomainView&lt;br /&gt;{&lt;br /&gt;    private IDomainPresenter mDomainPresenter;&lt;br /&gt; &lt;br /&gt;    public DomainView()&lt;br /&gt;    {&lt;br /&gt;        this.mDomainPresenter = new ConcreteDomainPresenter(this);&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The degree of logic permitted in the view varies among different implementations.&lt;br /&gt;&lt;br /&gt;At one extreme, the view is entirely passive, forwarding all interaction operations to the presenter. In this formulation, when a user triggers an event method of the view, it does nothing but invoke a method of the presenter which has no parameters and no return value. The presenter then retrieves data from the view through methods defined by the view interface. Finally, the presenter then operates on the model and updates the view with the results of the operation.&lt;br /&gt;&lt;br /&gt;Other versions of model-view-presenter allow some latitude with respect to which class handles a particular interaction, event, or command. This is often more suitable for web-based architectures, where the view, which executes on a client's browser, may be the best place to handle a particular interaction or command.&lt;br /&gt;&lt;br /&gt;From a layering point of view, the presenter class might be considered as belonging to the application layer in a multilayered architectured object-oriented system with common layers but it can also be seen as a presenter layer of its own between the application layer and the user interface layer.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;In a .NET environment the same presenter class can be used for ASP.NET application and a Windows Forms application. The presenter gets and sets information from/to the view through an interface that in .NET can be implemented by both Windows Forms class and an ASPX page (the code-behind class can implement the view interface).&lt;br /&gt;&lt;br /&gt;Instead of manually implementing the pattern, one of the model-view-presenter frameworks may be used. Below are listed some of such frameworks under the .NET platform.&lt;br /&gt;&lt;br /&gt;[edit] &lt;blockquote&gt;&lt;em&gt;&lt;strong&gt;Model-view-presenter frameworks under .NET&lt;/strong&gt;&lt;/em&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;    * MVC# Framework&lt;br /&gt;    * NMVP Framework&lt;br /&gt;    * Web Client Software Factory&lt;a href="http://www.codeplex.com/websf" &gt;Description&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://4.bp.blogspot.com/_URzpGoyPbng/Sm7cSnjlq4I/AAAAAAAAC9I/05ZGRojV2j8/s1600-h/wcsf-Intro-scope.png"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 320px; height: 303px;" src="http://4.bp.blogspot.com/_URzpGoyPbng/Sm7cSnjlq4I/AAAAAAAAC9I/05ZGRojV2j8/s320/wcsf-Intro-scope.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5363466418658847618" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;As UI-creation technologies such as ASP.NET and Windows® Forms become more and more powerful, it's common practice to let the UI layer do more than it should. Without a clear separation of responsibilities, the UI layer can often become a catch-all for logic that really belongs in other layers of the application. One design pattern, the Model View Presenter (MVP) pattern, is especially well suited to solving this problem. In order to illustrate my point, I will build a display screen that follows the MVP pattern for customers in the Northwind database.&lt;br /&gt;Why is it bad to have lots of logic in the UI layer? The code in the UI layer of an application is very difficult to test without either running the application manually or maintaining ugly UI runner scripts that automate the execution of UI components. While this is a big problem in itself, an even bigger problem is the reams of code that are duplicated between common views in an application. It can often be hard to see good candidates for refactoring when the logic to perform a specific business function is copied among different pieces in the UI layer. The MVP design pattern makes it much easier to factor logic and code out of the UI layer for more streamlined, reusable code that's easier to test.&lt;br /&gt;Figure 1 shows the main layers that make up the sample application. Notice that there are separate packages for UI and presentation. You might have expected them to be the same, but actually the UI layer of a project should consist only of the various UI elements—forms and controls. In a Web Forms project this is typically a collection of ASP.NET Web Forms, user controls, and server controls. In Windows Forms, it is a collection of Windows Forms, user controls, and third-party libraries. This extra layer is what keeps the display and the logic separate. In the presentation layer you have the objects that actually implement the behavior for the UI—things like validation display, collection input from the UI, and so forth.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://1.bp.blogspot.com/_URzpGoyPbng/Sm7c0tqibVI/AAAAAAAAC9Y/LXD4naEr-fg/s1600-h/cc188690.fig01(en-us).gif"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 138px; height: 182px;" src="http://1.bp.blogspot.com/_URzpGoyPbng/Sm7c0tqibVI/AAAAAAAAC9Y/LXD4naEr-fg/s320/cc188690.fig01(en-us).gif" border="0" alt=""id="BLOGGER_PHOTO_ID_5363467004414160210" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Following the MVP&lt;br /&gt;&lt;br /&gt;As you can see in Figure 2, the UI for this project is pretty standard. When the page loads, the screen will display a dropdown box filled with all of the customers in the Northwind database. If you select a customer from the dropdown list, the page will update to display the information for that customer. By following the MVP design pattern you can factor behaviors out of the UI and into their own classes. Figure 3 shows a class diagram that indicates the association between the different classes that are involved. &lt;br /&gt;&lt;br /&gt;&lt;a href="http://4.bp.blogspot.com/_URzpGoyPbng/Sm7cj-KEwGI/AAAAAAAAC9Q/oiyMLwx3n-U/s1600-h/cc188690.fig02(en-us).gif"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 320px; height: 299px;" src="http://4.bp.blogspot.com/_URzpGoyPbng/Sm7cj-KEwGI/AAAAAAAAC9Q/oiyMLwx3n-U/s320/cc188690.fig02(en-us).gif" border="0" alt=""id="BLOGGER_PHOTO_ID_5363466716783624290" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;It's important to note that the presenter has no knowledge of the actual UI layer of the application. It knows it can talk to an interface, but it does not know or care what the implementation of that interface is. This promotes reuse of presenters between disparate UI technologies.&lt;br /&gt;I am going to use Test Driven Development (TDD) to build the functionality of the customer screen. Figure 4 shows the details for the first test I will use to describe the behavior I expect to observe on page load. TDD lets me focus on one problem at a time, write just enough code to make the test pass, and then carry on. In this test I am making use of a mock object framework called NMock2 that allows me to build mock implementations of interfaces&lt;br /&gt;&lt;br /&gt;[Test]&lt;br /&gt;public void ShouldLoadListOfCustomersOnInitialize()&lt;br /&gt;{&lt;br /&gt;    mockery = new Mockery();&lt;br /&gt;    ICustomerTask  mockCustomerTask = mockery.NewMock&lt;ICustomerTask&gt;();&lt;br /&gt;    IViewCustomerView  mockViewCustomerView = &lt;br /&gt;        mockery.NewMock&lt;IViewCustomerView&gt;();&lt;br /&gt;    ILookupList  mockCustomerLookupList = mockery.NewMock&lt;ILookupList&gt;();&lt;br /&gt;&lt;br /&gt;    ViewCustomerPresenter presenter = &lt;br /&gt;        new ViewCustomerPresenter(mockViewCustomerView,&lt;br /&gt;          mockCustomerTask);&lt;br /&gt;            &lt;br /&gt;    ILookupCollection mockLookupCollection = &lt;br /&gt;        mockery.NewMock&lt;ILookupCollection&gt;();            &lt;br /&gt;     &lt;br /&gt;    Expect.Once.On(mockCustomerTask).Method(&lt;br /&gt;        "GetCustomerList").Will(Return.Value(mockLookupCollection));&lt;br /&gt;    Expect.Once.On(mockViewCustomerView).GetProperty(&lt;br /&gt;        "CustomerList").Will(Return.Value(mockCustomerLookupList));&lt;br /&gt;    Expect.Once.On(mockLookupCollection).Method(&lt;br /&gt;        "BindTo").With(mockCustomerLookupList);&lt;br /&gt;                        &lt;br /&gt;    presenter.Initialize();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://1.bp.blogspot.com/_URzpGoyPbng/Sm7dKqV-tsI/AAAAAAAAC9g/Nif_FDhagdg/s1600-h/cc188690.fig03(en-us).gif"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 184px; height: 107px;" src="http://1.bp.blogspot.com/_URzpGoyPbng/Sm7dKqV-tsI/AAAAAAAAC9g/Nif_FDhagdg/s320/cc188690.fig03(en-us).gif" border="0" alt=""id="BLOGGER_PHOTO_ID_5363467381479749314" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Figure 3 MVP Class Diagram &lt;br /&gt;In my MVP implementation, I have decided that the presenter is going to take as a dependency the view it is going to work with. It is always good to create objects in a state that enables them to do their work immediately. In this application, the presentation layer is dependent on the service layer to actually invoke the domain functionality. Because of this requirement it also makes sense to construct a presenter with an interface to a service class that it can talk to. This ensures that once a presenter is constructed, it is ready to do all of the work it needs to do. I start off by creating two specific mocks: one for the service layer and one for the view that the presenter will work with.&lt;br /&gt;Why mocks? A rule of unit testing is to isolate the test as much as possible to focus on one specific object. In this test I am only interested in the expected behavior of the presenter. At this point I don't care about the actual implementation of the view interface or service interface; I trust the contracts defined by those interfaces and set the mocks to behave accordingly. This ensures that I focus my test solely around the behavior I expect of the presenter, not of any of its dependencies. The behavior I expect the presenter to exhibit after its initialize method is invoked is as follows.&lt;br /&gt;First, the presenter should make one call to the GetCustomerList method on the ICustomerTask service layer object (mocked in the test). Notice that with the use of NMock I can simulate behavior of the mock. In the case of the service layer, I want it to return a mock ILookupCollection to the presenter. Then, after the presenter retrieves the ILookupCollection from the service layer, it should invoke the collection's BindTo method and pass the method an implementation of an ILookupList. By using the NMockExpect.Once method I can be sure that the test will fail if the presenter does not call the method once and only once.&lt;br /&gt;After writing that test I am in a completely non-compilable state. I'm going to do the simplest thing possible to get the test to pass.&lt;br /&gt;&lt;br /&gt;Making the First Test Pass&lt;br /&gt;One of the advantages of writing the test first is that I now have a blueprint (the test) I can follow to get the test to compile and eventually pass. The first test has two interfaces that do not yet exist. These interfaces are the first prerequisites for getting the code to compile correctly. I'll start with the code for IViewCustomerView:&lt;br /&gt;&lt;br /&gt;public interface IViewCustomerView&lt;br /&gt;{&lt;br /&gt;    ILookupList CustomerList { get; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;This interface exposes one property that returns an ILookupList interface implementation. I don't yet have an ILookupList interface or even an implementer, for that matter. For the purpose of getting this test to pass I don't need an explicit implementor, so I can proceed to create the ILookupList interface:&lt;br /&gt;&lt;br /&gt;public interface ILookupList { }&lt;br /&gt;&lt;br /&gt;At this point the ILookupList interface looks pretty useless. My goal is to get the test to compile and pass, and these interfaces satisfy the test's requirements. It's time to shift focus to the object that I'm actually testing—the ViewCustomerPresenter. This class does not exist yet, but looking at the test you can glean two important facts about it: it has a constructor that requires both a view and service implementation as dependencies, and it has a void Initialize method. The code in Figure 5 shows how to compile the test.&lt;br /&gt; Figure 5 Compiling the Test&lt;br /&gt;&lt;br /&gt;public class ViewCustomerPresenter&lt;br /&gt;{&lt;br /&gt;    private readonly IViewCustomerView view;&lt;br /&gt;    private readonly ICustomerTask task;&lt;br /&gt;&lt;br /&gt;    public ViewCustomerPresenter(&lt;br /&gt;        IViewCustomerView view, ICustomerTask task)&lt;br /&gt;    {&lt;br /&gt;        this.view = view;&lt;br /&gt;        this.task = task;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    public void Initialize()&lt;br /&gt;    {&lt;br /&gt;        throw new NotImplementedException();&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Remember that a presenter requires all of its dependencies in order to do its work meaningfully; this is why the view and service are passed in. I have not implemented the initialize method so if I run the test I get a NotImplementedException.&lt;br /&gt;As mentioned already, I am not coding the presenter blindly; I already know, from looking at the test, what behavior the presenter should exhibit once the initialize method is called. The implementation of that behavior is as follows:&lt;br /&gt;&lt;br /&gt;public void Initialize()&lt;br /&gt;{            &lt;br /&gt;    task.GetCustomerList().BindTo(view.CustomerList);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;In the source code accompanying this article there is a complete implementation of the GetCustomerList method in the CustomerTask class (which implements the ICustomerTask interface). From the perspective of implementing and testing the presenter, though, I don't need to know whether there is a working implementation yet. It is this level of abstraction that allows me to plow through with the testing of the presenter class. The first test is now in a state that will compile and run. This proves that when the Initialize method on the presenter is called, it will interact with its dependencies in the manner that I specified in the test, and ultimately when the concrete implementations of those dependencies are injected into the presenter, I can be sure that the resulting view (the ASPX page) will be filled with a list of Customers.&lt;br /&gt;&lt;br /&gt;Filling the DropDownList&lt;br /&gt;So far I have been dealing mainly with interfaces to abstract the actual implementation details away, allowing the focus to be on the presenter. It is now time to build some of the plumbing that will ultimately allow the presenter to populate a list on a Web page in a way that can be tested. The key to making this work is the interaction that will occur in the BindTo method of the LookupCollection class. If you take a look at the implementation of the LookupCollection class in Figure 6, you will notice that it implements the ILookupCollection interface. The source code for the article has the accompanying tests that were used to build up the functionality of the LookupCollection class.&lt;br /&gt; Figure 6 The LookupCollection Class&lt;br /&gt;&lt;br /&gt;public class LookupCollection : ILookupCollection&lt;br /&gt;{&lt;br /&gt;    private IList&lt;ILookupDTO&gt; items;&lt;br /&gt;&lt;br /&gt;    public LookupCollection(IEnumerable&lt;ILookupDTO&gt; items)&lt;br /&gt;    {&lt;br /&gt;        this.items = new List&lt;ILookupDTO&gt;(items);&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    public int Count { get { return items.Count; } }&lt;br /&gt;&lt;br /&gt;    public void BindTo(ILookupList list)&lt;br /&gt;    {&lt;br /&gt;        list.Clear();&lt;br /&gt;        foreach (ILookupDTO dto in items) list.Add(dto);&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;The implementation of the BindTo method is of particular interest. Notice that in this method the collection iterates through its own private list of ILookupDTO implementations. An ILookupDTO is an interface that caters well to binding to comboboxes in the UI layer:&lt;br /&gt;&lt;br /&gt;public interface ILookupDTO&lt;br /&gt;{&lt;br /&gt;    string Value { get; }   &lt;br /&gt;    string Text { get; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Figure 7 shows the code that tests the lookup collection's BindTo method, which will help explain the expected interaction between a LookupCollection and an ILookupList. The last line is of particular interest. In this test I expect that before attempting to add items to the list, the LookupCollection will invoke the Clear method on the ILookupList implementation. I then expect Add to be called on an ILookupList 10 times, and as an argument to the Add method, the LookupCollection will pass in an object that implements the ILookupDTO interface. To make this actually work with a control that lives in a Web project (such as a dropdown listbox) you will need to create an implementation of ILookupList that knows how to work with controls in a Web project.&lt;br /&gt; Figure 7 A Test that Describes Behavior&lt;br /&gt;&lt;br /&gt;[Test]&lt;br /&gt;public void ShouldBeAbleToBindToLookupList()&lt;br /&gt;{&lt;br /&gt;    IList&lt;ILookupDTO&gt; dtos = new IList;&lt;br /&gt;    ILookupList mockLookupList = mockery.NewMock&lt;ILookupList&gt;();&lt;br /&gt;            &lt;br /&gt;    Expect.Once.On(mockLookupList).Method("Clear");&lt;br /&gt;            &lt;br /&gt;    for (int i = 0; i &lt; 10; i++)&lt;br /&gt;    {&lt;br /&gt;        SimpleLookupDTO dto = &lt;br /&gt;            new SimpleLookupDTO(i.ToString(),i.ToString());&lt;br /&gt;        dtos.Add(dto);&lt;br /&gt;        Expect.Once.On(mockLookupList).Method("Add").With(dto);&lt;br /&gt;    }&lt;br /&gt;            &lt;br /&gt;    new LookupCollection(dtos).BindTo(mockLookupList);            &lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;The source code that accompanies this article contains a project named MVP.Web.Controls. This project contains any Web-specific controls or classes that I chose to create to complete the solution. Why did I place the code in this project and not in the APP_CODE directory or the Web project itself? Testability. Anything that lives in the Web project is difficult to test directly without either running the application manually or automating the UI using some sort of testing robot. The MVP pattern allows me to think at a higher level of abstraction and test implementations of the core interfaces (ILookupList and ILookupCollection) without manually running the application. I am going to add a new class, a WebLookupList control, to the Web.Controls project. Figure 8 shows the first test for this class.&lt;br /&gt; Figure 8 First Test for WebLookupList Control&lt;br /&gt;&lt;br /&gt;[Test]&lt;br /&gt;public void ShouldAddItemToUnderlyingList()&lt;br /&gt;{&lt;br /&gt;    ListControl webList = new DropDownList();            &lt;br /&gt;    ILookupList list = new WebLookupList(webList);&lt;br /&gt;&lt;br /&gt;    SimpleLookupDTO dto = new SimpleLookupDTO("1","1");&lt;br /&gt;    list.Add(dto);&lt;br /&gt;    &lt;br /&gt;    Assert.AreEqual(1, webList.Items.Count);&lt;br /&gt;    Assert.AreEqual(dto.Value, webList.Items[0].Value);&lt;br /&gt;    Assert.AreEqual(dto.Text, webList.Items[0].Text);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Some things stand out in the test that is shown in Figure 8. The test project clearly needs a reference to the System.Web library so that it can instantiate DropDownList Web controls. Looking at the test, you should see that the WebLookupList class will implement the ILookupList interface. It is also going to take a ListControl as a dependency. Two of the most common ListControl implementations in the System.Web.UI.WebControls namespace are the DropDownList and the ListBox classes. A key feature of the test in Figure 8 is the fact that I am ensuring that a WebLookupList correctly updates the state of an actual Web ListControl to which it is delegating responsibility. Figure 9 shows the class diagram for the classes involved in the WebLookupList implementation. I can satisfy the requirements of the first test for the WebLookupList control with the code in Figure 10.&lt;br /&gt; Figure 10 WebLookupList Control&lt;br /&gt;&lt;br /&gt;public class WebLookupList : ILookupList&lt;br /&gt;{&lt;br /&gt;    private ListControl underlyingList;&lt;br /&gt;&lt;br /&gt;    public WebLookupList(ListControl underlyingList)&lt;br /&gt;    {&lt;br /&gt;        this.underlyingList = underlyingList;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    public void Add(ILookupDTO dto)&lt;br /&gt;    {&lt;br /&gt;        underlyingList.Items.Add(new ListItem(dto.Text, dto.Value));&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;a href="http://4.bp.blogspot.com/_URzpGoyPbng/Sm7dnLE7wwI/AAAAAAAAC9o/r2WS_5iILxU/s1600-h/cc188690.fig09(en-us).gif"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 167px; height: 81px;" src="http://4.bp.blogspot.com/_URzpGoyPbng/Sm7dnLE7wwI/AAAAAAAAC9o/r2WS_5iILxU/s320/cc188690.fig09(en-us).gif" border="0" alt=""id="BLOGGER_PHOTO_ID_5363467871302959874" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Figure 9 WebLookupList Class &lt;br /&gt;Remember, one of the keys to MVP is the separation of layers introduced by the creation of a view interface. The presenter doesn't know what implementation of a view, and respectively an ILookupList, it will be talking to; it just knows that it will be able to call any of the methods defined by those interfaces. Ultimately, the WebLookupList class is a class that wraps and delegates to an underlying ListControl (base class for some of the ListControls defined in the System.Web.UI.WebControls project). With that code now in place, I can compile and run the WebLookupList control test which should pass. I can add one more test for the WebLookupList that tests the actual behavior of the clear method:&lt;br /&gt;&lt;br /&gt;[Test]&lt;br /&gt;public void ShouldClearUnderlyingList()&lt;br /&gt;{&lt;br /&gt;    ListControl webList = new DropDownList();&lt;br /&gt;    ILookupList list = new WebLookupList(webList);&lt;br /&gt;    &lt;br /&gt;    webList.Items.Add(new ListItem("1", "1"));&lt;br /&gt;    &lt;br /&gt;    list.Clear();&lt;br /&gt;    &lt;br /&gt;    Assert.AreEqual(0, webList.Items.Count);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Again I am testing that the WebLookupList class will actually change the state of the underlying ListControl (DropDownList) when its own methods are invoked. The WebLookupList is now feature complete for the purposes of populating a DropDownList in a Web Form. It is now time for me to wire everything together and get the Web page's dropdown filled with a list of customers.&lt;br /&gt;&lt;br /&gt;Implementing the View Interface&lt;br /&gt;Because I am building a Web Forms front end, it makes sense that the implementer for the IViewCustomerView interface would be a Web Form or a user control. For the purpose of this column, I'll make it a Web Form. The general appearance of the page has already been created, as you saw in Figure 2. Now I need only to implement the view interface. Switching to the codebehind for the ViewCustomers.aspx page, I can add the following code, indicating that the page is required to implement the IViewCustomersView interface:&lt;br /&gt;&lt;br /&gt;public partial class ViewCustomers : Page,IViewCustomerView&lt;br /&gt;&lt;br /&gt;If you look at the code sample, you'll notice that the Web project and the Presentation are two completely different assemblies. Also, the Presentation project has no reference whatsoever to the Web.UI project, further maintaining the layer of separation. On the other hand, the Web.UI project has to have a reference to the Presentation project, as that is where the View interface and the presenter live.&lt;br /&gt;By choosing to implement the IViewCustomerView interface, our Web page now has a responsibility to implement any methods or properties defined by that interface. Currently there is only one property on the IViewCustomerView interface and that is a getter that returns any implementation of an ILookupList interface. I added a reference to the Web.Controls project so that I can instantiate a WebLookupListControl. I did this because the WebLookupListControl implements the ILookupList interface and it knows how to delegate to actual WebControls that live in ASP.NET. Taking a look at the ASPX for the ViewCustomer page, you will see that the list of customers is simply an asp:DropDownList control:&lt;br /&gt;&lt;br /&gt;&lt;td&gt;Customers:&lt;/td&gt;&lt;br /&gt;&lt;td&gt;&lt;asp:DropDownList id="customerDropDownList" AutoPostBack="true" &lt;br /&gt;        runat="server" Width="308px"&gt;&lt;/asp:DropDownList&gt;&lt;/td&gt;&lt;br /&gt;&lt;/tr&gt;&lt;br /&gt;&lt;br /&gt;With this already in place, I can quickly continue to implement the code required to satisfy the implementation of the IViewCustomerView interface:&lt;br /&gt;&lt;br /&gt;public ILookupList CustomerList&lt;br /&gt;{&lt;br /&gt;    get { return new WebLookupList(this.customerDropDownList);}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;I now need to invoke the Initialize method on the presenter that will trigger it to actually do some work. To do that, the view needs to be able to instantiate the presenter so that methods on it can be invoked. If you look back to the presenter, you'll remember that it requires both a view and a service that it will work with. The ICustomerTask interface represents an interface that lives in the service layer of the application. Service layers are typically responsible for orchestrating the interaction between domain objects and converting the results of those interactions into Data Transfer Objects (DTOs) that are then passed from the service layer to the presentation layer and then to the UI layer. There is a problem, however—I have stipulated that the presenter needs to be constructed with both the view and service implementations.&lt;br /&gt;The actual instantiation of the presenter is going to take place in the codebehind for the Web page. This is a problem, because the UI project has no reference to the service layer project. The presentation project does, however, have a reference to the service layer project. This allows me to solve the problem by adding an overloaded constructor to the ViewCustomerPresenterClass:&lt;br /&gt;&lt;br /&gt;public ViewCustomerPresenter(IViewCustomerView view) : &lt;br /&gt;    this(view, new CustomerTask()) {}&lt;br /&gt;&lt;br /&gt;This new constructor satisfies the presenter's requirement for implementations of both the view and the service, while also maintaining the separation of the UI layer from the service layer. It is now fairly trivial to finish off the code for the codebehind:&lt;br /&gt;&lt;br /&gt;protected override void OnInit(EventArgs e)&lt;br /&gt;{&lt;br /&gt;    base.OnInit(e);&lt;br /&gt;    presenter = new ViewCustomerPresenter(this);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;protected void Page_Load(object sender, EventArgs e)&lt;br /&gt;{        &lt;br /&gt;    if (!IsPostBack) presenter.Initialize();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Notice the key to the instantiation of the presenter is the fact that I am making use of the newly created overload for the constructor, and the Web Form passes itself in as an object that implements the view interface!&lt;br /&gt;With the code for the codebehind implemented, I can now build and run the application. The DropDownList on the Web page is now filled with a list of customer names without the need for any databinding code in the codebehind. Plus, scores of tests have been run on all the pieces that ultimately work together, ensuring that the presentation layer architecture will behave as expected.&lt;br /&gt;I'm going to wrap up my discussion of MVP by showing what is required to display customer information for a customer selected in the DropDownList. Once again, I start by writing a test that describes the behavior I hope to observe (see Figure 11).&lt;br /&gt; Figure 11 One Last Test&lt;br /&gt;&lt;br /&gt;[Test]&lt;br /&gt;public void ShouldDisplayCustomerDetails()&lt;br /&gt;{&lt;br /&gt;    SimpleLookupDTO lookupDTO = new SimpleLookupDTO("1","JPBOO");&lt;br /&gt;&lt;br /&gt;    CustomerDTO dto = new CustomerDTO("BLAH", "BLAHCOMPNAME",&lt;br /&gt;        "BLAHCONTACTNAME", "BLAHCONTACTTILE", "ADDRESS", "CITY", &lt;br /&gt;        "REGION", "POSTALCODE", Country.CANADA, "4444444", "4444444");&lt;br /&gt;&lt;br /&gt;    Expect.Once.On(mockViewCustomerView).GetProperty(&lt;br /&gt;        "CustomerList").Will(Return.Value(mockCustomerLookupList));&lt;br /&gt;    Expect.Once.On(mockCustomerLookupList).GetProperty(&lt;br /&gt;        "SelectedItem").Will(Return.Value(lookupDTO));&lt;br /&gt;    Expect.Once.On(mockCustomerTask).Method(&lt;br /&gt;        "GetDetailsForCustomer").With(1).Will(Return.Value(dto));&lt;br /&gt;    Expect.Once.On(mockViewCustomerView).SetProperty(&lt;br /&gt;        "CompanyName").To(dto.CompanyName);&lt;br /&gt;    Expect.Once.On(mockViewCustomerView).SetProperty(&lt;br /&gt;        "ContactName").To(dto.ContactName);&lt;br /&gt;    Expect.Once.On(mockViewCustomerView).SetProperty(&lt;br /&gt;        "ContactTitle").To(dto.ContactTitle);&lt;br /&gt;    Expect.Once.On(mockViewCustomerView).SetProperty(&lt;br /&gt;        "Address").To(dto.Address);&lt;br /&gt;    Expect.Once.On(mockViewCustomerView).SetProperty(&lt;br /&gt;        "City").To(dto.City);&lt;br /&gt;    Expect.Once.On(mockViewCustomerView).SetProperty(&lt;br /&gt;        "Region").To(dto.Region);&lt;br /&gt;    Expect.Once.On(mockViewCustomerView).SetProperty(&lt;br /&gt;        "PostalCode").To(dto.PostalCode);&lt;br /&gt;    Expect.Once.On(mockViewCustomerView).SetProperty(&lt;br /&gt;        "Country").To(dto.CountryOfResidence.Name);&lt;br /&gt;    Expect.Once.On(mockViewCustomerView).SetProperty(&lt;br /&gt;        "Phone").To(dto.Phone);&lt;br /&gt;    Expect.Once.On(mockViewCustomerView).SetProperty("Fax").To(dto.Fax);&lt;br /&gt;&lt;br /&gt;    presenter.DisplayCustomerDetails();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;As before, I am taking advantage of the NMock library to create mocks of the task and view interfaces. This particular test verifies the behavior of the presenter by asking the service layer for a DTO representing a particular customer. Once the presenter retrieves the DTO from the service layer, it will update properties on the view directly, thus eliminating the need for the view to have any knowledge of how to correctly display the information from the object. For brevity I am not going to discuss the implementation of the SelectedItem property on the WebLookupList control; instead I will leave it to you to examine the source code to see the implementation details. What this test really demonstrates is the interaction that occurs between the presenter and the view once the presenter retrieves a CustomerDTO from the service layer. If I attempt to run the test now, I will be in a big failure state as a lot of the properties don't yet exist on the view interface. So I'll go ahead and add the necessary members to the IViewCustomerView interface, as you see in Figure 12.&lt;br /&gt; Figure 12 Completing the IVewCustomerView Interface&lt;br /&gt;&lt;br /&gt;public interface IViewCustomerView&lt;br /&gt;{&lt;br /&gt;    ILookupList CustomerList{get;}&lt;br /&gt;    string CompanyName{set;}&lt;br /&gt;    string ContactName{set;}&lt;br /&gt;    string ContactTitle{set;}&lt;br /&gt;    string Address{set;}&lt;br /&gt;    string City{set;}&lt;br /&gt;    string Region{set;}&lt;br /&gt;    string PostalCode{set;}&lt;br /&gt;    string Country{set;}&lt;br /&gt;    string Phone{set;}   &lt;br /&gt;    string Fax{set;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Immediately after adding these interface members, my Web Form complains because it is no longer fulfilling the contract of the interface, so I have to go back to the codebehind for my Web Form and implement the remaining members. As stated before, the entire markup for the Web page has already been created, as have the table cells which have been marked with the "runat=server" attribute and are named according to the information that should be displayed in them. This makes the resulting code to implement the interface members very trivial:&lt;br /&gt;&lt;br /&gt;public string CompanyName&lt;br /&gt;{&lt;br /&gt;    set { this.companyNameLabel.InnerText = value; }&lt;br /&gt;}&lt;br /&gt;public string ContactName&lt;br /&gt;{&lt;br /&gt;    set { this.contactNameLabel.InnerText = value; }&lt;br /&gt;}&lt;br /&gt;...&lt;br /&gt;&lt;br /&gt;With the setter properties implemented, there is just one thing left to do. I need a way to tell the presenter to display the information for the selected customer. Looking back at the test, you can see that the implementation of this behavior will live in the DisplayCustomerDetails method on the presenter. This method will not, however, take any arguments. When invoked, the presenter will turn back around to the view, pull from it any information it needs (which it will retrieve by using the ILookupList), and then use that information to retrieve the details about the customer in question. All that I need to do from a UI perspective is set the AutoPostBack property of the DropDownList to true, and I also need to add the following event handler hookup code to the OnInit method of the page:&lt;br /&gt;&lt;br /&gt;protected override void OnInit(EventArgs e)&lt;br /&gt;{&lt;br /&gt;    base.OnInit(e);&lt;br /&gt;    presenter = new ViewCustomerPresenter(this);&lt;br /&gt;    this.customerDropDownList.SelectedIndexChanged += delegate&lt;br /&gt;    {&lt;br /&gt;        presenter.DisplayCustomerDetails();&lt;br /&gt;    };&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;This event handler ensures that whenever a new customer is selected in the dropdown, the view will ask the presenter to display the details for that customer.&lt;br /&gt;It is important to note that this is typical behavior. When a view asks a presenter to do something, it asks without giving any specific details, and it is up to the presenter to return to the view and get any information it needs using the view interface. Figure 13 shows the code required to implement the required behavior in the presenter.&lt;br /&gt; Figure 13 Completing the Presenter&lt;br /&gt;&lt;br /&gt;public void DisplayCustomerDetails()&lt;br /&gt;{&lt;br /&gt;    int? customerId = SelectedCustomerId;&lt;br /&gt;    if (customerId.HasValue)&lt;br /&gt;    {&lt;br /&gt;        CustomerDTO customer = &lt;br /&gt;            task.GetDetailsForCustomer(customerId.Value);&lt;br /&gt;        UpdateViewFrom(customer);&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;    &lt;br /&gt;private int? SelectedCustomerId&lt;br /&gt;{&lt;br /&gt;    get&lt;br /&gt;    {&lt;br /&gt;        string selectedId = view.CustomerList.SelectedItem.Value;&lt;br /&gt;            &lt;br /&gt;        if (String.IsNullOrEmpty(selectedId)) return null;&lt;br /&gt;&lt;br /&gt;        int? id = null;&lt;br /&gt;&lt;br /&gt;        try&lt;br /&gt;        {&lt;br /&gt;            id = int.Parse(selectedId.Trim());&lt;br /&gt;        }&lt;br /&gt;        catch (FormatException) {}&lt;br /&gt;&lt;br /&gt;        return id;&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;private void UpdateViewFrom(CustomerDTO customer)&lt;br /&gt;{&lt;br /&gt;    view.CompanyName = customer.CompanyName;&lt;br /&gt;    view.ContactName = customer.ContactName;&lt;br /&gt;    view.ContactTitle = customer.ContactTitle;&lt;br /&gt;    view.Address = customer.Address;&lt;br /&gt;    view.City = customer.City;&lt;br /&gt;    view.Region = customer.Region;&lt;br /&gt;    view.Country = customer.CountryOfResidence.Name;&lt;br /&gt;    view.Phone = customer.Phone;&lt;br /&gt;    view.Fax = customer.Fax;&lt;br /&gt;    view.PostalCode = customer.PostalCode;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Hopefully you now see the value of adding the presenter layer. It is the presenter's responsibility to attempt to retrieve an ID for a customer for whom it needs to display details. This is code that would normally have been performed in the codebehind, but is now inside a class that I can fully test and exercise outside of any presentation-layer technology.&lt;br /&gt;In the event that the presenter can retrieve a valid customer ID from the view, it turns to the service layer and asks for a DTO that represents the details for the customer. Once the presenter has the DTO in hand, it updates the view with the information contained in the DTO. A key point to note is the simplicity of the view interface; aside from the ILookupList interface, the view interface consists entirely of string DataTypes. It is ultimately the responsibility of the presenter to correctly convert and format the information retrieved from the DTO so that it can actually be handed to the view as a string. Although not demonstrated in this example, the presenter would also be responsible for reading information from the view and converting it to the necessary types that the service layer would expect.&lt;br /&gt;With all the pieces in place I can now run the application. When the page first loads, I get a list of customers and the first customer appears (not selected) in the DropDownList. If I select a customer, a postback occurs, the interaction between the view and the presenter takes place, and the Web page is updated with the related customer information.&lt;br /&gt;&lt;br /&gt;What's Next?&lt;br /&gt;The Model View Presenter design pattern is really just a fresh take on the Model View Controller pattern that many developers are already familiar with; the key distinction is that MVP truly separates the UI from the domain/service layer of the application. Although this example was fairly simple from a requirements perspective, it should help you abstract the interaction between a UI and the other layers of your applications. Also, you should now see ways that you can use these layers of indirection to make your application more testable with automation. As you delve deeper into the MVP pattern, I hope you'll find other ways to pull as much formatting and conditional logic out of your codebehinds and place them into testable view/presenter interaction models.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7527040749709927669-8817669522250725941?l=jaan1762.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jaan1762.blogspot.com/feeds/8817669522250725941/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7527040749709927669&amp;postID=8817669522250725941' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/8817669522250725941'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/8817669522250725941'/><link rel='alternate' type='text/html' href='http://jaan1762.blogspot.com/2009/07/model-view-presenter.html' title='Model-view-presenter'/><author><name>Mansoor</name><uri>http://www.blogger.com/profile/00473621254256960630</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/_URzpGoyPbng/Sm7cSnjlq4I/AAAAAAAAC9I/05ZGRojV2j8/s72-c/wcsf-Intro-scope.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7527040749709927669.post-3044599851431733141</id><published>2009-07-20T01:41:00.000-07:00</published><updated>2009-07-20T01:43:29.185-07:00</updated><title type='text'>Title Time Script</title><content type='html'>This script displays the live time in the title of your surfer's browser! It does not erase the default title of the document, but rather, simply appends the time to it. Like the Title date script, the script manipulates the IE 4+ and NS6+ exclusive document.title property, so it's only visible to IE 4+/NS6+ browsers.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;script language="JavaScript" type="text/javascript"&amp;gt;&lt;br /&gt;   &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;var scroller;&lt;br /&gt;var ampm;&lt;br /&gt;var actualtitle=document.title+" "&lt;br /&gt;function antiMilitaryTime()&lt;br /&gt;{&lt;br /&gt;if (hr == "12"){&lt;br /&gt;ampm="P.M."&lt;br /&gt;}&lt;br /&gt;else if (hr == "13"){&lt;br /&gt;hr="1"&lt;br /&gt;ampm="P.M."&lt;br /&gt;}&lt;br /&gt;else if (hr == "14"){&lt;br /&gt;hr="2"&lt;br /&gt;ampm="P.M."&lt;br /&gt;}&lt;br /&gt;else if (hr == "15"){&lt;br /&gt;hr ="3"&lt;br /&gt;ampm="P.M."&lt;br /&gt;}&lt;br /&gt;else if (hr == "16"){&lt;br /&gt;hr = "4"&lt;br /&gt;ampm="P.M."&lt;br /&gt;}&lt;br /&gt;else if (hr == "17"){&lt;br /&gt;hr = "5"&lt;br /&gt;ampm="P.M."&lt;br /&gt;}&lt;br /&gt;else if (hr == "18"){&lt;br /&gt;hr = "6"&lt;br /&gt;ampm="P.M."&lt;br /&gt;}&lt;br /&gt;else if (hr == "19"){&lt;br /&gt;hr = "7"&lt;br /&gt;ampm="P.M."&lt;br /&gt;}&lt;br /&gt;else if (hr == "20"){&lt;br /&gt;hr = "8"&lt;br /&gt;ampm="P.M."&lt;br /&gt;}&lt;br /&gt;else if (hr == "21"){&lt;br /&gt;hr = "9"&lt;br /&gt;ampm="P.M."&lt;br /&gt;}&lt;br /&gt;else if (hr == "22"){&lt;br /&gt;hr = "10"&lt;br /&gt;ampm="P.M."&lt;br /&gt;}&lt;br /&gt;else if (hr == "23"){&lt;br /&gt;hr = "11"&lt;br /&gt;ampm="P.M."&lt;br /&gt;}&lt;br /&gt;else if (hr == "24"){&lt;br /&gt;hr = "12"&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;function addZero(){&lt;br /&gt;if (min &lt;= "9"){&lt;br /&gt;min = "0"+min&lt;br /&gt;}&lt;br /&gt;if (sec&lt;= "9"){&lt;br /&gt;sec = "0"+sec&lt;br /&gt;}&lt;br /&gt;if (hr &lt;=9){&lt;br /&gt;hr = "0"+hr&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;function time(){&lt;br /&gt;dt=new Date()&lt;br /&gt;sec=dt.getSeconds()&lt;br /&gt;hr=dt.getHours()&lt;br /&gt;ampm="A.M."&lt;br /&gt;min=dt.getMinutes()&lt;br /&gt;}&lt;br /&gt;function scroll() {&lt;br /&gt;time()&lt;br /&gt;antiMilitaryTime()&lt;br /&gt;addZero()&lt;br /&gt;var scroller="TIME: "+hr+":"+min+":"+sec+" "+ampm&lt;br /&gt;var timeout=setTimeout("scroll()", 1000)&lt;br /&gt;  document.title=actualtitle+scroller&lt;br /&gt;  }&lt;br /&gt;if (document.all||document.getElementById)&lt;br /&gt;scroll()&lt;br /&gt;&lt;br /&gt;&amp;lt;/script&amp;rt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7527040749709927669-3044599851431733141?l=jaan1762.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jaan1762.blogspot.com/feeds/3044599851431733141/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7527040749709927669&amp;postID=3044599851431733141' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/3044599851431733141'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/3044599851431733141'/><link rel='alternate' type='text/html' href='http://jaan1762.blogspot.com/2009/07/title-time-script.html' title='Title Time Script'/><author><name>Mansoor</name><uri>http://www.blogger.com/profile/00473621254256960630</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-7527040749709927669.post-7583923776885075163</id><published>2009-07-16T21:29:00.000-07:00</published><updated>2009-07-16T21:33:47.481-07:00</updated><title type='text'>How to find the current IIS version installed in your system</title><content type='html'>Hi All&lt;br /&gt;&lt;br /&gt;I was wondering the other day where i could find my IIS Version number and once when i was looking at the documentation provided then i noticed that the simplest way to find out the version number is by simply typing the URL&lt;br /&gt;&lt;br /&gt;http://localhost/iisHelp/iis/misc/default.asp&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Thats it...&lt;br /&gt;&lt;br /&gt;Regards&lt;br /&gt;Mansoor Ali&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7527040749709927669-7583923776885075163?l=jaan1762.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jaan1762.blogspot.com/feeds/7583923776885075163/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7527040749709927669&amp;postID=7583923776885075163' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/7583923776885075163'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/7583923776885075163'/><link rel='alternate' type='text/html' href='http://jaan1762.blogspot.com/2009/07/how-to-find-current-iis-version.html' title='How to find the current IIS version installed in your system'/><author><name>Mansoor</name><uri>http://www.blogger.com/profile/00473621254256960630</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-7527040749709927669.post-3700510155024405145</id><published>2009-07-07T03:50:00.000-07:00</published><updated>2009-07-07T03:51:26.260-07:00</updated><title type='text'>Building an N-Tier Application in .NET</title><content type='html'>Building an N-Tier Application in .NET&lt;br /&gt;Upgrading to Microsoft .NET&lt;br /&gt;Paul D. Sheriff&lt;br /&gt;PDSA, Inc.&lt;br /&gt;February 2002&lt;br /&gt;Summary: After reviewing the types of n-tier applications, you'll learn how to create a typed dataset that can return data from a Web service and consume a Web service from a Windows application. (17 printed pages)&lt;br /&gt;Objectives&lt;br /&gt;· Review the types of n-tier applications. &lt;br /&gt;· Review the goals of a good n-tier application. &lt;br /&gt;· Learn how to create a typed dataset that can return data from a Web service. &lt;br /&gt;· Consume a Web service from a Windows application. &lt;br /&gt;Assumptions&lt;br /&gt;· You have developed an n-tier application. &lt;br /&gt;· You are very familiar with classes. &lt;br /&gt;· You have used the OleDbDataAdapter and DataSets. &lt;br /&gt;· You know how to create a Typed DataSet. &lt;br /&gt;· You can create a form in Microsoft® Visual Studio® .NET. &lt;br /&gt;· You are familiar with relational databases and Microsoft ADO.NET. &lt;br /&gt;· You have created a Web service in Microsoft® .NET. &lt;br /&gt;Contents&lt;br /&gt;Types of N-Tier Applications&lt;br /&gt;Creating an N-Tier Application&lt;br /&gt;What's Different from Visual Basic 6.0?&lt;br /&gt;Summary&lt;br /&gt;Types of N-Tier Applications&lt;br /&gt;There are many types of n-tier applications that programmers have developed over the years. Since classes were first introduced in Microsoft Visual Basic® 4.0, many programmers have attempted to come up with the definitive method of creating n-tier applications. Although all of them are clever, there has never been a consensus on how every n-tier application should be constructed. As many programmers as there are in the world, there seem to be that many methods of developing n-tier applications. Below is a list of some of the possible ways. &lt;br /&gt;· Create a component with one class that returns a disconnected ADO recordset for any SQL statement sent to it. All updates are performed in the ADO recordset, then passed back to the component for batch updating. &lt;br /&gt;· Create a component that has many classes based around business processes. All data for the business process is passed to this component. The component will update the appropriate tables from the data supplied. Another component would be used to return views of data needed to support the user interface for a business process. &lt;br /&gt;· Create one class per table using ADO embedded into the class. This is a logical n-tier model where both the EXE and the classes (in a DLL) are installed on the client machine. &lt;br /&gt;· Create one class per table using ADO on the client side. This client-side class passes SQL through DCOM to a server-side Data Class running under MTS that returns a disconnected ADO recordset to the client side. &lt;br /&gt;· Create two classes per table, one with properties that can be set from the client side EXE. These properties are then bundled into an XML string and passed across DCOM to a server-side class running under MTS. The XML contains instructions on how to gather or modify the data, and a disconnected ADO recordset is returned back to the client-side class. &lt;br /&gt;· Create one class per table using a DOMDocument object on the client side to process all the data. The client-side class bundles up properties into an XML string that is then sent to a server-side data class. The server side extracts the instructions (the SQL) from the XML and performs the appropriate action on the database server. The server-side class then returns XML to the client-side class to inform the client what happened on the database. In this scenario, there is only one data class for all tables. &lt;br /&gt;· Create one server-side class for all tables. The client side passes SQL to the server-side class and it returns a disconnected ADO recordset. All forms then use these ADO recordsets for processing data. &lt;br /&gt;· Create a client-side EXE that sends a SOAP request to a Web server for XML data. XML is processed on the client side using the DOMDocument object. &lt;br /&gt;As you can see, there are many different methods for creating an n-tier application. They all work, and they each have advantages and disadvantages. The goal of this document is not to dispute any of these, nor to look at the advantages and disadvantages, but to simply present a way to create n-tier data classes within Visual Basic .NET.&lt;br /&gt;In this document, you will learn to create a Typed DataSet using built-in tools in Visual Studio .NET. A Typed DataSet is inherited from the DataSet class in .NET. It also provides you with properties that match up to each column in the base table. You use a standard data adapter object to fill up the DataSet from the data source. The wizard that generates this Typed DataSet reads the schema information from the data source and maps these data types to each of the columns. This is why this is called a Typed DataSet.&lt;br /&gt;A Typed DataSet will help you speed up your development process in a few ways. First, you no longer have to remember column names; you will have a Microsoft® InteliSense® list after creating an object from this DataSet class. This avoids run-time errors as column names can be checked at compile time. Second, you no longer have to see SQL in your front-end client application. All of the SQL is buried in the data adapter. By putting these Typed DataSets into a separate component, you are able to reuse these classes from multiple projects.&lt;br /&gt;Goals of a Good N-Tier Application&lt;br /&gt;N-tier design came about as a result of the failings of the client/server model. There are many goals that an n-tier application design should achieve. Here are some of them. &lt;br /&gt;· If you change the underlying data access methods, the client-side code should not have to change. &lt;br /&gt;· All data access routines should be exposed as objects instead of function calls. As an example, it is much easier to use ADO than the ODBC API calls. &lt;br /&gt;· SQL should be eliminated from the client-side code. The client code should just be concerned with methods and properties. &lt;br /&gt;· Table and column names should be eliminated from the client-side code. Typed datasets can present table and column names as properties, providing an IntelliSense list, as opposed to having to type in a string name. This means at compile time, checks can be made for data types and names of columns. &lt;br /&gt;· The client code should not care where the data comes from. It should just care that it can retrieve and modify the data in some object and the object will take care of the details. &lt;br /&gt;· The coding you need to do on the client side should be simplified. Instead of using many functions, your application should be able to use objects with properties and methods. &lt;br /&gt;· It becomes easier to create and use the classes than the function calls. &lt;br /&gt;· It becomes easier to add functionality to your applications, and change the functionality, without breaking the client-side code. &lt;br /&gt;Disadvantages to N-Tier&lt;br /&gt;Although there are many advantages to a good n-tier application, there are some disadvantages as well. &lt;br /&gt;· You end up creating a lot of classes. This can lead to maintenance issues and could even be a performance issue as it does take time to create a new class at run time. &lt;br /&gt;· N-tier does not work well when you do not know the structure of the tables from which you will be retrieving data. For example, in a Query By Example (QBE) application where the user may put together several columns from several tables, there is no way to generate classes on the fly to accomplish this. &lt;br /&gt;· Creating reports is not something that lends itself to a good n-tier design, as report writers do not use classes to get at data. &lt;br /&gt;In the end, the advantages of a good n-tier design will far outweigh the disadvantages. In the cases where you simply cannot use n-tier, go ahead and use the typical client/server method of development. There is certainly nothing wrong with mixing both of these paradigms in the same application if appropriate.&lt;br /&gt;Creating an N-Tier Application&lt;br /&gt;When you talk about a true distributed n-tier type of application, you are talking about separating the components of the different tiers on different machines as well as in separate components. Figure 1 shows a typical example of an n-tier application with multiple components on each machine.&lt;br /&gt; &lt;br /&gt;Figure 1. A distributed n-tier application has three physical tiers with one or more logical tiers on each machine&lt;br /&gt;There are many different ways you could configure an n-tier application. For example, the business rules may go on a separate machine and you might use .NET Remoting to talk from the client application to the business rule tier as shown in Figure 2.&lt;br /&gt; &lt;br /&gt;Figure 2. Business rules can be placed on a separate machine to facilitate ease of maintenance&lt;br /&gt;You may also have a data input validation rule component on the client to check simple rules such as required fields and formatting. These are rules that you do not want to make a trip across the network just to check. You may then also add a business rule layer on the same tier as the data layer component to check complicated business rules that compare the data from one table to another.&lt;br /&gt;These are just a few different configurations that you may utilize. Of course, you could come up with something unique that fits your specific situation. Regardless of how you structure the physical implementation of the components, make sure that the logical structure of the program is broken up into components as shown in the above figures.&lt;br /&gt;Creating the User Interface&lt;br /&gt;In the example you see in Figure 1, the client tier consists of a Windows application and a business rule component. The Windows application makes all requests for data, and all updates through the business rule component. This isolates the location of the data from the Windows application. The advantage of doing this is if you change where the data comes from, you do not need to make any changes to the client application, only to the business rule component.&lt;br /&gt; &lt;br /&gt;Figure 3. This is a DataGrid that has been bound to the return result from the business rules component&lt;br /&gt;Perform the following steps to build a simple Windows client application that will display employee information in a DataGrid control on a Windows Form. &lt;br /&gt;1. Create a new Windows Application project named EmpClient. &lt;br /&gt;2. Rename the default form (Form1.vb) file name to frmEmpInfo.vb. &lt;br /&gt;3. Set the form's Name property to EmpInfo. &lt;br /&gt;4. Set the form's Text property to Employee Information. &lt;br /&gt;5. Set the Startup Object in the Project Properties to EmpInfo. &lt;br /&gt;6. Drag a DataGrid onto this form. Set the Name property to grdEmps. &lt;br /&gt;7. Add a Button control to this form. Set the Name property to btnUpdate. Set the Text property to Update. &lt;br /&gt;At this point, the user interface for your employee form is complete. Now it is time to start building the components so you can retrieve the data to populate this DataGrid.&lt;br /&gt;Creating the Data Tier&lt;br /&gt;The data tier is responsible for connecting to your data source, building a typed data set, and returning that data set from a method within this component.&lt;br /&gt;Follow these steps to build a data tier component. &lt;br /&gt;1. In the Solution Explorer window, right-click the solution named EmpClient. &lt;br /&gt;2. On the shortcut menu, click Add, and then click New Project. &lt;br /&gt;3. Choose the Class Library template. Set the name of this class library to EmpData. &lt;br /&gt;4. Delete the class file named Class1.vb from the project. &lt;br /&gt;5. To add a new component to the project, on the Project menu, click Add Component. Set the name of the component to clsEmp.vb. &lt;br /&gt;6. View the code for this component and change the name of the class from clsEmp to Employees. &lt;br /&gt;7. In the design view, click and drag a SqlDataAdapter control from the Data tab of the toolbox onto the design surface of this component. &lt;br /&gt;8. Go through the steps of this wizard to connect to your SQL Server, pointing to the Northwind database on that server. Select all rows and columns from the Employee table within this database. &lt;br /&gt;9. Rename the SqlConnection object from SqlConnection1 to cnNorthwind. Rename the SqlDataAdapter object from SqlDataAdapter1 to daEmps. &lt;br /&gt;10. Click the daEmps object and, on the Data menu, click Generate DataSet. Set the name of the New DataSet to dsEmps. &lt;br /&gt;At this point, you have a component with some data access objects on it. The reason to use a component instead of a regular class is that you need the ability to drag a Connection and DataAdapter object onto a design surface. A component will let you do this; a regular class will not. Of course, you could always just create your own data adapter and connection objects in code, but this way is much easier.&lt;br /&gt;All that is left to do after adding this component is to add a couple of methods to the component. The first method, named GetData, returns a reference to the typed dataset filled with employee data. The second method, named Update, accepts a typed dataset as a parameter and submits the changes in this dataset to the backend data source.&lt;br /&gt;The GetData Method in the Data Component&lt;br /&gt;This method is responsible for declaring an object of the type dsEmps. Remember that this is the name of the typed dataset that you generated. This file is represented in the Solution Explorer window as dsEmps.xsd. This is the schema definition file for the Employees table from the Northwind database. The code behind this xsd file is the generated typed dataset named dsEmps.&lt;br /&gt;Public Function GetData() As dsEmps&lt;br /&gt;    Dim dsData As dsEmps&lt;br /&gt;&lt;br /&gt;    Try&lt;br /&gt;        dsData = New dsEmps()&lt;br /&gt;&lt;br /&gt;        daEmps.Fill(dsData)&lt;br /&gt;&lt;br /&gt;        Return dsData&lt;br /&gt;    Catch&lt;br /&gt;        Throw&lt;br /&gt;    End Try&lt;br /&gt;End Function&lt;br /&gt;After creating the instance of the dsEmps object, you will use the SqlDataAdapter object to fill the dsEmps object with data from the Employees table. This typed dataset is then returned from the method to be consumed by some other component. You will learn how to consume this dataset in the next section.&lt;br /&gt;The Update Method in the Data Component&lt;br /&gt;The Update method accepts a typed dataset from a calling program, and performs the Update method on the SqlDataAdapter object to send any changes in the dataset to the Employees table. It also returns this same dataset back to the calling program so any updated fields, like TimeStamps or Identity fields, can be merged back into the dataset in the calling program.&lt;br /&gt;Public Function Update(ByVal dsData As dsEmps) As dsEmps&lt;br /&gt;    Try&lt;br /&gt;        ' Update Data In Table&lt;br /&gt;        daEmps.Update(dsData)&lt;br /&gt;&lt;br /&gt;    Catch&lt;br /&gt;        ' Throw any exceptions back to client&lt;br /&gt;        Throw&lt;br /&gt;&lt;br /&gt;    End Try&lt;br /&gt;&lt;br /&gt;    Return dsData&lt;br /&gt;End Function&lt;br /&gt;Notice the use of the structured exception handling in both of these methods. If any errors are encountered, the exceptions are simply thrown back to the calling component for handling. No errors will be handled in these components.&lt;br /&gt;Creating the Web Service&lt;br /&gt;In Figure 1, you can see that the Data Tier is called from the Web service. You will now create the Web service project that calls the EmpData component that you just created. &lt;br /&gt;1. In the Solution Explorer window, click the solution named EmpClient. &lt;br /&gt;2. Right-click and on the shortcut menu, click Add, and then click New Project. &lt;br /&gt;3. Select the ASP.NET Web service template and set the Name of this project to EmpWS. &lt;br /&gt;4. Delete the Service1.asmx file from the project. &lt;br /&gt;5. To add a new Web service file, on the Project menu, click Add Web service. Set the name of this new Web service to Employees.asmx. &lt;br /&gt;6. Click the EmpWS project and add a reference to the EmpData project. &lt;br /&gt;Now that you have created the Web service named Employees, you can create the two methods that will consume the dataset from the data component. You name these two methods the same name as the methods in the data component for consistency.&lt;br /&gt;The GetData Method in the Web Service&lt;br /&gt;The GetData method in the Web service creates a reference to the EmpData.Employees class. Once you have created this new object, invoke the GetData method on this object and return the dataset from this Web method.&lt;br /&gt;&lt;WebMethod()&gt; Public Function GetData() _&lt;br /&gt; As EmpData.dsEmps&lt;br /&gt;    Dim dc As EmpData.Employees&lt;br /&gt;&lt;br /&gt;    Try&lt;br /&gt;        dc = New EmpData.Employees()&lt;br /&gt;&lt;br /&gt;        Return dc.GetData&lt;br /&gt;&lt;br /&gt;    Catch&lt;br /&gt;        ' Throw any exceptions back to client&lt;br /&gt;        Throw&lt;br /&gt;&lt;br /&gt;    End Try&lt;br /&gt;End Function&lt;br /&gt;Remember from the diagram in Figure 1 that the business rule component retrieves the data from this Web service. The reason you don't just create the typed data set in the Web service project is that you want the flexibility to use the data component directly from a Windows application if you are not going to be doing a true distributed application. So just by eliminating the Web service project, you can change the code in the business rule layer to talk directly to the data component instead of the Web service, and you do not have to change any other code.&lt;br /&gt;The Update Method&lt;br /&gt;The Update method in this Web service project simply passes the dataset that was passed in as an argument directly to the data component's Update method.&lt;br /&gt;&lt;WebMethod()&gt; Public Function Update( _&lt;br /&gt; ByVal dsData As EmpData.dsEmps) As EmpData.dsEmps&lt;br /&gt;    Dim dc As EmpData.Employees&lt;br /&gt;&lt;br /&gt;    Try&lt;br /&gt;        dc = New EmpData.Employees()&lt;br /&gt;&lt;br /&gt;        dc.Update(dsData)&lt;br /&gt;&lt;br /&gt;    Catch&lt;br /&gt;        ' Throw any exceptions back to client&lt;br /&gt;        Throw&lt;br /&gt;&lt;br /&gt;    End Try&lt;br /&gt;&lt;br /&gt;    Return dsData&lt;br /&gt;End Function&lt;br /&gt;Creating the Business Rules Component&lt;br /&gt;Now it is time to bring all of the projects together by hooking up the business rule component to the Windows application, and having the business rule component make the call to the Web service to retrieve the data.&lt;br /&gt;Follow the steps below to create the component that acts as the interface between the Windows application and the data tier. &lt;br /&gt;1. In the Solution Explorer window, right-click the EmpClient solution, and on the shortcut menu, click Add, and then click New Project. &lt;br /&gt;2. Select the Class Library template and set the Name of this new project to EmpBusRule. &lt;br /&gt;3. Rename the Class1.vb file to clsEmployee.vb. &lt;br /&gt;4. Change the name of the Public Class from Class1 to Employees. &lt;br /&gt;5. To ensure that the solution compiles and to also build the Web service files needed for referencing, on the Build menu, click Build Solution. &lt;br /&gt;6. Click the EmpBusRule project and add a Web Reference to the EmpWS.vsdisco file. &lt;br /&gt;Note   If you cannot set a reference to the vsdisco file, set a reference to the Employees.asmx file instead.&lt;br /&gt;7. Expand the Web References folder in this project and rename the LocalHost item (or whatever the name of your Web Server is) to EmpService. &lt;br /&gt;The GetData Method in the Business Rules Component&lt;br /&gt;The GetData method in the business rule component simply accesses the Web service component to request the data from the data tier. Although this seems to be an indirect approach to getting the data, it allows us to create a truly distributed approach to our n-tier application.&lt;br /&gt;Public Function GetData() As EmpService.dsEmps&lt;br /&gt;    Dim ws As EmpService.Employees&lt;br /&gt;&lt;br /&gt;    Try&lt;br /&gt;        ws = New EmpService.Employees()&lt;br /&gt;&lt;br /&gt;        Return ws.GetData&lt;br /&gt;&lt;br /&gt;    Catch&lt;br /&gt;        Throw&lt;br /&gt;&lt;br /&gt;    End Try&lt;br /&gt;End Function&lt;br /&gt;The Update Method in the Business Rules Component&lt;br /&gt;The Update method is responsible for taking the dataset of changes, checking to make sure that the business rules are not violated, and then pushing the data back across the HTTP interface to the Web service component.&lt;br /&gt;Public Function Update( _&lt;br /&gt; ByVal dsData As EmpService.dsEmps) As EmpService.dsEmps&lt;br /&gt;    Dim ws As EmpService.Employees&lt;br /&gt;&lt;br /&gt;    Try&lt;br /&gt;        ws = New EmpService.Employees()&lt;br /&gt;&lt;br /&gt;        ' Check business Rules&lt;br /&gt;        Me.Check(dsData)&lt;br /&gt;&lt;br /&gt;        ' Update Data In Table&lt;br /&gt;        ws.Update(dsData)&lt;br /&gt;&lt;br /&gt;    Catch&lt;br /&gt;        ' Throw any exceptions back to client&lt;br /&gt;        Throw&lt;br /&gt;&lt;br /&gt;    End Try&lt;br /&gt;&lt;br /&gt;    Return dsData&lt;br /&gt;End Function&lt;br /&gt;The Check Method in the Business Rules Component&lt;br /&gt;The Check method is where you put in any appropriate business rules that you need to check prior to inserting or updating any rows in the dataset.&lt;br /&gt;Public Sub Check(ByVal dsData As EmpService.dsEmps)&lt;br /&gt;    Dim strMsg As String&lt;br /&gt;    Dim row As EmpService.dsEmps.EmployeesRow&lt;br /&gt;&lt;br /&gt;    ' Check business rules&lt;br /&gt;    For Each row In dsData.Employees.Rows&lt;br /&gt;        If row.RowState = DataRowState.Added Or _&lt;br /&gt;         row.RowState = DataRowState.Modified Then&lt;br /&gt;            If row.FirstName.Trim() = "" Then&lt;br /&gt;              strMsg &amp;= "First Name must be filled in" &amp; _&lt;br /&gt;               ControlChars.CrLf&lt;br /&gt;            End If&lt;br /&gt;            If row.LastName.Trim() = "" Then&lt;br /&gt;              strMsg &amp;= "Last Name must be filled in" &amp; _&lt;br /&gt;               ControlChars.CrLf&lt;br /&gt;            End If&lt;br /&gt;            If row.HireDate &lt; row.BirthDate Then&lt;br /&gt;                strMsg &amp;= "Hire Date must be greater &lt;br /&gt;                           than Birth Date" &amp; _&lt;br /&gt;                 ControlChars.CrLf&lt;br /&gt;            End If&lt;br /&gt;        End If&lt;br /&gt;    Next&lt;br /&gt;&lt;br /&gt;    If strMsg &lt;&gt; "" Then&lt;br /&gt;        ' Throw a new ApplicationException&lt;br /&gt;        ' with our custom error message in it&lt;br /&gt;        Throw New ApplicationException(strMsg)&lt;br /&gt;    End If&lt;br /&gt;End Sub&lt;br /&gt;Notice that you should check the RowState property to see whether the row has been added or updated. You do not need to check the row if it has been deleted. During the Check method you can see the benefit of using Typed Datasets. Instead of referencing a column name through an index in a Dataset you have an actual property name. This enforces type safety and gives you an IntelliSense list of column names so you do not have to look them up in your database.&lt;br /&gt;Consuming the Data from the Windows Application&lt;br /&gt;Now that you have all of the components hooked up together, it is time to make the Windows application consume data from the business rules component. Follow the steps below to make this work. &lt;br /&gt;1. In the Solution Explorer window, click the EmpClient project. &lt;br /&gt;2. Add a reference to the EmpBusRule project. &lt;br /&gt;3. Bring up the code for the form and add the Private mdsEmps variable, as shown in the code below. &lt;br /&gt;4. Public Class EmpInfo&lt;br /&gt;5.     Inherits System.Windows.Forms.Form&lt;br /&gt;6. &lt;br /&gt;    Private mdsEmps As EmpBusRule.EmpService.dsEmps&lt;br /&gt;This member variable on this form is a typed dataset that represents the Employees table in the Northwind database. You use this variable to fill the DataGrid control on the employee form. &lt;br /&gt;Loading Data into the DataGrid&lt;br /&gt;Next, you need to create the routine to load the DataGrid. First, you add code to the form's Load event procedure. &lt;br /&gt;1. Double-click the form to display the Load event procedure. &lt;br /&gt;2. Add the following code: &lt;br /&gt;3. Private Sub EmpInfo_Load( _&lt;br /&gt;4.  ByVal sender As System.Object, _&lt;br /&gt;5.  ByVal e As System.EventArgs) Handles MyBase.Load&lt;br /&gt;6.     GridLoad()&lt;br /&gt;End Sub&lt;br /&gt;7. Create the GridLoad procedure immediately below the Load event procedure. &lt;br /&gt;8. Public Sub GridLoad()&lt;br /&gt;9.     Dim br As EmpBusRule.Employees&lt;br /&gt;10. &lt;br /&gt;11.     Try&lt;br /&gt;12.         br = New EmpBusRule.Employees()&lt;br /&gt;13. &lt;br /&gt;14.         ' mdsEmps is a typed dataset on this form&lt;br /&gt;15.         mdsEmps = br.GetData&lt;br /&gt;16. &lt;br /&gt;17.         grdEmps.DataMember = "Employees"&lt;br /&gt;18.         grdEmps.DataSource = mdsEmps&lt;br /&gt;19. &lt;br /&gt;20.     Catch exp As Exception&lt;br /&gt;21.         MsgBox(exp.Message)&lt;br /&gt;22. &lt;br /&gt;23.     End Try&lt;br /&gt;End Sub&lt;br /&gt;The GridLoad procedure declares a new business rule object. It then uses the GetData method in the business rule object to assign the new typed dataset mdsEmps. You assign the table name to the DataMember and the dataset object to the DataSource property of the DataGrid control.&lt;br /&gt;You should now be able to run this application, and if you have done everything correctly, the DataGrid should be loaded with employee data. &lt;br /&gt;1. Set the EmpClient project as the Startup Project if it is not already. &lt;br /&gt;2. Press F5 to run the application. &lt;br /&gt;You should now see employee data in the list box that looks like Figure 2.&lt;br /&gt;Updating Data from the DataGrid&lt;br /&gt;You will now create the procedure under the Update button on the form to take any changes you make to the data in the grid and push them back to the data tier. Of course, you will first push the changes to the DataSet through the business rules component, which then sends the data through the Web service component, and then finally to the data tier component. The data tier component then connects up to the SQL Server and pushes the changes to the server.&lt;br /&gt;Private Sub btnUpdate_Click( _&lt;br /&gt; ByVal sender As System.Object, _&lt;br /&gt; ByVal e As System.EventArgs) Handles btnUpdate.Click&lt;br /&gt;    Dim br As New EmpBusRule.Employees()&lt;br /&gt;    Dim dsChanges As New EmpBusRule.EmpService.dsEmps()&lt;br /&gt;    Dim strMsg As String&lt;br /&gt;&lt;br /&gt;    Try&lt;br /&gt;        If mdsEmps.HasChanges Then&lt;br /&gt;            dsChanges.Merge(mdsEmps.GetChanges())&lt;br /&gt;&lt;br /&gt;            MsgBox("Count = " &amp; _&lt;br /&gt;             CStr(dsChanges.Employees.Rows.Count))&lt;br /&gt;&lt;br /&gt;            ' Update the Data on the Server&lt;br /&gt;            dsChanges = br.Update(dsChanges)&lt;br /&gt;&lt;br /&gt;            MsgBox("Data Has Been Updated Successfully")&lt;br /&gt;&lt;br /&gt;            ' You can either merge the changes back &lt;br /&gt;            ' in and accept the changes, or you can &lt;br /&gt;            ' reload the data from the table. I prefer &lt;br /&gt;            ' reloading as it gets all the other &lt;br /&gt;            ' changes by all other users.&lt;br /&gt;            'mdsEmps.Merge(dsChanges)&lt;br /&gt;            'mdsEmps.AcceptChanges()&lt;br /&gt;&lt;br /&gt;            ' If everything is OK, refresh all data &lt;br /&gt;            ' from the web service.&lt;br /&gt;            GridLoad()&lt;br /&gt;        Else&lt;br /&gt;            MsgBox("No changes have been made &lt;br /&gt;                    to the data")&lt;br /&gt;        End If&lt;br /&gt;&lt;br /&gt;    Catch exp As ApplicationException&lt;br /&gt;        MsgBox(exp.Message)&lt;br /&gt;&lt;br /&gt;    Catch exp As Exception&lt;br /&gt;        MsgBox(exp.Message)&lt;br /&gt;&lt;br /&gt;    End Try&lt;br /&gt;End Sub&lt;br /&gt;The first part of this event procedure checks to see whether any changes have even been made to the DataSet. If they have, you get the changed data rows by using the GetChanges method of the DataSet class. This will return just those rows that were changed in the DataGrid.&lt;br /&gt;Once you have this short list of rows from the dataset you can submit that to the Update method of the business rule component. The business rule component then sends it to the Web service component, which sends it on to the data tier component, and finally updates SQL Server. If any changes are made to the rows in the dataset (such as a TimeStamp field updating, or an identity field updating), these rows are passed back to this procedure. You can then either merge the data back into the main dataset, or you could simply reload the entire dataset directly from the database (going through the components of course).&lt;br /&gt;When attempting to submit the changes to the back end, there could be a business rule that is violated. For example, if someone deletes the first name of an employee, the business rule that checks for the existence of the first name in a row of data will fail. This will be thrown as an ApplicationException object. You should check for this type of exception first, then display the error message returned, as that will be the description of the business rule or rules that are in violation.&lt;br /&gt;The last thing you have to check for is any generic exceptions. For example, the database server might be down, and thus a regular exception might be thrown. Or maybe a concurrency exception is thrown because you updated a row and another user updated a row just before you did.&lt;br /&gt;What's Different from Visual Basic 6.0?&lt;br /&gt;Although the concepts for designing an n-tier application are pretty much the same as they have always been, the implementation is quite different. You should find that the amount of code you have to write is significantly reduced due to the advancements in Web services and ADO.NET.&lt;br /&gt;Summary&lt;br /&gt;In this document, you learned how to put together an n-tier application. Although you are shown just one of the many ways you could accomplish this, the format used here is very simple and easy to create. While the component you build here may be created on one machine, you can easily move the components from one machine to another and scale this solution using .NET Remoting and Web services. Whether you choose a logical or a physical implementation for your applications, you should always strive to develop your application using separate components for each process.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7527040749709927669-3700510155024405145?l=jaan1762.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jaan1762.blogspot.com/feeds/3700510155024405145/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7527040749709927669&amp;postID=3700510155024405145' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/3700510155024405145'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/3700510155024405145'/><link rel='alternate' type='text/html' href='http://jaan1762.blogspot.com/2009/07/building-n-tier-application-in-net.html' title='Building an N-Tier Application in .NET'/><author><name>Mansoor</name><uri>http://www.blogger.com/profile/00473621254256960630</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-7527040749709927669.post-3675578867290619270</id><published>2009-07-07T03:46:00.000-07:00</published><updated>2009-07-07T03:50:05.108-07:00</updated><title type='text'>Working with MDI Applications and Creating Menus</title><content type='html'>Working with MDI Applications and Creating Menus&lt;br /&gt;&lt;br /&gt;Upgrading to Microsoft .NET&lt;br /&gt;Paul D. Sheriff, PDSA, Inc.&lt;br /&gt;Ken Getz, MCW Technologies&lt;br /&gt;January 2002&lt;br /&gt;&lt;br /&gt;Summary: Introduces you to the concept of Multiple Document Interface (MDI) and how to create menus within an MDI application. (20 printed pages)&lt;br /&gt;&lt;br /&gt;Objectives&lt;br /&gt;· Learn to create MDI parent forms &lt;br /&gt;· Learn to create MDI child forms &lt;br /&gt;· Learn to create and use menus &lt;br /&gt;&lt;br /&gt;Assumptions&lt;br /&gt;The following should be true for you to get the most out of this document: &lt;br /&gt;· You are familiar with Microsoft® Visual Studio® .NET &lt;br /&gt;· You are familiar with designing forms and other user interfaces &lt;br /&gt;&lt;br /&gt;Contents&lt;br /&gt;MDI Overview&lt;br /&gt;Create an MDI Project&lt;br /&gt;Creating Menus&lt;br /&gt;Working with MDI Child Forms&lt;br /&gt;Creating Shortcut Menus&lt;br /&gt;Manipulating Menus at Run Time&lt;br /&gt;How Did the Code Work?&lt;br /&gt;Summary&lt;br /&gt;&lt;br /&gt;MDI Overview&lt;br /&gt;&lt;br /&gt;This document introduces you to the concept of Multiple Document Interface (MDI) and how to create menus within an MDI application. You will learn to create an MDI application in Microsoft Visual Studio .NET and learn why you might want to use this type of interface. You will learn about child forms that are contained within the MDI application, and learn to create shortcut, or context-sensitive, menus.&lt;br /&gt;MDI is a popular interface because it allows you to have multiple documents (or forms) open in one application. Examples of MDI applications include Microsoft Word, Microsoft Excel, Microsoft PowerPoint®, and even the Visual Studio integrated development environment itself. Each application consists of one (or more) parent windows, each containing an MDI client area—the area where the child forms (or documents) will be displayed. Code you write displays as many instances of each of the child forms that you want displayed, and each child form can only be displayed within the confines of the parent window—this means you can't drag the child forms outside the MDI container. Figure 1 shows a basic MDI application in use. &lt;br /&gt; &lt;br /&gt;Figure 1. Use MDI to open multiple windows and have them all contained within the parent area&lt;br /&gt;Single Document Interface&lt;br /&gt;Don't be misled: MDI is only one of several possible paradigms for creating a user interface. You can also create applications that display just a single form. They're easier to create, in fact. Those applications are called Single Document Interface (SDI) applications. Microsoft Windows® Notepad is an SDI application, and you can only open a single document at a time. (If you want multiple documents open, you simply run Notepad multiple times.) You are under no obligation to create your applications using the MDI paradigm. Even if you have multiple forms in your project, you can simply have each one as a stand-alone form, not contained by any parent form. &lt;br /&gt;&lt;br /&gt;Uses of MDI&lt;br /&gt;&lt;br /&gt;You'll use MDI most often in applications where the user might like to have multiple forms or documents open concurrently. Word processing applications (like Microsoft Word), spreadsheet applications (like Microsoft Excel), and project manager applications (like Microsoft Project) are all good candidates for MDI applications. MDI is also handy when you have a large application, and you want to provide a simple mechanism for closing all the child forms when the user exits the application.&lt;br /&gt;&lt;br /&gt;Creating an MDI Parent Form&lt;br /&gt;&lt;br /&gt;To create an MDI parent form, you can simply take one of your existing forms and set its IsMDIContainer property to True. This form will now be able to contain other forms as child forms. You may have one or many container forms within your application.&lt;br /&gt;Tip   Note the difference here between Visual Studio .NET and Microsoft Visual Basic® 6.0 behavior. In Visual Basic 6.0, you could only have a single MDI parent form per application, and you had to use the Project menu to add that one special form. In Visual Studio .NET, you can turn any form into an MDI parent form by simply modifying a property, and you can have as many MDI parent forms as you require within the same project.&lt;br /&gt;You may have as many different child forms (the forms that remain contained within the parent form) as you want in your project. A child form is nothing more than a regular form for which you dynamically set the MdiParent property to refer to the MDI container form. &lt;br /&gt;Note   The user interface objects you've designed within the Visual Studio environment are really templates for forms. That is, they don't actually become real Form objects until you instantiate them at run time. Therefore, your project can contain as many different templates for MDI child forms as you like. You can instantiate and then show as many instances of as many different templates as you need, while your applications are running.&lt;br /&gt;Run-time Features of MDI Child Forms&lt;br /&gt;At run time, the MDI parent form and the MDI child forms take on special features: &lt;br /&gt;· All child forms are displayed within the MDI parent's client area. The client area is the area below the MDI parent's title bar, any menus, and any tool bars. &lt;br /&gt;· Child forms can be moved and sized only within the MDI parent's client area. &lt;br /&gt;· Child forms can be minimized and their icon will be displayed within the parent's client area. &lt;br /&gt;· Child forms can be maximized within the parent's client area and the caption of the child form is appended to the caption of the MDI form. &lt;br /&gt;· Windows automatically gives child forms that have their FormBorderStyle property set to a sizable border a default size. This size is based on the size of the MDI parent's client area. You can override this by setting the FormBorderStyle property of the child form to any of the fixed type of borders. &lt;br /&gt;· Child forms cannot be displayed modally. &lt;br /&gt;· The MDI form can be minimized and only one icon will be displayed on the desktop representing the MDI form and all of its children. &lt;br /&gt;· If the MDI form is unloaded, all of the loaded children will also be unloaded. &lt;br /&gt;Note   The client area includes any usable area on the MDI form minus any toolbars or status bars that you may have added to the MDI form.&lt;br /&gt;Create an MDI Project&lt;br /&gt;In this section, you will walk through the steps of creating a simple MDI application using Visual Studio .NET. To do this, you will create a new form that will be the MDI parent form. You will add some menus to this new form, and then you will load the product form from a menu as a child form.&lt;br /&gt;Create the MDI Parent Form&lt;br /&gt;To create the MDI parent form &lt;br /&gt;1. Open Visual Studio .NET &lt;br /&gt;2. Create a new Windows application project. &lt;br /&gt;3. Set the name of the project to MDI.sln. &lt;br /&gt;4. Rename the form that is created automatically to frmMain.vb. &lt;br /&gt;5. With the frmMain selected, set the form's IsMdiContainer property to True. &lt;br /&gt;6. Set the WindowState property to Maximized. &lt;br /&gt;That's all there is to it: you've created an MDI parent form.&lt;br /&gt;&lt;br /&gt;Creating Menus&lt;br /&gt;Your main form will require menus so that you can perform actions such as opening child forms, copying and pasting data, and arranging windows. Visual Studio .NET includes a new menu designer that makes creating and modifying menus a snap. &lt;br /&gt;To add menus to your MDI parent form &lt;br /&gt;1. Double-click the MainMenu tool in the Toolbox window to add a new object named MainMenu1 to the form tray. &lt;br /&gt;Note   Unlike the form designer in Visual Basic 6.0, the Visual Studio .NET form designer places controls that don't have a user interface at run time into a special area on the form designer: the form "tray". They're out of the way, and don't get buried underneath other controls. This is a real improvement!&lt;br /&gt;2. At the top of the MDI parent form, click the box with Type Here in it and type &amp;File. &lt;br /&gt;Tip   Just as in Visual Basic 6.0, inserting an ampersand (&amp;) into a menu caption displays the caption with an underscore under the following letter. Pressing Alt+&lt;the letter&gt; acts as a hotkey, activating the menu item. One thing to note: if you're using Windows 2000 or later, it's possible that the hotkeys won't show up underlined until you press the Alt key. This setting is buried in the Display applet within Control Panel. In the Display Properties dialog box, check the Effects page: the Hide keyboard navigation indicators until I use the Alt key option controls this behavior.&lt;br /&gt;3. Press Enter to move to the next menu item and type &amp;Products. &lt;br /&gt;4. Press Enter to move to the next menu item and type a hyphen (-). &lt;br /&gt;Tip    Rather than using the "-" to indicate a divider in the menu, you can insert the next menu item (Exit, in this case), and then right-click the new item. Select "Insert Separator" from the context menu, and Visual Studio .NET will insert a separator above the current item for you.&lt;br /&gt;5. Press Enter and type E&amp;xit. &lt;br /&gt;You have now created the first drop-down menu on your main form. You should have something that looks like Figure 2.&lt;br /&gt; &lt;br /&gt;Figure 2. The menu designer allows you to type your menu structure in a WYSIWYG fashion&lt;br /&gt;To the right of the File menu and at the same level, you'll see another small box with the text, Type Here. Click it and type the following menu items by pressing Enter after each one. &lt;br /&gt;· &amp;Edit &lt;br /&gt;· Cu&amp;t &lt;br /&gt;· &amp;Copy &lt;br /&gt;· &amp;Paste &lt;br /&gt;Once more to the right of the Edit menu and at the same level, add the following menu items in the same manner. &lt;br /&gt;· &amp;Window &lt;br /&gt;· &amp;Cascade &lt;br /&gt;· Tile &amp;Horizontal &lt;br /&gt;· Tile &amp;Vertical &lt;br /&gt;· &amp;Arrange Icons &lt;br /&gt;&lt;br /&gt;Creating Names for Each Menu&lt;br /&gt;After creating all the menu items, you'll need to set the Name property for each. (Because you'll refer to the name of each menu item from any code you write concerning that menu item, it's important to choose a name you can understand from within your code.) Instead of clicking each menu item one at a time and then moving over to the Properties window to set the Name property, Visual Studio provides a shortcut: Right-click an item in the menu, then select Edit Names from the context menu. Now you can simply click each menu item and set the name property directly on each menu. This is certainly quicker than using the Properties window to accomplish the same task. &lt;br /&gt;&lt;br /&gt;Use the following names for your menu items: &lt;br /&gt;· mnuFile &lt;br /&gt;· mnuFProducts &lt;br /&gt;· mnuFExit &lt;br /&gt;· mnuEdit &lt;br /&gt;· mnuECut &lt;br /&gt;· mnuECopy &lt;br /&gt;· mnuEPaste &lt;br /&gt;· mnuWindow &lt;br /&gt;· mnuWCasade &lt;br /&gt;· mnuWHorizontal &lt;br /&gt;· mnuWVertical &lt;br /&gt;· mnuWArrange &lt;br /&gt;&lt;br /&gt;Test out your application: Press F5 and you should see your main MDI window appear with your menu system in place.&lt;br /&gt;Display a Child Form&lt;br /&gt;To add the code that displays the child form, frmProducts, make sure the main form is open in Design view, and on the File menu, double-click Products. Visual Studio .NET will create the stub of the menu item's Click event handler for you. Modify the procedure so that it looks like the following:&lt;br /&gt;Private Sub mnuFProducts_Click( _&lt;br /&gt; ByVal sender As System.Object, _&lt;br /&gt; ByVal e As System.EventArgs) Handles mnuFProducts.Click&lt;br /&gt;    Dim frm As New frmProducts()&lt;br /&gt;&lt;br /&gt;    frm.MdiParent = Me&lt;br /&gt;&lt;br /&gt;    frm.Show()&lt;br /&gt;End Sub&lt;br /&gt;This code declares a variable, frm, which refers to a new instance of the frmProducts form in the sample project. Then, you set the MdiParent property of the new form, indicating that its parent should be the current form (using the Me keyword). Finally, the code calls the Show method of the child form, making it appear on the screen.&lt;br /&gt;&lt;br /&gt;Some interesting things to note: &lt;br /&gt;· Me is a built-in keyword in Visual Basic .NET—just as in Visual Basic 6.0, this keyword refers to the class whose code is currently running. In this case, that's the MDI parent form, whose menu item you just clicked. &lt;br /&gt;· You don't have to set the MdiParent property of the new child form. If you don't, the form will simply load as a new normal form, outside the MDI parent. As a matter of fact, you can set the MDI parent to be a different MDI container if you like. &lt;br /&gt;· If you don't call the Show method, the child form won't ever display. &lt;br /&gt;Differentiating Between Child Windows&lt;br /&gt;You'll note that each instance of the Products form looks identical. You'll most likely need some way to differentiate the windows. One alternative is to modify the caption of the window as you load each instance. In the sample, you can create a static variable to contain a counter, increment that variable each time you open a form, and then assign that value into the Text property of the form.&lt;br /&gt;To uniquely identify each child form &lt;br /&gt;1. Modify the mnuFProducts_Click procedure so that it looks like this: &lt;br /&gt;2. Private Sub mnuFProducts_Click( _&lt;br /&gt;3.  ByVal sender As System.Object, _&lt;br /&gt;4.  ByVal e As System.EventArgs) _&lt;br /&gt;5.  Handles mnuFProducts.Click&lt;br /&gt;6.     Dim frm As frmProducts&lt;br /&gt;7.     Static intCount As Integer&lt;br /&gt;8. &lt;br /&gt;9.     frm = New frmProducts()&lt;br /&gt;10. &lt;br /&gt;11.     ' Increment the caption counter.&lt;br /&gt;12.     intCount += 1&lt;br /&gt;13. &lt;br /&gt;14.     ' Set the caption to be unique.&lt;br /&gt;15.     frm.Text = frm.Text &amp; " " &amp; intCount.ToString()&lt;br /&gt;16. &lt;br /&gt;17.     frm.MdiParent = Me&lt;br /&gt;18.     frm.Show()&lt;br /&gt;End Sub&lt;br /&gt;19. Run the project, create a few Products forms, and note that the caption of each form includes a different number. &lt;br /&gt;Note   What's that Static keyword? Using Static, rather than Dim, to declare a variable inside a procedure creates a variable that maintains its value from one invocation of the procedure to the next. When you declare a variable using Dim, that variable gets reinitialized each time the procedure is called. When you use Static, the variable maintains its value. That's what you want, in this case—you want intCount to maintain its value, so that it continues to increment each time you create a new instance of frmProducts.&lt;br /&gt;&lt;br /&gt;Child Menus in MDI Applications&lt;br /&gt;&lt;br /&gt;What if a child form has its own set of menus? How do those menus interact with the menus of the parent form? In previous versions of Visual Basic you really didn't have much control over the behavior—the menus of the currently active child simply replaced the menus of its parent. In Visual Studio .NET, however, you can control how the menus interact, using the MergeOrder and MergeType properties of the individual menu items.&lt;br /&gt;&lt;br /&gt;The MergeOrder property controls the relative position of the menu item when its menu structure gets merged with the parent form's menus. The default value for this property is 0, indicating that this menu item will be added at the end of the existing menu items. The MergeType property controls how the menu item behaves when it has the same merge order as another menu item being merged. Table 1 shows a list of the possible values you can assign to the MergeType property. &lt;br /&gt;Table 1. The MergeType property allows you to specify what happens when menu items merge&lt;br /&gt;Value Description&lt;br /&gt;Add The MenuItem is added to the collection of existing MenuItem objects in a merged menu. (Default)&lt;br /&gt;MergeItems All submenu items of this MenuItem are merged with those of existing MenuItem objects at the same position in a merged menu. &lt;br /&gt;Remove The MenuItem is not included in a merged menu. &lt;br /&gt;Replace The MenuItem replaces an existing MenuItem at the same position in a merged menu.&lt;br /&gt;&lt;br /&gt;By default, a menu item's MergeOrder property is set to 0. The MergeType property is set to Add by default. This means that if you create a child form with a menu on it, the menu will be added at the end of the main menu. Consider Figure 3, which shows a child form called from the parent form's main menu. This form has a Maintenance menu on it (and the parent form does not). All of the items on the parent's main menu have their MergeOrder properties set to 0 and this menu's MergeOrder property is set to 0, so this menu will be added at the end of the main menu on the MDI parent form.&lt;br /&gt; &lt;br /&gt;Figure 3. A child form that has menus will by default be added to the end of the main menu&lt;br /&gt;To create the form in Figure 3 &lt;br /&gt;1. On the Project menu, click Add Windows Form. &lt;br /&gt;2. Set the new form's name to frmChildWithMenus.vb. &lt;br /&gt;3. Add a MainMenu control to this form. &lt;br /&gt;4. Set the Name property for the MainMenu control to mnuMainMaint. &lt;br /&gt;5. Add the following menus as shown in Table 2. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Table 2. Windows Form menus &lt;br /&gt;Menu Name&lt;br /&gt;&amp;Maintenance mnuMaint&lt;br /&gt;&amp;Suppliers mnuMSuppliers&lt;br /&gt;&amp;Categories mnuMCategories&lt;br /&gt;If you were to call this form exactly like you did the Products form in the previous section you will see that your main form looks like Figure 4. You can see that by default, the menu is added to the end of this form. &lt;br /&gt; &lt;br /&gt;Figure 4. Menus are added to the end of the main menu by default&lt;br /&gt;Call this form by adding a new menu item under the File menu: &lt;br /&gt;1. Open frmMain.vb in Design view. &lt;br /&gt;2. Click on the separator after the Products menu item and press the Insert key to add a new menu item. &lt;br /&gt;3. Type Child form with Menus as the text of this new menu item. &lt;br /&gt;4. Set the Name property of this new menu item to mnuFChild. &lt;br /&gt;5. Double click this new menu item and modify its Click event handler so that it looks like this: &lt;br /&gt;6. Private Sub mnuFChildMenus_Click( _&lt;br /&gt;7.  ByVal sender As System.Object, _&lt;br /&gt;8.  ByVal e As System.EventArgs) _&lt;br /&gt;9.  Handles mnuFChildMenus.Click&lt;br /&gt;10.     Dim frm As New frmChildWithMenus()&lt;br /&gt;11.     frm.MdiParent = Me&lt;br /&gt;12.     frm.Show()&lt;br /&gt;End Sub&lt;br /&gt;Note   If you wish to merge the Maintenance menu in between the Edit and Window menus, you could set the MergeOrder property on the Edit menu item to 1, and the MergeOrder property on the Window menu to a 2. Then on the Maintenance menu item on frmChildWithMenus, set the MergeOrder property to 1 and leave the MergeType with its default value, Add. Taking these steps will add the Maintenance menu after the menu on the main form with the same MergeOrder number as it has (that is, after the Edit menu, but before the Window menu).&lt;br /&gt;Working with MDI Child Forms&lt;br /&gt;If you have multiple child forms open, you may want to have them arrange themselves, much as you can do in Word or Excel, choosing options under the Window menu. Table 3 lists the available options when arranging child windows. &lt;br /&gt;Table 3. Choose one of these values when arranging child windows&lt;br /&gt;Menu Item Enumerated Value&lt;br /&gt;Tile Horizontal MdlLayout.TileHorizontal&lt;br /&gt;Tile Vertical MdiLayout.TileVertical&lt;br /&gt;Cascade MdiLayout.Cascade&lt;br /&gt;Arrange Icons MdiLayout.ArrangeIcons&lt;br /&gt;Add some menus to your main form for each of these options: &lt;br /&gt;1. Open frmMain.vb in Design view. &lt;br /&gt;2. On the Window menu, double-click Cascade. &lt;br /&gt;3. For the Cascade menu item, modify the Click event handler so that it looks like the following: &lt;br /&gt;4. Private Sub mnuWCascade_Click( _&lt;br /&gt;5.  ByVal sender As System.Object, _&lt;br /&gt;6.  ByVal e As System.EventArgs) _&lt;br /&gt;7.  Handles mnuWCascade.Click&lt;br /&gt;8.     Me.LayoutMdi(MdiLayout.Cascade)&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;On the Window menu, double-click each menu item and add the appropriate code. &lt;br /&gt;Tip   The LayoutMDI method replaces the Arrange method you may have used in Visual Basic 6.0.&lt;br /&gt;&lt;br /&gt;What If There's No Active Child Form?&lt;br /&gt;If there's no active child form, attempting to work with the ActiveMdiChild property of the parent form will trigger a run-time error. To avoid this situation, you can check the value of the property in the Click event handler for the Window menu item, and enable or disable the Center Child Form menu item accordingly. To add this feature, follow these steps: &lt;br /&gt;1. With frmMain open in Design view, press F7 to edit the form's code module. &lt;br /&gt;2. Select mnuWindow from the Class Name combo box (the list on the top left of the editor window), and then select Select from the Method Name combo box (the list on the right). &lt;br /&gt;3. Modify the Select event handler, so that it looks like this: &lt;br /&gt;4. Private Sub mnuWindow_Popup( _&lt;br /&gt;5.  ByVal sender As Object, _&lt;br /&gt;6.  ByVal e As System.EventArgs) _&lt;br /&gt;7.  Handles mnuWindow.Popup&lt;br /&gt;8.     mnuWCenterChild.Enabled = _&lt;br /&gt;9.      Not (Me.ActiveMdiChild Is Nothing)&lt;br /&gt;End Sub&lt;br /&gt;10. 4.Run the project, and verify that if you have child windows displayed, the Center Child Form menu item is enabled. If there isn't a child form open, verify that the menu item is disabled. &lt;br /&gt;How does this work? Here are some things to consider: &lt;br /&gt;· The Popup event occurs when you select a menu item that includes sub-items. (You can't use the Click event, since that event doesn't occur for menu items that contain sub-items.) &lt;br /&gt;· The Is operator allows you to compare values to the built-in value Nothing. In this case, the ActiveMdiChild property returns this special value if it doesn't refer to a form, and you must use the Is operator to check for this. (The = operator checks values for equality: the Is operator checks references to objects for equality.) &lt;br /&gt;· The syntax of the procedure may be confusing. The value in parentheses (Me, ActiveChild, Is, Nothing) returns a Boolean value: it's either True or False. The Not operator toggles the returned value to be the opposite Boolean value. The whole line of code assigns the return value from the expression in parentheses to the Enabled property of the menu item. In this case, if it's not true that the ActiveChild is Nothing, you'll enable the menu item. If it's True, you'll disable the menu item. &lt;br /&gt;&lt;br /&gt;Tracking Child Windows&lt;br /&gt;&lt;br /&gt;Visual Basic .NET will keep track of all child forms that you create, and it's easy to create a window list menu to manage the child windows. If you wish to see a list of all of the child forms and be able to give a specific child form focus, follow these steps: &lt;br /&gt;1. Load frmMain in Design view. &lt;br /&gt;2. Select frmMain's Window menu. &lt;br /&gt;3. In the Properties window, set the MdiList to True. &lt;br /&gt;4. Run the project, open a couple of Products forms, and then click the Window drop-down menu. You should see each instance of the Product form that you opened displayed in the window list. &lt;br /&gt;&lt;br /&gt;Creating Shortcut Menus&lt;br /&gt;&lt;br /&gt;In most modern Windows applications, you can click the right mouse button and see a context-sensitive, or shortcut (pop-up), menu. These menus give you the ability to perform actions based on the current context—that is, changing depending on the current situation.&lt;br /&gt;Visual Studio provides the ContextMenu control, making it just as easy to create context menus as it was to create main menus. Once you've dropped one of these controls on your form (it will appear in the tray area, just like the MainMenu control did), you can edit the menu items to be displayed by this context menu.&lt;br /&gt;Note   The design of your context menu won't display on the form until you've clicked the ContextMenu control. This makes it possible for one form to contain both MainMenu and ContextMenu controls.&lt;br /&gt;&lt;br /&gt;Tip    You can place as many ContextMenu controls as you need on your forms.&lt;br /&gt;To add a context menu to the Products form: &lt;br /&gt;1. Open frmProducts in Design view. &lt;br /&gt;2. In the Toolbox, find the ContextMenu control. &lt;br /&gt;3. Double-click this control to add it to the tray area of the form. &lt;br /&gt;4. Click the ContextMenu control to give it focus. &lt;br /&gt;5. Change the Name property to cmnuProdID. &lt;br /&gt;6. Add the menu items (shown in Table 4) to this control, and set the Name properties as shown. When you add to a context menu, you start with the first menu item under the top-level menu. Figure 5 shows the finished context menu. &lt;br /&gt;Table 4. Context menu items &lt;br /&gt;Menu Name&lt;br /&gt;&amp;Lookup mnuPLookUp&lt;br /&gt;&amp;Copy mnuPCopy&lt;br /&gt;&amp;Paste mnuPPaste&lt;br /&gt; &lt;br /&gt;Figure 5. When adding items to the ContextMenu control, create a top-level item that won't ever be displayed as the parent for your items &lt;br /&gt;7. Click the Product ID text box. &lt;br /&gt;8. In the Properties window, set the ContextMenu property to the ContextMenu control you just created, cmnuProdID. &lt;br /&gt;9. Run the project. On the File menu, click Products to create a child form, and righ-click on the Product ID text box to see the context menu appear. &lt;br /&gt;If you were completing this form, you could now add code to respond to the Click events on each of these menus.&lt;br /&gt;Manipulating Menus at Run Time&lt;br /&gt;You may need to modify the behavior of menu items while your application is running. In this section, you'll see how to check and uncheck, and add and remove menu items programmatically.&lt;br /&gt;To set up for the following sections, you will need to add three new menu items under the File menu on your MDI form. &lt;br /&gt;1. Open frmMain.vb in Design view. &lt;br /&gt;2. Click the File menu to display its sub-items. &lt;br /&gt;3. Add three menu items, as described in Table 5. &lt;br /&gt;&lt;br /&gt;Table 5. File menu items &lt;br /&gt;Menu Name&lt;br /&gt;&amp;Add Menus mnuFAddMenus&lt;br /&gt;&amp;Remove Menus mnuFRemoveMenus&lt;br /&gt;&amp;Add &amp;New Menu mnuFAddNew&lt;br /&gt;Checking and Unchecking Menu Items&lt;br /&gt;Visually selecting a menu item programmatically is easy: simply set the menu item's Checked property to True or False, as necessary. For example, you might want to indicate that you've added new menu items by adding a check to the Add Menus item, and remove it once you've removed the items. You'll add and remove the menu items in the next section, but for now, add and remove the check by following these steps: &lt;br /&gt;1. On the File menu, double-click Add Menus to view the Click event procedure. &lt;br /&gt;2. Modify the event procedure, so that it looks like this: &lt;br /&gt;3. Private Sub mnuFAddMenus_Click( _&lt;br /&gt;4.  ByVal sender As System.Object, _&lt;br /&gt;5.  ByVal e As System.EventArgs) _&lt;br /&gt;6.  Handles mnuFAddMenus.Click&lt;br /&gt;7.     If Not mnuFAddMenus.Checked Then&lt;br /&gt;8.         mnuFAddMenus.Checked = True&lt;br /&gt;9.     End If&lt;br /&gt;End Sub&lt;br /&gt;10. To repeat the previous two steps, on the File menu, double-click Remove Menus and modify its Click event procedure so that it looks like this: &lt;br /&gt;11. Private Sub mnuFRemoveMenus_Click( _&lt;br /&gt;12.  ByVal sender As System.Object, _&lt;br /&gt;13.  ByVal e As System.EventArgs) _&lt;br /&gt;14.  Handles mnuFRemoveMenus.Click&lt;br /&gt;15.     If mnuFAddMenus.Checked Then&lt;br /&gt;16.         mnuFAddMenus.Checked = False&lt;br /&gt;17.     End If&lt;br /&gt;End Sub&lt;br /&gt;18. Run the project, and on the File menu, double-click Add Menus. Verify that you see a check next to the item. To repeat, on the File menu, click Remove Menus to verify that the check has been removed. &lt;br /&gt;Adding and Removing Menus&lt;br /&gt;Windows Forms allows you to add and remove menus programmatically at run time. Using the Add and Remove (or RemoveAt) methods of the MenuItems collection, you can create new menus at run time, and delete any menu items.&lt;br /&gt;Note   In Visual Basic 6.0, you could only delete menu items that you created dynamically, at run time. That is, you couldn't delete static menu items. In Visual Studio .NET, you can delete any menu item.&lt;br /&gt;&lt;br /&gt;Adding Menus Programmatically&lt;br /&gt;&lt;br /&gt;To add a menu item, call the Add method of a particular menu item. For example, you might want to add two new menu items on the File menu. To do this, follow these steps: &lt;br /&gt;1. On the on the File menu, double-click Add Menus to view its Click event handler. &lt;br /&gt;2. Modify the event procedure so that it looks like this: &lt;br /&gt;3. Private Sub mnuFAddMenus_Click( _&lt;br /&gt;4.  ByVal sender As System.Object, _&lt;br /&gt;5.  ByVal e As System.EventArgs) _&lt;br /&gt;6.  Handles mnuFAddMenus.Click&lt;br /&gt;7.     If Not mnuFAddMenus.Checked Then&lt;br /&gt;8.         mnuFAddMenus.Checked = True&lt;br /&gt;9.         ' Adds these menus to the end of the File menu&lt;br /&gt;10.         With mnuFile.MenuItems&lt;br /&gt;11.             .Add("New Menu 1")&lt;br /&gt;12.             .Add("New Menu 2")&lt;br /&gt;13.         End With&lt;br /&gt;14.     End If&lt;br /&gt;End Sub&lt;br /&gt;Each menu item contained within the MainMenu (or ContextMenu) control is itself a MenuItem object, and just as with any other object, you refer to the menu items using the Name property you assigned to each. If a menu item contains other menu items (as each top-level menu item does), you can use its MenuItems property to refer to the collection of menu items it contains. In this case, you called the Add method of a MenuItem object (mnuFile) to add menu items to the collection of items. (In this example, mnuFile was the name you assigned to the File menu item.)&lt;br /&gt;Removing Menus Programmatically&lt;br /&gt;To remove menu items programmatically, you can either call the MenuItem collection's Remove or RemoveAt method. Remove requires you to provide a MenuItem object; if you instead want to remove items by their position within the menu, call the RemoveAt method.&lt;br /&gt;&lt;br /&gt;In this example, the simplest way to remove the menu items you created in the previous steps is to specify their position within the menu. You'll call the RemoveAt method to do the work. Because menu items are numbered starting at 0 (as are all collections and arrays in Visual Basic .NET), you need to take that into account when removing menu items.&lt;br /&gt;To handle removing the two menu items you've just added, modify the Click event procedure for the Remove Menus items on the File menu, so that the procedure looks like this:&lt;br /&gt;Private Sub mnuFRemoveMenus_Click( _&lt;br /&gt; ByVal sender As System.Object, _&lt;br /&gt; ByVal e As System.EventArgs) _&lt;br /&gt; Handles mnuFRemoveMenus.Click&lt;br /&gt;    If mnuFAddMenus.Checked Then&lt;br /&gt;        With mnuFile.MenuItems&lt;br /&gt;            ' Remove the last two items&lt;br /&gt;            .RemoveAt(.Count - 1)&lt;br /&gt;            .RemoveAt(.Count - 1)&lt;br /&gt;        End With&lt;br /&gt;        mnuFAddMenus.Checked = False&lt;br /&gt;    End If&lt;br /&gt;End Sub&lt;br /&gt;Run the project to verify that choosing the Add and Remove Menus menu items correctly adds and removes the two extra items.&lt;br /&gt;Using Menu Groups&lt;br /&gt;When you add a check to a menu item, you're indicating the state of that menu item—it's either selected, or it's not. Normal checked menus work individually, and are independent of other menu items.&lt;br /&gt;You may have a need to treat a group of menu items as a dependent set. In this case, selecting one item from the group forces all the other items in the group to be deselected. Although Visual Studio .NET doesn't provide a way to make this happen for you, it does supply the RadioCheck property of menu items that at least provides a visual indication. Rather than seeing a normal check, menu items with their RadioCheck property set to True display a dot when they're selected. It's still up to your code to deselect all the other items in your menu group, once the user selects a menu item.&lt;br /&gt;&lt;br /&gt;To demonstrate this behavior, modify properties and add code so that the four window management menu items (Cascade, Tile Horizontal, Tile Vertical, Arrange Icons) work as a group. To do that, follow these steps: &lt;br /&gt;1. With frmMain open in Design view, select the Window&gt;Center Child Form menu item. &lt;br /&gt;2. Right-click, and on the shortcut menu, click Insert Separator, which inserts a separator item above the selected item. &lt;br /&gt;3. Click on the Window&gt;Cascade menu item, then at the same time, press Ctrl and click the other four window management items on the menu, selecting all four. &lt;br /&gt;4. In the Properties window, set the RadioCheck property for the four selected menu items to True. &lt;br /&gt;5. Add the following procedure to the frmMain class: &lt;br /&gt;6. Private Sub RadioCheck_Click( _&lt;br /&gt;7.  ByVal sender As System.Object, _&lt;br /&gt;8.  ByVal e As System.EventArgs) _&lt;br /&gt;9.  Handles mnuWArrange.Click, mnuWCascade.Click, _&lt;br /&gt;10.  mnuWHorizontal.Click, mnuWVertical.Click&lt;br /&gt;11.     mnuWArrange.Checked = False&lt;br /&gt;12.     mnuWCascade.Checked = False&lt;br /&gt;13.     mnuWHorizontal.Checked = False&lt;br /&gt;14.     mnuWVertical.Checked = False&lt;br /&gt;15.     CType(sender, MenuItem).Checked = True&lt;br /&gt;End Sub&lt;br /&gt;16. Run the project, create some Product forms, and use the Window menu items to arrange the children. As you use the Cascade, Tile Horizontal, and other menu items, you should see a circle next to the most recently selected item. Figure 6 shows the results of adding this new feature. &lt;br /&gt; &lt;br /&gt;Figure 6. Setting a menu item's RadioCheck property to True shows a dot, rather than a check, next to selected items &lt;br /&gt;How Did the Code Work?&lt;br /&gt;It may seem odd that you managed to add new functionality to four menu items without modifying their event procedures at all. This example took advantage of a new feature in Visual Basic .NET—you can hook up as many event handlers to a specific event as you need, using the Handles clause on a procedure. Here, you provided a new procedure (RadioCheck_Click) that handles Click events for each of the four menu items you want to have work together.&lt;br /&gt;Here are the important issues: &lt;br /&gt;· The procedure you want to call must match the procedure signature of the standard Click event for menu items. That is, it must receive two parameters (one as System.Object, the other as System.EventArgs) and return nothing at all. (It must be a Sub, in other words.) &lt;br /&gt;· You must add a Handles clause for each event you want to handle. In this case, you're handling the Click event of four different menu items. &lt;br /&gt;· Within the procedure, you can use the first parameter (named sender, in this example) to figure out which object triggered the event. This example first sets each of the four items to be unchecked, and then checks the item that triggered the event. &lt;br /&gt;It's also interesting to note how the RadioCheck_Click procedure set the RadioCheck property of the object it received as its first parameter. To convert the Object variable into a MenuItem type, the code calls the CType function, indicating the variable to convert, and the result type (MenuItem):&lt;br /&gt;CType(sender, MenuItem).Checked = True&lt;br /&gt;You'll use CType a lot in Visual Basic .NET. This important function allows you to convert variables from one type to another. Because Visual Basic .NET is so strictly typed (it's always careful about the specific data types you're working with, unlike Visual Basic 6.0), you'll often need to use this function to convert variables into a specific data type.&lt;br /&gt;Note   It's important to note that when you use the Handles clause as you did here to add event handlers, you cannot control the order in which those events get handled. Visual Basic .NET does supply a different mechanism, the AddHandler statement, which gives you more control. Using the Handles clause is simpler, however, and if you don't care about the order in which the procedures handle the event (in this case, you don't), it's an easier way to add extra functionality.&lt;br /&gt;&lt;br /&gt;Summary&lt;br /&gt;&lt;br /&gt;In this document you have learned to build an MDI application using several techniques that you find in professional Windows applications. You also learned to create and manipulate menus. Whether or not you choose to use the MDI paradigm will depend on the complexity of your application and how many forms will need to be displayed at one time.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7527040749709927669-3675578867290619270?l=jaan1762.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jaan1762.blogspot.com/feeds/3675578867290619270/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7527040749709927669&amp;postID=3675578867290619270' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/3675578867290619270'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/3675578867290619270'/><link rel='alternate' type='text/html' href='http://jaan1762.blogspot.com/2009/07/working-with-mdi-applications-and.html' title='Working with MDI Applications and Creating Menus'/><author><name>Mansoor</name><uri>http://www.blogger.com/profile/00473621254256960630</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-7527040749709927669.post-3599720050529630492</id><published>2009-07-07T03:45:00.000-07:00</published><updated>2009-07-07T03:46:18.234-07:00</updated><title type='text'>Why use Stored Procedures?</title><content type='html'>Introduction&lt;br /&gt;&lt;br /&gt;A lot of people are now using stored procedures for their database operations, but what is so good about them? This article accompanies 'Developing Stored Procedures' and looks at the advantages and disadvantages of stored procedures. Note that most of the features listed here depend on the database server you are using.&lt;br /&gt;&lt;br /&gt;Performance&lt;br /&gt;&lt;br /&gt;If you have a really complex query then stored procedures will speed up the query after the first run (much like ASP.NET pages). This is because, much like ASP.NET, it generates an execution plan for the procedure. This is like taking your VB.NET code and moving it to MSIL code, it is faster and quicker to run. The DB Server will automatically update this plan when changes to the procedure are made.&lt;br /&gt;&lt;br /&gt;Encapsulation&lt;br /&gt;&lt;br /&gt;This ties in with Performance because you can take multiple statements (eg. an INPUT, UPDATE and SELECT) into one procedure, this significantly reduces the code needed to type in when using those statements (eg. on an ASP.NET page) and the 'compiling' done to the procedure make it faster to execute.&lt;br /&gt;Parameterized Queries&lt;br /&gt;Using input/output queries, you can customize the way that your queries operate, like functions and methods in regular programming languages that allow you to input parameters to change the output, stored procedures allow you to do the same.&lt;br /&gt;&lt;br /&gt;Maintainability&lt;br /&gt;&lt;br /&gt;When you write a stored procedure, applications can call it whenever they want and you can update the procedure whenever you see fit and the new version will be used by everyone who used it before and they don't even have to know it. This is especially good if a new requirement comes up and you already have 5000 people using it, you can just update the SP and everyone seamlessly uses the new one (unless you screw it up and it causes them all to fail).&lt;br /&gt;&lt;br /&gt;Security&lt;br /&gt;&lt;br /&gt;With a regular SQL statement, security would have to be set by what a user can and cannot do to the database or table. This can be very restricting and tedious if you want to update the security for a user or add a new user to the list. Depending on your database server (I know that Oracle and SQL Server can do this) you can set up permissions for individual stored procedures. You could lock down the database and have stored procedures the only way to access the database if you wanted to be than conscious. &lt;br /&gt;&lt;br /&gt;Easy to learn and copy&lt;br /&gt;&lt;br /&gt;Stored procedures are just SQL and are very easy to learn and to copy. You can find resources on creating them nearly anywhere on the web and tutorials on SQL as well. You can also copy them easily from database to database (or database server to database server). If you have the MSDN Library CD's then you will find everything you need to know about programming the stored procedures using T-SQL.&lt;br /&gt;&lt;br /&gt;Easy Debugging&lt;br /&gt;&lt;br /&gt;This really only applies to users of VS.NET, but you can interpret error messages if you want. &lt;br /&gt;VS.NET uses it's debugging tools to debug T-SQL stored procedures so that you will always get it right. There may be some other debugging tools out there (there must be) and those should also provide the features to debug your stored procedures.&lt;br /&gt;&lt;br /&gt;Disadvantages&lt;br /&gt;&lt;br /&gt;As you can see, there are so many advantages from using stored procedures that you're probably wondering how terrible the bad stuff it. The truth is - it isn't. As far as I can see, they are nearly perfect for your database, but sometimes they require some work to create and debug them (especially if you are new to SQL programming), the only other thing that I can see if that there is not universal language for stored procedures. i.e. There is T-SQL for SQL Server and PL/SQL for Oracle, these two languages are quite different.&lt;br /&gt; &lt;br /&gt;Summary&lt;br /&gt;You can see that the advantages far outweigh the disadvantages (if you really call those disadvantages). So, why not use them? Check out the RELATED ARTICLES section for more information on creating and using stored procedures.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7527040749709927669-3599720050529630492?l=jaan1762.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jaan1762.blogspot.com/feeds/3599720050529630492/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7527040749709927669&amp;postID=3599720050529630492' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/3599720050529630492'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/3599720050529630492'/><link rel='alternate' type='text/html' href='http://jaan1762.blogspot.com/2009/07/why-use-stored-procedures.html' title='Why use Stored Procedures?'/><author><name>Mansoor</name><uri>http://www.blogger.com/profile/00473621254256960630</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-7527040749709927669.post-7826530470104466119</id><published>2009-07-07T03:38:00.000-07:00</published><updated>2009-07-07T03:41:47.581-07:00</updated><title type='text'>USING JAVASCRIPT FOR DISABLING BUTTON</title><content type='html'>JAVASCRIPTS FOR DISABLE BUTTON&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Button.JS CODE&lt;br /&gt;---------------&lt;br /&gt;&lt;br /&gt;function addLoadEvent(func) {&lt;br /&gt;  if(typeof window.onload != 'function')&lt;br /&gt;    window.onload = func;&lt;br /&gt;  else {&lt;br /&gt;    var oldLoad = window.onload;&lt;br /&gt;&lt;br /&gt;    window.onload = function() {&lt;br /&gt;      if(oldLoad) oldLoad();&lt;br /&gt;      func();&lt;br /&gt;    }&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt; /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *&lt;br /&gt;  *                     Button Disabler                         *&lt;br /&gt;  *                       Version 1.0                           *&lt;br /&gt;  *                 Written by Josh Stodola                     *&lt;br /&gt;  *                     January 29, 2008                        *&lt;br /&gt;  *                                                             *&lt;br /&gt;  * * * * * * * * * *CONFIGURATION OPTIONS* * * * * * * * * * * *&lt;br /&gt;  *                                                             *&lt;br /&gt;  *   IsTesting  (Boolean, defaults to false)                   *&lt;br /&gt;  *     When this is set to true, the form will never submit.   *&lt;br /&gt;  *     Use this to confirm that the script is working.         *&lt;br /&gt;  *                                                             *&lt;br /&gt;  *   DisabledButtonValue  (String, defaults to 'Please Wait')  *&lt;br /&gt;  *     This is the value to show on the button once disabled.  *&lt;br /&gt;  *                                                             *&lt;br /&gt;  *   HideNonSubmitButtons  (Boolean, defaults to true)         *&lt;br /&gt;  *     When true, the script will also hide any reset buttons  *&lt;br /&gt;  *     or Javascript buttons it encounters.                    *&lt;br /&gt;  *                                                             *&lt;br /&gt;  *   ShowHourglassCursor  (Boolean, defaults to true)          *&lt;br /&gt;  *     When true, the script will change the cursor to the     *&lt;br /&gt;  *     OS-defined "waiting" symbol to indicate loading.        *&lt;br /&gt;  *                                                             *&lt;br /&gt;  *   StopLoopAtFirstTextbox  (Boolean, defaults to false)      *&lt;br /&gt;  *     When true, the script will stop looping through input   *&lt;br /&gt;  *     elements once it encounters the first textbox. The loop *&lt;br /&gt;  *     begins at the bottom of the form. This can be set to    *&lt;br /&gt;  *     true to make the script more efficient.                 *&lt;br /&gt;  *                                                             *&lt;br /&gt;  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */&lt;br /&gt;&lt;br /&gt;var ButtonDisabler = {&lt;br /&gt;  IsTesting: false,&lt;br /&gt;  DisabledButtonValue: 'Please Wait',&lt;br /&gt;  HideNonSubmitButtons: true,&lt;br /&gt;  ShowHourglassCursor: true,&lt;br /&gt;  StopLoopAtFirstTextbox: true,&lt;br /&gt;  IsCapable: (document.getElementById &amp;&amp; document.createElement),&lt;br /&gt;  AddSubmitEvent: function(frm, func) {&lt;br /&gt;    if(typeof frm.onsubmit != 'function')&lt;br /&gt;      frm.onsubmit = func;&lt;br /&gt;    else {&lt;br /&gt;      var oldSub = frm.onsubmit;&lt;br /&gt;&lt;br /&gt;      frm.onsubmit = function() {&lt;br /&gt;        if(oldSub) {&lt;br /&gt;          if(oldSub())&lt;br /&gt;            return func();&lt;br /&gt;          else&lt;br /&gt;            return false;&lt;br /&gt;        }&lt;br /&gt;        else&lt;br /&gt;          return func();&lt;br /&gt;      }&lt;br /&gt;    }&lt;br /&gt;  },&lt;br /&gt;  LoadEventHandlers: function() {&lt;br /&gt;    if(ButtonDisabler.IsCapable) {&lt;br /&gt;      for(var i = 0; i &lt; document.forms.length; i++) {&lt;br /&gt;        var frm = document.forms[i];&lt;br /&gt;&lt;br /&gt;        ButtonDisabler.AddSubmitEvent(frm, function() {&lt;br /&gt;          ButtonDisabler.DisableForm(frm);&lt;br /&gt;          return !ButtonDisabler.IsTesting;&lt;br /&gt;        });&lt;br /&gt;      }&lt;br /&gt;    }&lt;br /&gt;  },&lt;br /&gt;  DisableForm: function(frm) {&lt;br /&gt;    if(!frm) return;&lt;br /&gt;    var inputs = frm.getElementsByTagName('INPUT');&lt;br /&gt;&lt;br /&gt;    for(var j = inputs.length - 1; j &gt;= 0; j--) {&lt;br /&gt;      var elem = inputs[j];&lt;br /&gt;&lt;br /&gt;      if(elem.type == 'submit' || elem.type == 'image') {&lt;br /&gt;        var btn = document.createElement('button');&lt;br /&gt;&lt;br /&gt;        btn.disabled = 'disabled';&lt;br /&gt;        btn.innerHTML = ButtonDisabler.DisabledButtonValue;&lt;br /&gt;&lt;br /&gt;        elem.parentNode.insertBefore(btn, elem);&lt;br /&gt;        elem.style.display = 'none';&lt;br /&gt;      }&lt;br /&gt;&lt;br /&gt;      if(elem.type == 'reset' || elem.type == 'button') {&lt;br /&gt;        if(ButtonDisabler.HideNonSubmitButtons)&lt;br /&gt;          elem.style.display = 'none';&lt;br /&gt;      }&lt;br /&gt;&lt;br /&gt;      if(elem.type == 'text' &amp;&amp; ButtonDisabler.StopLoopAtFirstTextbox)&lt;br /&gt;        break;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    if(ButtonDisabler.ShowHourglassCursor)&lt;br /&gt;      document.body.style.cursor = 'wait';&lt;br /&gt;&lt;br /&gt;    frm.onsubmit = function() {&lt;br /&gt;      return false;&lt;br /&gt;    }&lt;br /&gt;  }&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;addLoadEvent(ButtonDisabler.LoadEventHandlers);&lt;br /&gt;&lt;br /&gt;SCRIPT.js&lt;br /&gt;-------------&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;function validateForm(frm) {&lt;br /&gt;    if(!document.getElementById('radGender_0').checked&lt;br /&gt;    &amp;&amp; !document.getElementById('radGender_1').checked) {&lt;br /&gt;        alert('I know it\'s rude, but I must know your gender');&lt;br /&gt;        return false;&lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;    if(!document.getElementById('chkFood_0').checked&lt;br /&gt;    &amp;&amp; !document.getElementById('chkFood_1').checked&lt;br /&gt;    &amp;&amp; !document.getElementById('chkFood_2').checked&lt;br /&gt;    &amp;&amp; !document.getElementById('chkFood_3').checked) {&lt;br /&gt;        alert('What is your favorite food?');&lt;br /&gt;        return false;&lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;    return true;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;ASPX PAGE&lt;br /&gt;---------&lt;br /&gt;&lt;br /&gt;&amp;lt;%@ Page Language="VB" %&amp;gt;&lt;br /&gt;&amp;lt;script runat="server"&amp;gt;&lt;br /&gt;    Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click&lt;br /&gt;        Threading.Thread.Sleep(5000)&lt;br /&gt;    End Sub&lt;br /&gt;&amp;lt;/script&amp;gt;&lt;br /&gt;&amp;lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;html xmlns="http://www.w3.org/1999/xhtml"&amp;gt;&lt;br /&gt;&amp;lt;head runat="server"&amp;gt;&lt;br /&gt;    &amp;lt;title&amp;gt;Disable Web Form Submit Button - ASP.NET Example&amp;lt;/title&amp;gt;&lt;br /&gt;    &amp;lt;script type="text/javascript" src="script/button.js"&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;    &amp;lt;script type="text/javascript" src="script/script.js"&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;    &amp;lt;link rel="stylesheet" type="text/css" href="styles.css" /&amp;gt;&lt;br /&gt;&amp;lt;/head&amp;gt;&lt;br /&gt;&amp;lt;body&amp;gt;&lt;br /&gt;    &amp;lt;h1&amp;gt;Disable Web Form Submit Button&amp;lt;/h1&amp;gt;&lt;br /&gt;    &amp;lt;h2&amp;gt;Solution by Josh Stodola&amp;lt;/h2&amp;gt;&lt;br /&gt;    &amp;lt;h3&amp;gt;ASP.NET Example&amp;lt;/h3&amp;gt;&lt;br /&gt;    &amp;lt;form id="form1" runat="server" onsubmit="return validateForm(this);"&amp;gt;&lt;br /&gt;        &amp;lt;div&amp;gt;&lt;br /&gt;            &amp;lt;label for="txtFirst"&amp;gt;First Name&amp;lt;/label&amp;gt;&lt;br /&gt;        &amp;lt;/div&amp;gt;&lt;br /&gt;        &amp;lt;div&amp;gt;&lt;br /&gt;            &amp;lt;asp:TextBox ID="txtFirst" runat="server" MaxLength="50"&amp;gt;&amp;lt;/asp:TextBox&amp;gt;&lt;br /&gt;            &amp;lt;asp:RequiredFieldValidator ID="rfvFirst" runat="server" ErrorMessage="Enter your name" ControlToValidate="txtFirst" SetFocusOnError="true" EnableClientScript="true"&amp;gt;&amp;lt;/asp:RequiredFieldValidator&amp;gt;&lt;br /&gt;        &amp;lt;/div&amp;gt;&lt;br /&gt;        &amp;lt;div&amp;gt;&lt;br /&gt;            &amp;lt;label for="txtLast"&amp;gt;Last Name&amp;lt;/label&amp;gt;&lt;br /&gt;        &amp;lt;/div&amp;gt;&lt;br /&gt;        &amp;lt;div&amp;gt;&lt;br /&gt;            &amp;lt;asp:TextBox ID="txtLast" runat="server" MaxLength="50"&amp;gt;&amp;lt;/asp:TextBox&amp;gt;&lt;br /&gt;            &amp;lt;asp:RequiredFieldValidator ID="rfvLast" runat="server" ErrorMessage="Enter your name" ControlToValidate="txtLast" SetFocusOnError="true" EnableClientScript="true"&amp;gt;&amp;lt;/asp:RequiredFieldValidator&amp;gt;&lt;br /&gt;        &amp;lt;/div&amp;gt;&lt;br /&gt;        &amp;lt;div&amp;gt;&lt;br /&gt;            &amp;lt;label for="txtAge"&amp;gt;Age&amp;lt;/label&amp;gt;&lt;br /&gt;        &amp;lt;/div&amp;gt;&lt;br /&gt;        &amp;lt;div&amp;gt;&lt;br /&gt;            &amp;lt;asp:TextBox ID="txtAge" runat="server" MaxLength="2" Width="40"&amp;gt;&amp;lt;/asp:TextBox&amp;gt;&lt;br /&gt;            &amp;lt;asp:RequiredFieldValidator ID="rfvAge" runat="server" ErrorMessage="Enter your age" ControlToValidate="txtAge" SetFocusOnError="true" EnableClientScript="true"&amp;gt;&amp;lt;/asp:RequiredFieldValidator&amp;gt;&lt;br /&gt;        &amp;lt;/div&amp;gt;&lt;br /&gt;        &amp;lt;div&amp;gt;&lt;br /&gt;            &amp;lt;label for="radGenter"&amp;gt;Gender&amp;lt;/label&amp;gt;&lt;br /&gt;        &amp;lt;/div&amp;gt;&lt;br /&gt;        &amp;lt;div&amp;gt;&lt;br /&gt;            &amp;lt;asp:RadioButtonList ID="radGender" runat="server"&amp;gt;&lt;br /&gt;                &amp;lt;asp:ListItem Text="Male" Value="0" /&amp;gt;&lt;br /&gt;                &amp;lt;asp:ListItem Text="Female" Value="1" /&amp;gt;&lt;br /&gt;            &amp;lt;/asp:RadioButtonList&amp;gt;&lt;br /&gt;        &amp;lt;/div&amp;gt;&lt;br /&gt;        &amp;lt;div&amp;gt;&lt;br /&gt;            &amp;lt;label for="chkFood"&amp;gt;Favorite Foods&amp;lt;/label&amp;gt;&lt;br /&gt;        &amp;lt;/div&amp;gt;&lt;br /&gt;        &amp;lt;div&amp;gt;&lt;br /&gt;            &amp;lt;asp:CheckBoxList ID="chkFood" runat="server"&amp;gt;&lt;br /&gt;                &amp;lt;asp:ListItem Text="American" Value="A" /&amp;gt;&lt;br /&gt;                &amp;lt;asp:ListItem Text="Chinese" Value="C" /&amp;gt;&lt;br /&gt;                &amp;lt;asp:ListItem Text="Italian" Value="I" /&amp;gt;&lt;br /&gt;                &amp;lt;asp:ListItem Text="Mexican" Value="M" /&amp;gt;&lt;br /&gt;            &amp;lt;/asp:CheckBoxList&amp;gt;&lt;br /&gt;        &amp;lt;/div&amp;gt;&lt;br /&gt;        &amp;lt;div&amp;gt;&lt;br /&gt;            &amp;lt;label for="txtComments"&amp;gt;Comments&amp;lt;/label&amp;gt;&lt;br /&gt;        &amp;lt;/div&amp;gt;&lt;br /&gt;        &amp;lt;div&amp;gt;&lt;br /&gt;            &amp;lt;asp:TextBox ID="txtComments" TextMode="multiLine" Rows="7" Columns="30" runat="server"&amp;gt;&amp;lt;/asp:TextBox&amp;gt;&lt;br /&gt;        &amp;lt;/div&amp;gt;&lt;br /&gt;        &amp;lt;div&amp;gt;&lt;br /&gt;            &amp;lt;asp:Button ID="btnSubmit" runat="server" Text="Submit Form" /&amp;gt;&lt;br /&gt;            &amp;lt;input id="btnReset" type="reset" value="Clear Form" /&amp;gt;&lt;br /&gt;        &amp;lt;/div&amp;gt;&lt;br /&gt;    &amp;lt;/form&amp;gt;&lt;br /&gt;&amp;lt;/body&amp;gt;&lt;br /&gt;&amp;lt;/html&amp;gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7527040749709927669-7826530470104466119?l=jaan1762.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jaan1762.blogspot.com/feeds/7826530470104466119/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7527040749709927669&amp;postID=7826530470104466119' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/7826530470104466119'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/7826530470104466119'/><link rel='alternate' type='text/html' href='http://jaan1762.blogspot.com/2009/07/javascripts-for-disable-button-button.html' title='USING JAVASCRIPT FOR DISABLING BUTTON'/><author><name>Mansoor</name><uri>http://www.blogger.com/profile/00473621254256960630</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-7527040749709927669.post-5520527596351483079</id><published>2009-07-07T03:31:00.000-07:00</published><updated>2009-07-07T03:33:38.911-07:00</updated><title type='text'>ASP.NET DropDownList OptionGroup support</title><content type='html'>In APP_Browser FOlder&lt;br /&gt;---------------------&lt;br /&gt;&lt;br /&gt;&amp;lt;browsers&amp;gt;&lt;br /&gt;  &amp;lt;browser refID="IE6to9"&amp;gt;&lt;br /&gt;    &amp;lt;controlAdapters&amp;gt;&lt;br /&gt;      &amp;lt;adapter controlType="System.Web.UI.WebControls.DropDownList"&lt;br /&gt;      adapterType="CraigBlog.Net.Code.Adapters.DropDownListAdapter" /&amp;gt;&lt;br /&gt;    &amp;lt;/controlAdapters&amp;gt;&lt;br /&gt;  &amp;lt;/browser&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;!--&lt;br /&gt;NOTE: If you are using VS2005 with the standard build model, simply place the DropDownListAdapter in the App_Code directory and use the following browser section:&lt;br /&gt;&lt;br /&gt;  &amp;lt;browser refID="IE6to9"&amp;gt;&lt;br /&gt;    &amp;lt;controlAdapters&amp;gt;&lt;br /&gt;      &amp;lt;adapter controlType="System.Web.UI.WebControls.DropDownList"&lt;br /&gt;      adapterType="DropDownListAdapter" /&amp;gt;&lt;br /&gt;    &amp;lt;/controlAdapters&amp;gt;&lt;br /&gt;  &amp;lt;/browser&amp;gt;&lt;br /&gt;--&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;/browsers&amp;gt;&lt;br /&gt;&lt;br /&gt;IN APP_CODE Folder add a folder named Adapters and add this code&lt;br /&gt;----------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;using System;&lt;br /&gt;using System.Data;&lt;br /&gt;using System.Configuration;&lt;br /&gt;using System.Web;&lt;br /&gt;using System.Web.Security;&lt;br /&gt;using System.Web.UI;&lt;br /&gt;using System.Web.UI.WebControls;&lt;br /&gt;using System.Web.UI.WebControls.WebParts;&lt;br /&gt;using System.Web.UI.HtmlControls;&lt;br /&gt;using System.Collections;&lt;br /&gt;using System.Collections.Generic;&lt;br /&gt;&lt;br /&gt;namespace CraigBlog.Net.Code.Adapters {&lt;br /&gt;    public class DropDownListAdapter : System.Web.UI.WebControls.Adapters.WebControlAdapter {&lt;br /&gt;        protected override void RenderContents(HtmlTextWriter writer) {&lt;br /&gt;            DropDownList list = this.Control as DropDownList;&lt;br /&gt;&lt;br /&gt;            string currentOptionGroup;&lt;br /&gt;            List&lt;string&gt; renderedOptionGroups = new List&lt;string&gt;();&lt;br /&gt;&lt;br /&gt;            foreach(ListItem item in list.Items) {&lt;br /&gt;                if(item.Attributes["OptionGroup"] == null) {&lt;br /&gt;                    RenderListItem(item, writer);&lt;br /&gt;                } else {&lt;br /&gt;                    currentOptionGroup = item.Attributes["OptionGroup"];&lt;br /&gt;&lt;br /&gt;                    if(renderedOptionGroups.Contains(currentOptionGroup)) {&lt;br /&gt;                        RenderListItem(item, writer);&lt;br /&gt;                    } else {&lt;br /&gt;                        if(renderedOptionGroups.Count &gt; 0) {&lt;br /&gt;                            RenderOptionGroupEndTag(writer);&lt;br /&gt;                        }&lt;br /&gt;&lt;br /&gt;                        RenderOptionGroupBeginTag(currentOptionGroup, writer);&lt;br /&gt;                        renderedOptionGroups.Add(currentOptionGroup);&lt;br /&gt;&lt;br /&gt;                        RenderListItem(item, writer);&lt;br /&gt;                    }&lt;br /&gt;                }&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            if(renderedOptionGroups.Count &gt; 0) {&lt;br /&gt;                RenderOptionGroupEndTag(writer);&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private void RenderOptionGroupBeginTag(string name, HtmlTextWriter writer) {&lt;br /&gt;            writer.WriteBeginTag("optgroup");&lt;br /&gt;            writer.WriteAttribute("label", name);&lt;br /&gt;            writer.Write(HtmlTextWriter.TagRightChar);&lt;br /&gt;            writer.WriteLine();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private void RenderOptionGroupEndTag(HtmlTextWriter writer) {&lt;br /&gt;            writer.WriteEndTag("optgroup");&lt;br /&gt;            writer.WriteLine();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private void RenderListItem(ListItem item, HtmlTextWriter writer) {&lt;br /&gt;            writer.WriteBeginTag("option");&lt;br /&gt;            writer.WriteAttribute("value", item.Value, true);&lt;br /&gt;&lt;br /&gt;            if(item.Selected) {&lt;br /&gt;                writer.WriteAttribute("selected", "selected", false);&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            foreach(string key in item.Attributes.Keys) {&lt;br /&gt;                writer.WriteAttribute(key, item.Attributes[key]);&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            writer.Write(HtmlTextWriter.TagRightChar);&lt;br /&gt;            HttpUtility.HtmlEncode(item.Text, writer);&lt;br /&gt;            writer.WriteEndTag("option");&lt;br /&gt;            writer.WriteLine();&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;ASPX PAGE&lt;br /&gt;---------&lt;br /&gt;&lt;br /&gt;&amp;lt;%@ Page Language="C#" AutoEventWireup="true" CodeBehind="DropDownListOptionGroup.aspx.cs" Inherits="CraigBlog.Net.DropDownListOptionGroup" %&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;html xmlns="http://www.w3.org/1999/xhtml" &amp;gt;&lt;br /&gt;&amp;lt;head runat="server"&amp;gt;&lt;br /&gt;    &amp;lt;title&amp;gt;DropDownList with OptionGroup support&amp;lt;/title&amp;gt;&lt;br /&gt;&amp;lt;/head&amp;gt;&lt;br /&gt;&amp;lt;body&amp;gt;&lt;br /&gt;    &amp;lt;form id="form1" runat="server"&amp;gt;&lt;br /&gt;    &amp;lt;div style="padding: 50px 0px 0px 50px"&amp;gt;&lt;br /&gt;        &amp;lt;asp:DropDownList ID="ddlItems" runat="server"&amp;gt;&amp;lt;/asp:DropDownList&amp;gt;&lt;br /&gt;    &amp;lt;/div&amp;gt;&lt;br /&gt;    &amp;lt;/form&amp;gt;&lt;br /&gt;&amp;lt;/body&amp;gt;&lt;br /&gt;&amp;lt;/html&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;CODE BEHIND PAGE&lt;br /&gt;-----------------&lt;br /&gt;using System;&lt;br /&gt;using System.Data;&lt;br /&gt;using System.Configuration;&lt;br /&gt;using System.Collections;&lt;br /&gt;using System.Web;&lt;br /&gt;using System.Web.Security;&lt;br /&gt;using System.Web.UI;&lt;br /&gt;using System.Web.UI.WebControls;&lt;br /&gt;using System.Web.UI.WebControls.WebParts;&lt;br /&gt;using System.Web.UI.HtmlControls;&lt;br /&gt;&lt;br /&gt;namespace CraigBlog.Net {&lt;br /&gt;    public partial class TestDropDownList : System.Web.UI.Page {&lt;br /&gt;        protected void Page_Load(object sender, EventArgs e) &lt;br /&gt;        {&lt;br /&gt;            ListItem item1 = new ListItem("Camel", "1");&lt;br /&gt;            item1.Attributes["OptionGroup"] = "Mammals";&lt;br /&gt;&lt;br /&gt;            ListItem item2 = new ListItem("Lion", "2");&lt;br /&gt;            item2.Attributes["OptionGroup"] = "Mammals";&lt;br /&gt;&lt;br /&gt;            ListItem item3 = new ListItem("Whale", "3");&lt;br /&gt;            item3.Attributes["OptionGroup"] = "Mammals";&lt;br /&gt;&lt;br /&gt;            ListItem item4 = new ListItem("Walrus", "4");&lt;br /&gt;            item4.Attributes["OptionGroup"] = "Mammals";&lt;br /&gt;&lt;br /&gt;            ListItem item5 = new ListItem("Velociraptor", "5");&lt;br /&gt;            item5.Attributes["OptionGroup"] = "Dinosaurs";&lt;br /&gt;&lt;br /&gt;            ListItem item6 = new ListItem("Allosaurus", "6");&lt;br /&gt;            item6.Attributes["OptionGroup"] = "Dinosaurs";&lt;br /&gt;&lt;br /&gt;            ListItem item7 = new ListItem("Triceratops", "7");&lt;br /&gt;            item7.Attributes["OptionGroup"] = "Dinosaurs";&lt;br /&gt;&lt;br /&gt;            ListItem item8 = new ListItem("Stegosaurus", "8");&lt;br /&gt;            item8.Attributes["OptionGroup"] = "Dinosaurs";&lt;br /&gt;&lt;br /&gt;            ListItem item9 = new ListItem("Tyrannosaurus", "9");&lt;br /&gt;            item9.Attributes["OptionGroup"] = "Dinosaurs";&lt;br /&gt;&lt;br /&gt;            ddlItems.Items.Add(item1);&lt;br /&gt;            ddlItems.Items.Add(item2);&lt;br /&gt;            ddlItems.Items.Add(item3);&lt;br /&gt;            ddlItems.Items.Add(item4);&lt;br /&gt;            ddlItems.Items.Add(item5);&lt;br /&gt;            ddlItems.Items.Add(item6);&lt;br /&gt;            ddlItems.Items.Add(item7);&lt;br /&gt;            ddlItems.Items.Add(item8);&lt;br /&gt;            ddlItems.Items.Add(item9);&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7527040749709927669-5520527596351483079?l=jaan1762.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jaan1762.blogspot.com/feeds/5520527596351483079/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7527040749709927669&amp;postID=5520527596351483079' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/5520527596351483079'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/5520527596351483079'/><link rel='alternate' type='text/html' href='http://jaan1762.blogspot.com/2009/07/aspnet-dropdownlist-optiongroup-support.html' title='ASP.NET DropDownList OptionGroup support'/><author><name>Mansoor</name><uri>http://www.blogger.com/profile/00473621254256960630</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-7527040749709927669.post-5126592487181511770</id><published>2009-07-07T03:28:00.001-07:00</published><updated>2009-07-07T03:28:31.679-07:00</updated><title type='text'>HGRIDVIEW</title><content type='html'>#region Copyright&lt;br /&gt;// Please do not remove this section. If you can improve it further, you may send a copy to the&lt;br /&gt;// author at azharkhan@hotmail.com &lt;br /&gt;// &lt;br /&gt;// Author : Azhar A. Khan&lt;br /&gt;// Date : 08/27/2008&lt;br /&gt;// Filename : HWGridView.cs&lt;br /&gt;// History : &lt;br /&gt;//            08/27/2008 Initial Version&lt;br /&gt;//            08/28/2008 Romoved  ApplyFilterCommand call from OnFilterCommand, since it will be called in OnPreRender&lt;br /&gt;#endregion&lt;br /&gt;&lt;br /&gt;using System;&lt;br /&gt;using System.Collections.Generic;&lt;br /&gt;using System.Collections;&lt;br /&gt;using System.ComponentModel;&lt;br /&gt;using System.Text;&lt;br /&gt;using System.Web;&lt;br /&gt;using System.Web.UI;&lt;br /&gt;using System.Web.UI.WebControls;&lt;br /&gt;&lt;br /&gt;namespace HWControls&lt;br /&gt;{&lt;br /&gt;    public delegate void FilterCommandEventHandler(object sender, FilterCommandEventArgs e);&lt;br /&gt;&lt;br /&gt;    public class FilterCommandEventArgs : EventArgs&lt;br /&gt;    {&lt;br /&gt;        private string filterExpression;&lt;br /&gt;&lt;br /&gt;        public FilterCommandEventArgs()&lt;br /&gt;        {&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        public FilterCommandEventArgs(string filterExpression)&lt;br /&gt;        {&lt;br /&gt;            this.filterExpression = filterExpression;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        public string FilterExpression&lt;br /&gt;        {&lt;br /&gt;            get&lt;br /&gt;            {&lt;br /&gt;                return this.filterExpression;&lt;br /&gt;            }&lt;br /&gt;            set&lt;br /&gt;            {&lt;br /&gt;                this.filterExpression = value;&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    [ToolboxData("&lt;{0}:HWGridView runat=server&gt;&lt;/{0}:HWGridView&gt;")]&lt;br /&gt;    public class HWGridView : GridView&lt;br /&gt;    {&lt;br /&gt;&lt;br /&gt;        TextBox m_txtPageNo = null;&lt;br /&gt;        Hashtable m_txtFilter = new Hashtable();&lt;br /&gt;        Hashtable m_ddlFilter = new Hashtable();&lt;br /&gt;&lt;br /&gt;        private static readonly object EventFilterCommand = new object();&lt;br /&gt;        // Events&lt;br /&gt;        [Category("Extend GridView Events"), Description("ExtededGridView_OnFilterCommand")]&lt;br /&gt;        public event EventHandler FilterCommand&lt;br /&gt;        {&lt;br /&gt;            add&lt;br /&gt;            {&lt;br /&gt;                base.Events.AddHandler(EventFilterCommand, value);&lt;br /&gt;            }&lt;br /&gt;            remove&lt;br /&gt;            {&lt;br /&gt;                base.Events.RemoveHandler(EventFilterCommand, value);&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        public HWGridView()&lt;br /&gt;        {&lt;br /&gt;            PagerSettings.Position = PagerPosition.TopAndBottom;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;#region Pager&lt;br /&gt;        protected virtual void InitializeTopPager(GridViewRow row, &lt;br /&gt;            int columnSpan, &lt;br /&gt;            PagedDataSource pagedDataSource)&lt;br /&gt;        {&lt;br /&gt;            TableCell cell = new TableCell();&lt;br /&gt;            if (columnSpan &gt; 1)&lt;br /&gt;            {&lt;br /&gt;                cell.ColumnSpan = columnSpan;&lt;br /&gt;            }&lt;br /&gt;            Literal ltrlSpan = new Literal();&lt;br /&gt;            ltrlSpan.Text = "&lt;span style='float:left'&gt;&amp;nbsp;" + &lt;br /&gt;                pagedDataSource.DataSourceCount.ToString() + &lt;br /&gt;                "&amp;nbsp;record(s)&amp;nbsp;found.&lt;/span&gt;";&lt;br /&gt;            cell.Controls.Add(ltrlSpan);&lt;br /&gt;            row.Cells.Add(cell);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        protected virtual void InitializeBottomPager(GridViewRow row, &lt;br /&gt;            int columnSpan, &lt;br /&gt;            PagedDataSource pagedDataSource)&lt;br /&gt;        {&lt;br /&gt;            TableCell goToCell = new TableCell();&lt;br /&gt;            goToCell.Style.Add(HtmlTextWriterStyle.Width, "100%");&lt;br /&gt;&lt;br /&gt;            Table pagerTable = (Table)row.Cells[0].Controls[0];&lt;br /&gt;            pagerTable.Rows[0].Cells.Add(goToCell);&lt;br /&gt;&lt;br /&gt;            Literal ltrlSpanBegin = new Literal();&lt;br /&gt;            ltrlSpanBegin.Text = "&lt;span style='float:right'&gt;Page&amp;nbsp;";&lt;br /&gt;&lt;br /&gt;            if (m_txtPageNo == null)&lt;br /&gt;            {&lt;br /&gt;                m_txtPageNo = new TextBox();&lt;br /&gt;                m_txtPageNo.Width = new Unit(20);&lt;br /&gt;                m_txtPageNo.Style.Add("height", "10px");&lt;br /&gt;                m_txtPageNo.Font.Size = new FontUnit("10px");&lt;br /&gt;                m_txtPageNo.CssClass = this.PagerStyle.CssClass;&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            Literal ltrlText = new Literal();&lt;br /&gt;            ltrlText.Text = "&amp;nbsp;of&amp;nbsp;" + PageCount.ToString();&lt;br /&gt;&lt;br /&gt;            Button btnGo = new Button();&lt;br /&gt;            btnGo.Text = "Go";&lt;br /&gt;            btnGo.CommandName = "Page1";&lt;br /&gt;            btnGo.CommandArgument = "2";&lt;br /&gt;            btnGo.ID = "ctl_PageIndex";&lt;br /&gt;            btnGo.Height = new Unit("16px");&lt;br /&gt;            btnGo.Font.Size = new FontUnit("10px");&lt;br /&gt;            btnGo.CssClass = this.PagerStyle.CssClass;&lt;br /&gt;            if (this.PagerStyle.ForeColor!=null) {&lt;br /&gt;                btnGo.Style.Add(HtmlTextWriterStyle.Color, &lt;br /&gt;                    this.PagerStyle.ForeColor.ToString());&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            Literal ltrlSpanEnd = new Literal();&lt;br /&gt;            ltrlSpanEnd.Text = "&lt;/span&gt;";&lt;br /&gt;&lt;br /&gt;            goToCell.Controls.Add(ltrlSpanBegin);&lt;br /&gt;            goToCell.Controls.Add(m_txtPageNo);&lt;br /&gt;            goToCell.Controls.Add(ltrlText);&lt;br /&gt;            goToCell.Controls.Add(btnGo);&lt;br /&gt;            goToCell.Controls.Add(ltrlSpanEnd);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        protected override void InitializePager(GridViewRow row, &lt;br /&gt;                                                int columnSpan, &lt;br /&gt;                                                PagedDataSource pagedDataSource)&lt;br /&gt;        {&lt;br /&gt;            //if (this.TopPagerRow == null &amp;&amp; &lt;br /&gt;            if (this.Controls[0].Controls.Count == 0 &amp;&amp; &lt;br /&gt;               (this.PagerSettings.Position == PagerPosition.Top || &lt;br /&gt;                this.PagerSettings.Position == PagerPosition.TopAndBottom))&lt;br /&gt;            {&lt;br /&gt;                InitializeTopPager(row, columnSpan, pagedDataSource);&lt;br /&gt;            }&lt;br /&gt;            else&lt;br /&gt;            {&lt;br /&gt;                base.InitializePager(row, columnSpan, pagedDataSource);&lt;br /&gt;                InitializeBottomPager(row, columnSpan, pagedDataSource);&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        protected virtual void HandlePageCommand(GridViewCommandEventArgs e)&lt;br /&gt;        {&lt;br /&gt;            TextBox txtPageIndex;&lt;br /&gt;            txtPageIndex = (TextBox)((System.Web.UI.Control)e.CommandSource).Parent.Controls[1];&lt;br /&gt;            Button btnPageIndex = (Button)((System.Web.UI.Control)e.CommandSource).Parent.Controls[3];&lt;br /&gt;            if (txtPageIndex.Text.Length &gt; 0)&lt;br /&gt;            {&lt;br /&gt;                try&lt;br /&gt;                {&lt;br /&gt;                    int ndx = int.Parse(txtPageIndex.Text);&lt;br /&gt;                    ndx = ndx - 1;&lt;br /&gt;                    if (ndx &gt;= PageCount)&lt;br /&gt;                        ndx = PageCount - 1;&lt;br /&gt;                    if (ndx &lt; 0)&lt;br /&gt;                        ndx = 0;&lt;br /&gt;                    this.PageIndex = ndx;&lt;br /&gt;                    btnPageIndex.CommandArgument = txtPageIndex.Text;&lt;br /&gt;                }&lt;br /&gt;                catch (Exception e1)&lt;br /&gt;                {&lt;br /&gt;                    if (e1.Message.Length == 0)&lt;br /&gt;                        return;&lt;br /&gt;                }&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        protected override void OnRowCommand(GridViewCommandEventArgs e)&lt;br /&gt;        {&lt;br /&gt;            switch (e.CommandName)&lt;br /&gt;            {&lt;br /&gt;                case "Page1":&lt;br /&gt;                    HandlePageCommand(e);&lt;br /&gt;                    break;&lt;br /&gt;                default:&lt;br /&gt;                    base.OnRowCommand(e);&lt;br /&gt;                    break;&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;#endregion&lt;br /&gt;&lt;br /&gt;#region Filter&lt;br /&gt;        protected virtual void AddFilter(int columnIndex, &lt;br /&gt;            TableCell headerCell, &lt;br /&gt;            DataControlField field)&lt;br /&gt;        {&lt;br /&gt;            if (headerCell.Controls.Count == 0)&lt;br /&gt;            {&lt;br /&gt;                LiteralControl ltlHeaderText = new LiteralControl(headerCell.Text);&lt;br /&gt;                headerCell.Controls.Add(ltlHeaderText);&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            LiteralControl ltlBreak = new LiteralControl("&lt;/br&gt;");&lt;br /&gt;            headerCell.Controls.Add(ltlBreak);&lt;br /&gt;            TextBox txtFilter = null;&lt;br /&gt;            if (m_txtFilter.Contains(columnIndex))&lt;br /&gt;            {&lt;br /&gt;                txtFilter = (TextBox)m_txtFilter[columnIndex];&lt;br /&gt;            }&lt;br /&gt;            else&lt;br /&gt;            {&lt;br /&gt;                txtFilter = new TextBox();&lt;br /&gt;                txtFilter.ID = ID + "_txtFilter" + columnIndex.ToString();// +headerCell.ClientID;&lt;br /&gt;                if (field.ItemStyle.Width.Value != 0.0)&lt;br /&gt;                {&lt;br /&gt;                    txtFilter.Style.Add(HtmlTextWriterStyle.Width, Convert.ToString(field.ItemStyle.Width.Value - 40) + "px");&lt;br /&gt;                }&lt;br /&gt;                else if (field.HeaderStyle.Width.Value != 0.0)&lt;br /&gt;                {&lt;br /&gt;                    txtFilter.Style.Add(HtmlTextWriterStyle.Width, Convert.ToString(field.HeaderStyle.Width.Value - 40) + "px");&lt;br /&gt;                }&lt;br /&gt;                txtFilter.Style.Add(HtmlTextWriterStyle.Height, "10px");&lt;br /&gt;                txtFilter.Style.Add(HtmlTextWriterStyle.FontSize, "9px");&lt;br /&gt;                m_txtFilter[columnIndex] = txtFilter;&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            DropDownList ddlFilter;&lt;br /&gt;            if (m_ddlFilter.Contains(columnIndex))&lt;br /&gt;            {&lt;br /&gt;                ddlFilter = (DropDownList)m_ddlFilter[columnIndex];&lt;br /&gt;            }&lt;br /&gt;            else&lt;br /&gt;            {&lt;br /&gt;                ddlFilter = new DropDownList();&lt;br /&gt;                ddlFilter.ID = ID + "_ddlFilter" + columnIndex.ToString();&lt;br /&gt;                ddlFilter.Items.Add(" ");&lt;br /&gt;                ddlFilter.Items.Add("=");&lt;br /&gt;                ddlFilter.Items.Add("&lt;");&lt;br /&gt;                ddlFilter.Items.Add("&gt;");&lt;br /&gt;                ddlFilter.Items.Add("&lt;=");&lt;br /&gt;                ddlFilter.Items.Add("&gt;=");&lt;br /&gt;                ddlFilter.AutoPostBack = true;&lt;br /&gt;                ddlFilter.SelectedIndexChanged += new EventHandler(this.HandleFilterCommand);&lt;br /&gt;                //ddlFilter.SelectedIndex = 0;&lt;br /&gt;                ddlFilter.Style.Add(HtmlTextWriterStyle.Width, "30px");&lt;br /&gt;                ddlFilter.Height = new Unit("7px");&lt;br /&gt;                ddlFilter.Style.Add(HtmlTextWriterStyle.Height, "8px");&lt;br /&gt;                ddlFilter.Style.Add(HtmlTextWriterStyle.FontSize, "8px");&lt;br /&gt;                m_ddlFilter[columnIndex] = ddlFilter;&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            headerCell.Controls.Add(txtFilter);&lt;br /&gt;            headerCell.Controls.Add(ddlFilter);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        protected virtual void AddFilters(GridViewRow headerRow, &lt;br /&gt;            DataControlField[] fields)&lt;br /&gt;        {&lt;br /&gt;            for (int i = 0; i &lt; Columns.Count; i++)&lt;br /&gt;            {&lt;br /&gt;                if (Columns[i].HeaderText.EndsWith(" "))&lt;br /&gt;                {&lt;br /&gt;                    AddFilter(i, headerRow.Cells[i], fields[i]);&lt;br /&gt;                }&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        protected virtual void AddGlyph(GridView grid, GridViewRow item)&lt;br /&gt;        {&lt;br /&gt;            Label glyph = new Label();&lt;br /&gt;            glyph.EnableTheming = false;&lt;br /&gt;            glyph.Font.Name = "webdings";&lt;br /&gt;            glyph.Text = (grid.SortDirection == SortDirection.Ascending ? " 5" : " 6");&lt;br /&gt;            //glyph.Font.Size = FontUnit.Medium;&lt;br /&gt;            //glyph.Text = "&amp;nbsp;" + (grid.SortDirection == SortDirection.Ascending ? "&amp;#9650;" : "&amp;#9660;");&lt;br /&gt;            // Find the column you sorted by&lt;br /&gt;            for (int i = 0; i &lt; grid.Columns.Count; i++)&lt;br /&gt;            {&lt;br /&gt;                string colExpr = grid.Columns[i].SortExpression;&lt;br /&gt;                if (colExpr != "" &amp;&amp; colExpr == grid.SortExpression)&lt;br /&gt;                {&lt;br /&gt;                    item.Cells[i].Controls.Add(glyph);&lt;br /&gt;                }&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        protected virtual void InitializeHeaderRow(GridViewRow row, DataControlField[] fields)&lt;br /&gt;        {&lt;br /&gt;            AddGlyph(this, row);&lt;br /&gt;            AddFilters(row, fields);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        protected override void InitializeRow(GridViewRow row, DataControlField[] fields)&lt;br /&gt;        {&lt;br /&gt;            base.InitializeRow(row, fields);&lt;br /&gt;            if (row.RowType == DataControlRowType.Header)&lt;br /&gt;            {&lt;br /&gt;                InitializeHeaderRow(row, fields);&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        protected virtual String GetFilterCommand()&lt;br /&gt;        {&lt;br /&gt;            String filterCommand = "";&lt;br /&gt;            for (int i = 0; i &lt; this.Columns.Count; i++)&lt;br /&gt;            {&lt;br /&gt;                if (this.Columns[i].HeaderText.EndsWith(" "))&lt;br /&gt;                {&lt;br /&gt;                    DataControlFieldHeaderCell headerCell = (DataControlFieldHeaderCell)this.HeaderRow.Cells[i];&lt;br /&gt;                    TextBox txtFilter = (TextBox)m_txtFilter[i];&lt;br /&gt;                    DropDownList ddlFilter = (DropDownList)m_ddlFilter[i];&lt;br /&gt;                    BoundField aColumn;&lt;br /&gt;                    if (!(this.Columns[i] is BoundField) || String.IsNullOrEmpty(ddlFilter.SelectedValue.Trim()))&lt;br /&gt;                    {&lt;br /&gt;                        continue;&lt;br /&gt;                    }&lt;br /&gt;                    aColumn = (BoundField)this.Columns[i];&lt;br /&gt;                    if (String.IsNullOrEmpty(txtFilter.Text))&lt;br /&gt;                    {&lt;br /&gt;                        continue;&lt;br /&gt;                    }&lt;br /&gt;                    if (String.IsNullOrEmpty(filterCommand))&lt;br /&gt;                    {&lt;br /&gt;                        filterCommand = aColumn.DataField + " " + ddlFilter.SelectedValue + " " + txtFilter.Text;&lt;br /&gt;                    }&lt;br /&gt;                    else&lt;br /&gt;                    {&lt;br /&gt;                        filterCommand += " AND " + aColumn.DataField + " " + ddlFilter.SelectedValue + " " + txtFilter.Text;&lt;br /&gt;                    }&lt;br /&gt;                }&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            return filterCommand;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        protected virtual void ApplyFilterCommand(String filterCommand)&lt;br /&gt;        {&lt;br /&gt;            DataSourceView dsv = this.GetData();&lt;br /&gt;            if (dsv is SqlDataSourceView)&lt;br /&gt;            {&lt;br /&gt;                String selectCommand = ((SqlDataSourceView)dsv).SelectCommand;&lt;br /&gt;                if (selectCommand.Contains(filterCommand)) {&lt;br /&gt;                    return;&lt;br /&gt;                }&lt;br /&gt;                if (selectCommand.Contains("WHERE"))&lt;br /&gt;                {&lt;br /&gt;                    selectCommand += " AND " + filterCommand;&lt;br /&gt;                }&lt;br /&gt;                else&lt;br /&gt;                {&lt;br /&gt;                    selectCommand += " WHERE " + filterCommand;&lt;br /&gt;                }&lt;br /&gt;                ((SqlDataSourceView)dsv).SelectCommand = selectCommand;&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        protected virtual void OnFilterCommand(FilterCommandEventArgs e)&lt;br /&gt;        {&lt;br /&gt;            EventHandler handler = (EventHandler)base.Events[EventFilterCommand];&lt;br /&gt;            if (handler != null)&lt;br /&gt;            {&lt;br /&gt;                handler(this, e);&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private void HandleFilterCommand(object sender, EventArgs e)&lt;br /&gt;        {&lt;br /&gt;            this.RequiresDataBinding = true;  //this is required to make sure that unsetting of filter is also handled&lt;br /&gt;            FilterCommandEventArgs filterArgs = new FilterCommandEventArgs();&lt;br /&gt;            filterArgs.FilterExpression = GetFilterCommand();&lt;br /&gt;            this.OnFilterCommand(filterArgs);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        protected override void OnPreRender(EventArgs e)&lt;br /&gt;        {&lt;br /&gt;            String filterCommand = GetFilterCommand();&lt;br /&gt;&lt;br /&gt;            if (String.IsNullOrEmpty(filterCommand) == false)&lt;br /&gt;            {&lt;br /&gt;                ApplyFilterCommand(filterCommand);&lt;br /&gt;            }&lt;br /&gt;            base.OnPreRender(e);&lt;br /&gt;        }&lt;br /&gt;#endregion&lt;br /&gt;    }&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7527040749709927669-5126592487181511770?l=jaan1762.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jaan1762.blogspot.com/feeds/5126592487181511770/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7527040749709927669&amp;postID=5126592487181511770' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/5126592487181511770'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/5126592487181511770'/><link rel='alternate' type='text/html' href='http://jaan1762.blogspot.com/2009/07/hgridview.html' title='HGRIDVIEW'/><author><name>Mansoor</name><uri>http://www.blogger.com/profile/00473621254256960630</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-7527040749709927669.post-6571529474066277955</id><published>2009-07-07T03:15:00.000-07:00</published><updated>2009-07-07T03:16:42.493-07:00</updated><title type='text'>RANDOM PASSWORD GENERATION</title><content type='html'>RANDOM PASSWORD GENERATION ASPX PAGE&lt;br /&gt;&lt;br /&gt;&amp;lt;%@ Page Language="C#" AutoEventWireup="true" CodeFile="RandomPassword.aspx.cs" Inherits="RandomPassword" %&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;html xmlns="http://www.w3.org/1999/xhtml" &amp;gt;&lt;br /&gt;&amp;lt;head runat="server"&amp;gt;&lt;br /&gt;    &amp;lt;title&amp;gt;Untitled Page&amp;lt;/title&amp;gt;&lt;br /&gt;&amp;lt;/head&amp;gt;&lt;br /&gt;&amp;lt;body&amp;gt;&lt;br /&gt;    &amp;lt;form id="form1" runat="server"&amp;gt;&lt;br /&gt;    &amp;lt;div&amp;gt;&lt;br /&gt;    &amp;lt;div&amp;gt;Enter Password length: &amp;lt;asp:TextBox ID="txtPassLength" runat="server"&amp;gt;&amp;lt;/asp:TextBox&amp;gt;&amp;lt;asp:Button ID="btnGenerate" runat="server" Text="Generate" OnClick="btnGenerate_Click" /&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;    &amp;lt;div&amp;gt;Random Password: &amp;lt;asp:TextBox ID="txtPassword" runat="server"&amp;gt;&amp;lt;/asp:TextBox&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;    &amp;lt;/div&amp;gt;&lt;br /&gt;    &amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;     &amp;lt;div&amp;gt;&lt;br /&gt;            &amp;lt;b&amp;gt;Coding Support Provided By &amp;lt;a href="http://www.top54u.com"&amp;gt;www.top54u.com&amp;lt;/a&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;                &amp;lt;a href="http://programming.top54u.com"&amp;gt;Programming Ezine&amp;lt;/a&amp;gt;&amp;lt;/b&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;            &amp;lt;br /&amp;gt;&lt;br /&gt;        &amp;lt;/div&amp;gt;&lt;br /&gt;    &amp;lt;/form&amp;gt;&lt;br /&gt;&amp;lt;/body&amp;gt;&lt;br /&gt;&amp;lt;/ht&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;CODE BEHIND PAGE&lt;br /&gt;-------------------&lt;br /&gt;&lt;br /&gt;using System;&lt;br /&gt;using System.Data;&lt;br /&gt;using System.Configuration;&lt;br /&gt;using System.Collections;&lt;br /&gt;using System.Web;&lt;br /&gt;using System.Web.Security;&lt;br /&gt;using System.Web.UI;&lt;br /&gt;using System.Web.UI.WebControls;&lt;br /&gt;using System.Web.UI.WebControls.WebParts;&lt;br /&gt;using System.Web.UI.HtmlControls;&lt;br /&gt;&lt;br /&gt;public partial class RandomPassword : System.Web.UI.Page&lt;br /&gt;{&lt;br /&gt;    protected void Page_Load(object sender, EventArgs e)&lt;br /&gt;    {&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;    protected void btnGenerate_Click(object sender, EventArgs e)&lt;br /&gt;    {&lt;br /&gt;        string allowedChars = "";&lt;br /&gt;        allowedChars = "a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,";&lt;br /&gt;        allowedChars += "A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,";&lt;br /&gt;        allowedChars += "1,2,3,4,5,6,7,8,9,0,!,@,#,$,%,&amp;,?";&lt;br /&gt;&lt;br /&gt;        char[] sep ={ ',' };&lt;br /&gt;        string[] arr = allowedChars.Split(sep);&lt;br /&gt;                &lt;br /&gt;        string passwordString = "";&lt;br /&gt;&lt;br /&gt;        string temp = "";&lt;br /&gt;&lt;br /&gt;        Random rand = new Random();&lt;br /&gt;        for (int i = 0; i &lt; Convert.ToInt32(txtPassLength.Text); i++)&lt;br /&gt;        {&lt;br /&gt;            temp = arr[rand.Next(0, arr.Length)];&lt;br /&gt;            passwordString += temp;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        txtPassword.Text = passwordString;&lt;br /&gt;    }&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7527040749709927669-6571529474066277955?l=jaan1762.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jaan1762.blogspot.com/feeds/6571529474066277955/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7527040749709927669&amp;postID=6571529474066277955' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/6571529474066277955'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/6571529474066277955'/><link rel='alternate' type='text/html' href='http://jaan1762.blogspot.com/2009/07/random-password-generation.html' title='RANDOM PASSWORD GENERATION'/><author><name>Mansoor</name><uri>http://www.blogger.com/profile/00473621254256960630</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-7527040749709927669.post-5008245744494971896</id><published>2009-07-07T03:12:00.000-07:00</published><updated>2009-07-07T03:14:38.735-07:00</updated><title type='text'>Fixed Records SP</title><content type='html'>CREATE PROCEDURE [dbo].[Test_Customers_Paginacion] &lt;br /&gt;@PageSize  int = 10,&lt;br /&gt;@PageIndex int = 1&lt;br /&gt;&lt;br /&gt; AS&lt;br /&gt;&lt;br /&gt;DECLARE @RowNumBegin int&lt;br /&gt;DECLARE @RowNumEnd   int&lt;br /&gt;&lt;br /&gt;-- Index based on  "1", so to get the first page&lt;br /&gt;-- we set the param to  @PageIndex = 1&lt;br /&gt;SET @RowNumBegin = (@PageIndex -1) * @PageSize&lt;br /&gt;SET @RowNumEnd   = @RowNumBegin + @PageSize&lt;br /&gt;&lt;br /&gt;-- Make the Quero and add a referente ID to each row by using and auto incremental field&lt;br /&gt;SELECT ContactName, ContactTitle, Address, City, RowNum = Identity (int, 1, 1) &lt;br /&gt;INTO #t&lt;br /&gt;FROM Customers&lt;br /&gt;&lt;br /&gt;-- Select the subset of rows that we want to retrieve&lt;br /&gt;SELECT *&lt;br /&gt;FROM #t&lt;br /&gt;WHERE RowNum BETWEEN @RowNumBegin AND @RowNumEnd&lt;br /&gt;&lt;br /&gt;-- Just to be sure...&lt;br /&gt;DROP TABLE #t&lt;br /&gt;&lt;br /&gt;GO&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7527040749709927669-5008245744494971896?l=jaan1762.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jaan1762.blogspot.com/feeds/5008245744494971896/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7527040749709927669&amp;postID=5008245744494971896' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/5008245744494971896'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/5008245744494971896'/><link rel='alternate' type='text/html' href='http://jaan1762.blogspot.com/2009/07/fixed-records-sp.html' title='Fixed Records SP'/><author><name>Mansoor</name><uri>http://www.blogger.com/profile/00473621254256960630</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-7527040749709927669.post-2214728320502820389</id><published>2009-07-07T03:10:00.000-07:00</published><updated>2009-07-07T03:11:31.170-07:00</updated><title type='text'>GridView Header CheckBox Check</title><content type='html'>&amp;lt;%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;html xmlns="http://www.w3.org/1999/xhtml" &amp;gt;&lt;br /&gt;&amp;lt;head id="Head1" runat="server"&amp;gt;&lt;br /&gt;    &amp;lt;title&amp;gt;Demo&amp;lt;/title&amp;gt;&lt;br /&gt;&amp;lt;/head&amp;gt;&lt;br /&gt;&amp;lt;body onload="AttachListener()"&amp;gt;&lt;br /&gt;    &amp;lt;form id="form1" runat="server"&amp;gt;&lt;br /&gt;    &amp;lt;div&amp;gt;&lt;br /&gt;    &lt;br /&gt;        &amp;lt;asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="4" Font-Names="Verdana" ForeColor="#333333" GridLines="None"&amp;gt;&lt;br /&gt;        &lt;br /&gt;        &amp;lt;Columns&amp;gt;&lt;br /&gt;        &lt;br /&gt;         &amp;lt;asp:TemplateField&amp;gt;&lt;br /&gt;         &lt;br /&gt;         &amp;lt;HeaderTemplate&amp;gt;&lt;br /&gt;        &amp;lt;input type="checkbox" id="chkAll" name="chkAll" onclick="Check(this)" /&amp;gt;&lt;br /&gt;         &amp;lt;/HeaderTemplate&amp;gt;&lt;br /&gt;         &lt;br /&gt;        &amp;lt;ItemTemplate&amp;gt;&lt;br /&gt;        &amp;lt;asp:CheckBox ID="chkSelect" runat="server" /&amp;gt;&lt;br /&gt;        &amp;lt;/ItemTemplate&amp;gt;&lt;br /&gt;        &amp;lt;/asp:TemplateField&amp;gt;&lt;br /&gt;        &lt;br /&gt;        &lt;br /&gt;        &amp;lt;asp:TemplateField HeaderText="Category Name"&amp;gt;&lt;br /&gt;        &amp;lt;ItemTemplate&amp;gt;&lt;br /&gt;        &amp;lt;asp:Label ID="lblCategoryName" runat="server" Text = '&amp;lt;%# Eval("CategoryName") %&amp;gt;' /&amp;gt;&lt;br /&gt;        &amp;lt;/ItemTemplate&amp;gt;&lt;br /&gt;        &amp;lt;/asp:TemplateField&amp;gt;&lt;br /&gt;        &lt;br /&gt;        &amp;lt;/Columns&amp;gt;&lt;br /&gt;            &amp;lt;FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" /&amp;gt;&lt;br /&gt;            &amp;lt;RowStyle BackColor="#FFFBD6" ForeColor="#333333" /&amp;gt;&lt;br /&gt;            &amp;lt;SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" /&amp;gt;&lt;br /&gt;            &amp;lt;PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" /&amp;gt;&lt;br /&gt;            &amp;lt;HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" /&amp;gt;&lt;br /&gt;            &amp;lt;AlternatingRowStyle BackColor="White" /&amp;gt;&lt;br /&gt;        &lt;br /&gt;        &amp;lt;/asp:GridView&amp;gt;&lt;br /&gt;    &lt;br /&gt;    &lt;br /&gt;    &lt;br /&gt;    &lt;br /&gt;    &amp;lt;/div&amp;gt;&lt;br /&gt;    &amp;lt;/form&amp;gt;&lt;br /&gt;&amp;lt;/body&amp;gt;&lt;br /&gt;&amp;lt;/html&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;script language="javascript" type="text/javascript"&amp;gt;&lt;br /&gt;&lt;br /&gt;var counter = 0;&lt;br /&gt; &lt;br /&gt;var pattern = '^GridView1';&lt;br /&gt;&lt;br /&gt;// Get the checkboxes inside the Gridview which is part of the template column&lt;br /&gt;function GetChildCheckBoxCount() &lt;br /&gt;{    &lt;br /&gt;    var checkBoxCount = 0;  &lt;br /&gt;    &lt;br /&gt;    var elements = document.getElementsByTagName("INPUT"); &lt;br /&gt;    &lt;br /&gt;    for(i=0; i&amp;lt;elements.length;i++) &lt;br /&gt;    {&lt;br /&gt;        if(IsCheckBox(elements[i]) &amp;&amp;  IsMatch(elements[i].id)) checkBoxCount++; &lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;   return parseInt(checkBoxCount); &lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;// A function that checks if the checkboxes are the one inside the GridView &lt;br /&gt;function IsMatch(id) &lt;br /&gt;{&lt;br /&gt;    var regularExpresssion = new RegExp(pattern); &lt;br /&gt;    &lt;br /&gt;    if(id.match(regularExpresssion)) return true; &lt;br /&gt;    else return false; &lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;function IsCheckBox(chk) &lt;br /&gt;{&lt;br /&gt;    if(chk.type == 'checkbox') return true; &lt;br /&gt;    else return false;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;function AttachListener()&lt;br /&gt;{&lt;br /&gt;    var elements =  document.getElementsByTagName("INPUT");&lt;br /&gt;    &lt;br /&gt;    for(i=0; i&amp;lt; elements.length; i++) &lt;br /&gt;    {       &lt;br /&gt;        if( IsCheckBox(elements[i]) &amp;&amp;  IsMatch(elements[i].id)) &lt;br /&gt;        {&lt;br /&gt;            AddEvent(elements[i],'click',CheckChild); &lt;br /&gt;        }&lt;br /&gt;    }    &lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;function CheckChild(e) &lt;br /&gt;{&lt;br /&gt;    var evt = e || window.event; &lt;br /&gt;    &lt;br /&gt;    var obj = evt.target || evt.srcElement &lt;br /&gt;  &lt;br /&gt;    if(obj.checked)&lt;br /&gt;    {&lt;br /&gt;        if(counter &amp;lt; GetChildCheckBoxCount()) &lt;br /&gt;            { counter++; }        &lt;br /&gt;    }    &lt;br /&gt;            &lt;br /&gt;    else &lt;br /&gt;    {&lt;br /&gt;       if(counter &amp;gt; 0) { counter--; }    &lt;br /&gt;    } &lt;br /&gt;       &lt;br /&gt;    if(counter == GetChildCheckBoxCount()) &lt;br /&gt;    { document.getElementById("chkAll").checked = true; } &lt;br /&gt;    else if(counter &amp;lt; GetChildCheckBoxCount()) { document.getElementById("chkAll").checked = false; }    &lt;br /&gt;  &lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;function AddEvent(obj, evType, fn) &lt;br /&gt;{&lt;br /&gt;    if (obj.addEventListener)&lt;br /&gt;    {&lt;br /&gt;    obj.addEventListener(evType, fn, true);&lt;br /&gt;    return true;&lt;br /&gt;    }&lt;br /&gt; &lt;br /&gt; else if (obj.attachEvent)&lt;br /&gt; {&lt;br /&gt;    var r = obj.attachEvent("on"+evType, fn);&lt;br /&gt;    return r;&lt;br /&gt; }&lt;br /&gt;  else&lt;br /&gt;   {&lt;br /&gt;    return false;&lt;br /&gt;   }    &lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;function Check(parentChk) &lt;br /&gt;{&lt;br /&gt;    var elements =  document.getElementsByTagName("INPUT"); &lt;br /&gt;    &lt;br /&gt;    for(i=0; i&amp;lt;elements.length;i++) &lt;br /&gt;    {&lt;br /&gt;        if(parentChk.checked == true) &lt;br /&gt;        {  &lt;br /&gt;            if( IsCheckBox(elements[i]) &amp;&amp;  IsMatch(elements[i].id)) &lt;br /&gt;            {&lt;br /&gt;            elements[i].checked = true; &lt;br /&gt;            }         &lt;br /&gt;        }&lt;br /&gt;        else &lt;br /&gt;        {&lt;br /&gt;            elements[i].checked = false; &lt;br /&gt;            // reset the counter &lt;br /&gt;            counter = 0; &lt;br /&gt;        }       &lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;    if(parentChk.checked == true) &lt;br /&gt;    {&lt;br /&gt;        counter = GetChildCheckBoxCount(); &lt;br /&gt;    }   &lt;br /&gt;       &lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;/script&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;  if (!Page.IsPostBack)&lt;br /&gt;        {&lt;br /&gt;            BindData();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt; private void BindData()&lt;br /&gt;    {&lt;br /&gt;        string connectionString = "Server=localhost;Database=Northwind;Trusted_Connection=true";&lt;br /&gt;        SqlConnection myConnection = new SqlConnection(connectionString);&lt;br /&gt;        SqlDataAdapter ad = new SqlDataAdapter("SELECT CategoryID, CategoryName FROM Categories", myConnection);&lt;br /&gt;&lt;br /&gt;        DataSet ds = new DataSet();&lt;br /&gt;        ad.Fill(ds);&lt;br /&gt;&lt;br /&gt;        GridView1.DataSource = ds;&lt;br /&gt;        GridView1.DataBind(); &lt;br /&gt;    }&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7527040749709927669-2214728320502820389?l=jaan1762.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jaan1762.blogspot.com/feeds/2214728320502820389/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7527040749709927669&amp;postID=2214728320502820389' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/2214728320502820389'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/2214728320502820389'/><link rel='alternate' type='text/html' href='http://jaan1762.blogspot.com/2009/07/gridview-header-checkbox-check.html' title='GridView Header CheckBox Check'/><author><name>Mansoor</name><uri>http://www.blogger.com/profile/00473621254256960630</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-7527040749709927669.post-2879281694001003900</id><published>2009-07-07T03:08:00.000-07:00</published><updated>2009-07-07T03:09:41.226-07:00</updated><title type='text'>Custom Pager</title><content type='html'>Custom Pager ASPX PAGE&lt;br /&gt;----------------------&lt;br /&gt;&lt;br /&gt;&amp;lt;html&amp;gt;&lt;br /&gt;&amp;lt;body&amp;gt;&lt;br /&gt;    &amp;lt;form id="Form1" runat="server"&amp;gt;&lt;br /&gt;        &amp;lt;p&amp;gt;&lt;br /&gt;            &amp;lt;asp:DataGrid id="dgSearchResults" runat="server" Width="462px" Height="143px" OnPreRender="DataGrid1_PreRender" OnItemCreated="DataGrid1_ItemCreated" AllowPaging="True" BorderStyle="None" GridLines="Vertical" BorderWidth="1px" BorderColor="#999999" BackColor="White" CellPadding="3" OnPageIndexChanged="dgSearchResults_PageIndexChanged"&amp;gt;&lt;br /&gt;                &amp;lt;FooterStyle forecolor="Black" backcolor="#CCCCCC"&amp;gt;&amp;lt;/FooterStyle&amp;gt;&lt;br /&gt;                &amp;lt;HeaderStyle font-bold="True" forecolor="White" backcolor="#000084"&amp;gt;&amp;lt;/HeaderStyle&amp;gt;&lt;br /&gt;                &amp;lt;PagerStyle horizontalalign="Right" forecolor="Black" position="TopAndBottom" backcolor="#999999" mode="NumericPages"&amp;gt;&amp;lt;/PagerStyle&amp;gt;&lt;br /&gt;                &amp;lt;SelectedItemStyle font-bold="True" forecolor="White" backcolor="#008A8C"&amp;gt;&amp;lt;/SelectedItemStyle&amp;gt;&lt;br /&gt;                &amp;lt;AlternatingItemStyle backcolor="Gainsboro"&amp;gt;&amp;lt;/AlternatingItemStyle&amp;gt;&lt;br /&gt;                &amp;lt;ItemStyle forecolor="Black" backcolor="#EEEEEE"&amp;gt;&amp;lt;/ItemStyle&amp;gt;&lt;br /&gt;            &amp;lt;/asp:DataGrid&amp;gt;&lt;br /&gt;        &amp;lt;/p&amp;gt;&lt;br /&gt;    &amp;lt;/form&amp;gt;&lt;br /&gt;&amp;lt;/body&amp;gt;&lt;br /&gt;&amp;lt;/html&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;%@ Page Language="C#"  Debug="true"%&gt;&lt;br /&gt;&lt;%@ import Namespace="System.Data" %&gt;&lt;br /&gt;&lt;%@ import Namespace="System.Data.SqlClient" %&gt;&lt;br /&gt;&lt;script runat="server"&gt;&lt;br /&gt;    void Page_Load(Object sender, EventArgs e)&lt;br /&gt;    {&lt;br /&gt;        if (!IsPostBack)&lt;br /&gt;        {&lt;br /&gt;            BindData();&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;    private void BindData()&lt;br /&gt;    {&lt;br /&gt;        SqlConnection myConnection;&lt;br /&gt;        SqlDataAdapter myAdapter;&lt;br /&gt;        string CmdStr;&lt;br /&gt;        string ConnStr;&lt;br /&gt;        DataSet ds = new DataSet();&lt;br /&gt;    &lt;br /&gt;        // Establish Connection&lt;br /&gt;        ConnStr = "server=localhost;uid=sa;pwd=;database=pubs";&lt;br /&gt;        myConnection = new SqlConnection(ConnStr);&lt;br /&gt;    &lt;br /&gt;        // Run Query and Fill DataSet&lt;br /&gt;        CmdStr = "select au_id as ID, au_fname as FirstName, au_lname as LastName from authors order by au_lname";&lt;br /&gt;        myAdapter = new SqlDataAdapter(CmdStr, myConnection);&lt;br /&gt;        myAdapter.Fill(ds, "Authors");&lt;br /&gt;    &lt;br /&gt;        // Bind to Grid&lt;br /&gt;        dgSearchResults.DataSource = ds.Tables["Authors"].DefaultView;&lt;br /&gt;        dgSearchResults.DataBind();&lt;br /&gt;    &lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;    void DataGrid1_PreRender(Object sender, EventArgs e)&lt;br /&gt;    {&lt;br /&gt;      try&lt;br /&gt;        {&lt;br /&gt;            //Find the Labels and Set to the Record Count&lt;br /&gt;            ((Label)dgSearchResults.Controls[0].Controls[0].FindControl("lblNumRecords")).Text = ((DataView)dgSearchResults.DataSource).Count.ToString() + " records found"; //This Line Sets the Label at the Top. Remove if only using the Pager at the bottom.&lt;br /&gt;            ((Label)dgSearchResults.Controls[0].Controls[dgSearchResults.Controls[0].Controls.Count - 1].FindControl("lblNumRecords")).Text = ((DataView)dgSearchResults.DataSource).Count.ToString() + " records found"; //This Line Sets the Label at the Bottom. Remove if only using the Pager at the top.&lt;br /&gt;        }&lt;br /&gt;        catch&lt;br /&gt;        {}&lt;br /&gt;    &lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;    void DataGrid1_ItemCreated(Object sender, DataGridItemEventArgs e)&lt;br /&gt;    {&lt;br /&gt;    &lt;br /&gt;        // Get the newly created item&lt;br /&gt;        ListItemType itemType = e.Item.ItemType;&lt;br /&gt;    &lt;br /&gt;        // Is it the pager?&lt;br /&gt;        if (itemType == ListItemType.Pager)&lt;br /&gt;        {&lt;br /&gt;            // Extract the Pager&lt;br /&gt;            TableCell pager = (TableCell)e.Item.Controls[0];&lt;br /&gt;    &lt;br /&gt;            //Add Cell to Row to Hold Row Count Label&lt;br /&gt;            TableCell newcell = new TableCell();&lt;br /&gt;            newcell.ColumnSpan = 1;&lt;br /&gt;            newcell.HorizontalAlign = HorizontalAlign.Left;&lt;br /&gt;            newcell.Style["border-color"] = pager.Style["border-color"]; //Set Border so the Pager Row looks seamless&lt;br /&gt;    &lt;br /&gt;            //Add Label Indicating Row Count&lt;br /&gt;            Label lblNumRecords = new Label();&lt;br /&gt;            lblNumRecords.ID = "lblNumRecords";&lt;br /&gt;            newcell.Controls.Add(lblNumRecords);&lt;br /&gt;    &lt;br /&gt;            //Add Table Cell to Pager&lt;br /&gt;            e.Item.Controls.AddAt(0, newcell);&lt;br /&gt;    &lt;br /&gt;            //Subtract from Colspan of Original Pager to Account for New Row&lt;br /&gt;            pager.ColumnSpan = pager.ColumnSpan - 1;&lt;br /&gt;        }&lt;br /&gt;    &lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;    void dgSearchResults_PageIndexChanged(Object source, DataGridPageChangedEventArgs e)&lt;br /&gt;    {&lt;br /&gt;        dgSearchResults.CurrentPageIndex= e.NewPageIndex;&lt;br /&gt;        BindData();&lt;br /&gt;    }&lt;br /&gt;&lt;/script&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7527040749709927669-2879281694001003900?l=jaan1762.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jaan1762.blogspot.com/feeds/2879281694001003900/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7527040749709927669&amp;postID=2879281694001003900' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/2879281694001003900'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/2879281694001003900'/><link rel='alternate' type='text/html' href='http://jaan1762.blogspot.com/2009/07/custom-pager.html' title='Custom Pager'/><author><name>Mansoor</name><uri>http://www.blogger.com/profile/00473621254256960630</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-7527040749709927669.post-4918574779959825070</id><published>2009-07-07T03:02:00.000-07:00</published><updated>2009-07-07T03:06:52.146-07:00</updated><title type='text'>Gridview Highlight Search</title><content type='html'>ASPX Page&lt;br /&gt;---------&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&amp;gt;&lt;br /&gt;&amp;lt;html xmlns="http://www.w3.org/1999/xhtml"&amp;gt;&lt;br /&gt;&amp;lt;head id="Head1" runat="server"&amp;gt;&lt;br /&gt;    &amp;lt;title&amp;gt;Untitled Page&amp;lt;/title&amp;gt;&lt;br /&gt;    &amp;lt;style type="text/css"&amp;gt;&lt;br /&gt;    &lt;br /&gt;    .highlight &lt;br /&gt;    {&lt;br /&gt;        background:Yellow;&lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;    &amp;lt;/style&amp;gt;&lt;br /&gt;&amp;lt;/head&amp;gt;&lt;br /&gt;&amp;lt;body&amp;gt;&lt;br /&gt;    &amp;lt;form id="form1" runat="server"&amp;gt;&lt;br /&gt;        &amp;lt;div&amp;gt;&lt;br /&gt;            Enter Search Keyword:&lt;br /&gt;            &amp;lt;asp:TextBox ID="txtSearchBox" runat="server" Text="Ca" /&amp;gt;&lt;br /&gt;            &amp;lt;asp:Button ID="Btn_Search" OnClick="Search" runat="server" Text="Search" /&amp;gt;&lt;br /&gt;            &amp;lt;br /&amp;gt;&lt;br /&gt;            &amp;lt;br /&amp;gt;&lt;br /&gt;            &amp;lt;br /&amp;gt;&lt;br /&gt;            &amp;lt;asp:GridView ID="gvProducts" runat="server" AutoGenerateColumns="false" AllowPaging="True"&lt;br /&gt;                Font-Size="Large" OnPageIndexChanging="gvProducts_PageIndexChanging" PageSize="10"&amp;gt;&lt;br /&gt;                &amp;lt;Columns&amp;gt;&lt;br /&gt;                    &amp;lt;asp:TemplateField HeaderText="Product Name"&amp;gt;&lt;br /&gt;                        &amp;lt;ItemTemplate&amp;gt;&lt;br /&gt;                            &amp;lt;asp:Label ID="lblProductName" runat="server" Text='&amp;lt;%# SearchKeyWord( searchWord,(string) Eval("emp_name") ) %&amp;gt;' /&amp;gt;&lt;br /&gt;                        &amp;lt;/ItemTemplate&amp;gt;&lt;br /&gt;                    &amp;lt;/asp:TemplateField&amp;gt;&lt;br /&gt;                &amp;lt;/Columns&amp;gt;&lt;br /&gt;            &amp;lt;/asp:GridView&amp;gt;&lt;br /&gt;            &amp;lt;br /&amp;gt;&lt;br /&gt;            &amp;nbsp;&lt;br /&gt;            &amp;lt;asp:Panel ID="Panel1" runat="server" Height="50px" Width="263px"&amp;gt;&lt;br /&gt;            &amp;lt;/asp:Panel&amp;gt;&lt;br /&gt;            &amp;lt;br /&amp;gt;&lt;br /&gt;            &amp;lt;br /&amp;gt;&lt;br /&gt;            &amp;lt;br /&amp;gt;&lt;br /&gt;            &amp;nbsp;&amp;lt;/div&amp;gt;&lt;br /&gt;    &amp;lt;/form&amp;gt;&lt;br /&gt;&amp;lt;/body&amp;gt;&lt;br /&gt;&amp;lt;/html&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Code Behind Page&lt;br /&gt;----------------&lt;br /&gt;&lt;br /&gt;using System;&lt;br /&gt;using System.Data;&lt;br /&gt;using System.Configuration;&lt;br /&gt;using System.Collections;&lt;br /&gt;using System.Web;&lt;br /&gt;using System.Web.Security;&lt;br /&gt;using System.Web.UI;&lt;br /&gt;using System.Web.UI.WebControls;&lt;br /&gt;using System.Web.UI.WebControls.WebParts;&lt;br /&gt;using System.Web.UI.HtmlControls;&lt;br /&gt;using System.Data.SqlClient;&lt;br /&gt;using System.Text.RegularExpressions;&lt;br /&gt;&lt;br /&gt;public partial class _Default : System.Web.UI.Page&lt;br /&gt;{&lt;br /&gt;    protected string searchWord = String.Empty;   &lt;br /&gt;    private const int PAGE_SIZE = 10;&lt;br /&gt;&lt;br /&gt;    private Hashtable hMatches = new Hashtable();   &lt;br /&gt;    &lt;br /&gt;    protected void Page_Load(object sender, EventArgs e)&lt;br /&gt;    {&lt;br /&gt;        if (!Page.IsPostBack)&lt;br /&gt;        {&lt;br /&gt;            BindData();    &lt;br /&gt;        }       &lt;br /&gt;&lt;br /&gt;        CreateLinks(); &lt;br /&gt;       &lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    private void CreateLinks()&lt;br /&gt;    {&lt;br /&gt;        Hashtable myHashTable = ViewState["MyHashTable"] as Hashtable; &lt;br /&gt;&lt;br /&gt;        if(myHashTable != null &amp;&amp; myHashTable.Count &gt; 0) &lt;br /&gt;        {&lt;br /&gt;&lt;br /&gt;        foreach (object key in new ArrayList(myHashTable.Keys))&lt;br /&gt;        {&lt;br /&gt;            LinkButton link = new LinkButton();&lt;br /&gt;            link.Command += new CommandEventHandler(link_Command);&lt;br /&gt;            link.CommandArgument = key.ToString();&lt;br /&gt;            link.Text = String.Format("There are {0} results on page {1}",myHashTable[key].ToString() , (Convert.ToInt32(key) + 1).ToString()) + "&lt;BR&gt;";&lt;br /&gt;                                   &lt;br /&gt;            Panel1.Controls.Add(link);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        Panel1.DataBind();&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    private void BindData()&lt;br /&gt;    {&lt;br /&gt;        string connectionString = "Server=SERVERNAME;Database=TestDB;user=rsmsuser;pwd=rsmsuser";&lt;br /&gt;        SqlConnection myConnection = new SqlConnection(connectionString);&lt;br /&gt;        SqlDataAdapter ad = new SqlDataAdapter("SELECT emp_id, emp_name FROM ali_employee", myConnection);&lt;br /&gt;&lt;br /&gt;        DataSet ds = new DataSet();&lt;br /&gt;        ad.Fill(ds);&lt;br /&gt;&lt;br /&gt;        gvProducts.DataSource = ds;&lt;br /&gt;        gvProducts.DataBind(); &lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    protected void Search(object sender, EventArgs e)&lt;br /&gt;    {&lt;br /&gt;        // clear the old results &lt;br /&gt;        Panel1.Controls.Clear();&lt;br /&gt;        Panel1.DataBind(); &lt;br /&gt;        &lt;br /&gt;        searchWord = txtSearchBox.Text;&lt;br /&gt;        SearchContainer(searchWord);      &lt;br /&gt;&lt;br /&gt;        // Hmmm  &lt;br /&gt;        BindData();      &lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    protected string SearchKeyWord(string searchString, string text)&lt;br /&gt;    {&lt;br /&gt;        Regex reg = new Regex(searchString.Replace(" ", "|"), RegexOptions.IgnoreCase);&lt;br /&gt;        return reg.Replace(text,new MatchEvaluator(ReplaceKeyWords));   &lt;br /&gt;        &lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    private void SearchContainer(string searchString)&lt;br /&gt;    {&lt;br /&gt;        int index = 0;        &lt;br /&gt;&lt;br /&gt;        // get the container&lt;br /&gt;        DataSet ds = GetDataSet(); &lt;br /&gt;       &lt;br /&gt;&lt;br /&gt;        double pageIndex = 0; &lt;br /&gt;&lt;br /&gt;        Regex reg = new Regex(searchString.Replace(" ","|"),RegexOptions.IgnoreCase); &lt;br /&gt;&lt;br /&gt;        foreach(DataRow row in ds.Tables[0].Rows) &lt;br /&gt;        {&lt;br /&gt;            if (reg.IsMatch(row["emp_name"] as String))&lt;br /&gt;            {&lt;br /&gt;                pageIndex = Math.Ceiling( Convert.ToDouble( index / PAGE_SIZE ));&lt;br /&gt;&lt;br /&gt;                if (hMatches.ContainsKey(pageIndex))&lt;br /&gt;                {&lt;br /&gt;                    hMatches[pageIndex] = ((int)hMatches[pageIndex]) + 1;&lt;br /&gt;                }&lt;br /&gt;                else&lt;br /&gt;                {&lt;br /&gt;                    hMatches.Add(pageIndex, 1); &lt;br /&gt;                }               &lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            index++; &lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        ViewState["MyHashTable"] = hMatches;&lt;br /&gt;&lt;br /&gt;        CreateLinks(); &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    void link_Command(object sender, CommandEventArgs e)&lt;br /&gt;    {&lt;br /&gt;        gvProducts.PageIndex = Convert.ToInt32( e.CommandArgument);&lt;br /&gt;        searchWord = txtSearchBox.Text;&lt;br /&gt;        BindData(); &lt;br /&gt;    }   &lt;br /&gt;&lt;br /&gt;    private DataSet GetDataSet()&lt;br /&gt;    {&lt;br /&gt;        string connectionString = "Server=SERVERNAME;Database=TestDB;user=rsmsuser;pwd=rsmsuser";&lt;br /&gt;        SqlConnection myConnection = new SqlConnection(connectionString);&lt;br /&gt;        SqlDataAdapter ad = new SqlDataAdapter("SELECT emp_id, emp_name FROM ali_employee", myConnection);&lt;br /&gt;&lt;br /&gt;        DataSet ds = new DataSet();&lt;br /&gt;&lt;br /&gt;        ad.Fill(ds); &lt;br /&gt;&lt;br /&gt;        return ds; &lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    private string ReplaceKeyWords(Match m)&lt;br /&gt;    {&lt;br /&gt;        return "&lt;span class='highlight'&gt;" + m.Value + "&lt;/span&gt;"; &lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    protected void gvProducts_PageIndexChanging(object sender, GridViewPageEventArgs e)&lt;br /&gt;    {&lt;br /&gt;        gvProducts.PageIndex = e.NewPageIndex;&lt;br /&gt;        searchWord = txtSearchBox.Text;&lt;br /&gt;        BindData(); &lt;br /&gt;    }   &lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7527040749709927669-4918574779959825070?l=jaan1762.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jaan1762.blogspot.com/feeds/4918574779959825070/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7527040749709927669&amp;postID=4918574779959825070' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/4918574779959825070'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/4918574779959825070'/><link rel='alternate' type='text/html' href='http://jaan1762.blogspot.com/2009/07/gridview-highlight-search.html' title='Gridview Highlight Search'/><author><name>Mansoor</name><uri>http://www.blogger.com/profile/00473621254256960630</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-7527040749709927669.post-5832220463911587264</id><published>2009-07-06T23:47:00.000-07:00</published><updated>2009-07-06T23:58:11.364-07:00</updated><title type='text'>Document Saving and Retrieving fom Database</title><content type='html'>Document Saving in Database&lt;br /&gt;----------------------------&lt;br /&gt;&lt;br /&gt;Table Structure&lt;br /&gt;---------------&lt;br /&gt;&lt;br /&gt;CREATE TABLE [dbo].[eDocuments](&lt;br /&gt; [DownloadID] [int] IDENTITY(1,1) NOT NULL,&lt;br /&gt; [DocTitle] [varchar](200) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,&lt;br /&gt; [DocStream] [image] NULL,&lt;br /&gt; [DocExt] [varchar](5) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,&lt;br /&gt; [DocSize] [float] NULL,&lt;br /&gt; [DocType] [varchar](25) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,&lt;br /&gt; [Decription] [varchar](500) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,&lt;br /&gt; [ReviewDate] [datetime] NULL DEFAULT (getdate())&lt;br /&gt;) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]&lt;br /&gt;&lt;br /&gt;Procedure for Saving Document Data into Database&lt;br /&gt;-------------------------------------------------&lt;br /&gt;&lt;br /&gt;CREATE PROC [dbo].[eDocumentsUPD]&lt;br /&gt;(&lt;br /&gt; @DownloadID INT=0,&lt;br /&gt; @DocTitle VARCHAR(200),&lt;br /&gt; @DocStream IMAGE,&lt;br /&gt; @DocExt VARCHAR(5),&lt;br /&gt; @DocSize FLOAT,&lt;br /&gt; @DocType VARCHAR(25),&lt;br /&gt; @Decription VARCHAR(500)=NULL&lt;br /&gt;)&lt;br /&gt;AS&lt;br /&gt;DECLARE @RECORDCOUNT INT&lt;br /&gt;SET @RECORDCOUNT=0&lt;br /&gt;SELECT @RECORDCOUNT=COUNT(*)&lt;br /&gt;FROM eDocuments&lt;br /&gt;WHERE DownloadID=@DownloadID &lt;br /&gt;  &lt;br /&gt;IF @RECORDCOUNT=0&lt;br /&gt;BEGIN&lt;br /&gt; INSERT INTO  eDocuments&lt;br /&gt; (&lt;br /&gt; DocTitle,DocStream,DocExt,DocSize,DocType,Decription ,ReviewDate&lt;br /&gt; )&lt;br /&gt; SELECT @DocTitle,@DocStream,@DocExt,@DocSize,@DocType,@Decription ,GETDATE()&lt;br /&gt; Select @DownloadID=IDENT_CURRENT('eCtblDownloadableDocuments')&lt;br /&gt;END&lt;br /&gt;ELSE&lt;br /&gt;BEGIN&lt;br /&gt;UPDATE eDocuments&lt;br /&gt;SET DocTitle=DocTitle,&lt;br /&gt; DocStream=DocStream,&lt;br /&gt; DocExt=DocExt,&lt;br /&gt; DocSize=DocSize,&lt;br /&gt; DocType=DocType,&lt;br /&gt; Decription= Decription ,&lt;br /&gt; ReviewDate=GETDATE()&lt;br /&gt;WHERE  DownloadID=DownloadID &lt;br /&gt;&lt;br /&gt;END&lt;br /&gt;  &lt;br /&gt;select @DownloadID   as DownloadID&lt;br /&gt;&lt;br /&gt;IF @@error!=0&lt;br /&gt;BEGIN &lt;br /&gt;&lt;br /&gt; RAISERROR 20001 'eDocumentsUPD: Failed Insert/Updae Records Into eDocuments'&lt;br /&gt;&lt;br /&gt; RETURN(1)&lt;br /&gt;&lt;br /&gt;END&lt;br /&gt;&lt;br /&gt; RETURN(0)&lt;br /&gt;&lt;br /&gt;Stored Procedure for Getting Documents Info Based on DocumentID&lt;br /&gt;---------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;CREATE PROC [dbo].[eDocumentsGETByID]&lt;br /&gt;@DownloadID int&lt;br /&gt;AS&lt;br /&gt;&lt;br /&gt;SELECT &lt;br /&gt;ISNULL(DownloadID,0) AS DownloadID ,&lt;br /&gt;ISNULL(DocTitle,'') AS DocTitle,&lt;br /&gt;DocStream,&lt;br /&gt;ISNULL(DocExt,'') AS DocExt,&lt;br /&gt;ISNULL(DocSize,0) AS DocSize,&lt;br /&gt;ISNULL(DocType,'') AS DocType,&lt;br /&gt;ISNULL(Decription,'') AS  Decription ,&lt;br /&gt;ReviewDate&lt;br /&gt;&lt;br /&gt;FROM eDocuments&lt;br /&gt;where DownloadID=@DownloadID&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7527040749709927669-5832220463911587264?l=jaan1762.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jaan1762.blogspot.com/feeds/5832220463911587264/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7527040749709927669&amp;postID=5832220463911587264' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/5832220463911587264'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/5832220463911587264'/><link rel='alternate' type='text/html' href='http://jaan1762.blogspot.com/2009/07/document-saving-and-retrieving-fom.html' title='Document Saving and Retrieving fom Database'/><author><name>Mansoor</name><uri>http://www.blogger.com/profile/00473621254256960630</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-7527040749709927669.post-3215526445428839787</id><published>2009-07-06T23:25:00.000-07:00</published><updated>2009-07-06T23:30:43.930-07:00</updated><title type='text'>Error Saving SP and Table Structure in Database</title><content type='html'>&lt;strong&gt;Error Table Structure inorder to maintain Error data in database&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;CREATE TABLE [dbo].[PRJtblErrors](&lt;br /&gt; [ErrorNumber] [int] NULL,&lt;br /&gt; [ErrorSeverity] [int] NULL,&lt;br /&gt; [ErrorState] [int] NULL,&lt;br /&gt; [ErrorProcedure] [nvarchar](128) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,&lt;br /&gt; [ErrorLine] [int] NULL,&lt;br /&gt; [ErrorMessage] [nvarchar](4000) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,&lt;br /&gt; [ErrorDate] [datetime] NOT NULL DEFAULT (getdate()),&lt;br /&gt; [UserName] [varchar](150) COLLATE SQL_Latin1_General_CP1_CI_AS NULL DEFAULT ('DBAdmin'),&lt;br /&gt; [ModuleName] [varchar](150) COLLATE SQL_Latin1_General_CP1_CI_AS NULL DEFAULT (db_name()),&lt;br /&gt; [ScreenName] [varchar](150) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,&lt;br /&gt; [FunctionNameOrMethodName] [varchar](150) COLLATE SQL_Latin1_General_CP1_CI_AS NULL&lt;br /&gt;) ON [PRIMARY]&lt;br /&gt;&lt;br /&gt;------------------------------------------&lt;br /&gt;Call this procedure in the catch  block&lt;br /&gt;------------------------------------------&lt;br /&gt;&lt;br /&gt;Sample &lt;br /&gt;------&lt;br /&gt;BEGIN&lt;br /&gt;TRY&lt;br /&gt;&lt;br /&gt;End Try&lt;br /&gt;Begin Catch&lt;br /&gt;Execute PRJspErrorInfo&lt;br /&gt;End Catch&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt;-----------------------------------------------------------------------------------------&lt;br /&gt;-- Stored Proc Name: &lt;br /&gt;-- Author    : &lt;br /&gt;-- Date Created    : &lt;br /&gt;-- Version    : &lt;br /&gt;-- Last Revision   : &lt;br /&gt;-- Function    :&lt;br /&gt;--     : &lt;br /&gt;-------------------------------------------------------------------------------------------&lt;br /&gt;**/&lt;br /&gt;&lt;br /&gt;CREATE PROCEDURE [dbo].[PRJspErrorInfoSave]&lt;br /&gt;AS&lt;br /&gt;BEGIN&lt;br /&gt; INSERT INTO PRJtblErrors&lt;br /&gt;    (&lt;br /&gt;  ErrorNumber,&lt;br /&gt;        ErrorSeverity,&lt;br /&gt;        ErrorState,&lt;br /&gt;        ErrorProcedure,&lt;br /&gt;        ErrorLine,&lt;br /&gt;        ErrorMessage&lt;br /&gt;     )&lt;br /&gt;    SELECT&lt;br /&gt;        ERROR_NUMBER() AS ErrorNumber,&lt;br /&gt;        ERROR_SEVERITY() AS ErrorSeverity,&lt;br /&gt;        ERROR_STATE() AS ErrorState,&lt;br /&gt;        ERROR_PROCEDURE() AS ErrorProcedure,&lt;br /&gt;        ERROR_LINE() AS ErrorLine,&lt;br /&gt;        ERROR_MESSAGE() AS ErrorMessage;&lt;br /&gt;END&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7527040749709927669-3215526445428839787?l=jaan1762.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jaan1762.blogspot.com/feeds/3215526445428839787/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7527040749709927669&amp;postID=3215526445428839787' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/3215526445428839787'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/3215526445428839787'/><link rel='alternate' type='text/html' href='http://jaan1762.blogspot.com/2009/07/error-saving-sp-and-table-structure-in.html' title='Error Saving SP and Table Structure in Database'/><author><name>Mansoor</name><uri>http://www.blogger.com/profile/00473621254256960630</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-7527040749709927669.post-5007393053377777447</id><published>2009-07-06T23:22:00.000-07:00</published><updated>2009-07-06T23:24:07.172-07:00</updated><title type='text'>Stored Procedure for Saving Address Information</title><content type='html'>&lt;strong&gt;Procedure for Saving Address Information&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt;-----------------------------------------------------------------------------------------&lt;br /&gt;-- Stored Proc Name: &lt;br /&gt;-- Author    : &lt;br /&gt;-- Date Created    : &lt;br /&gt;-- Version    : 1.0&lt;br /&gt;-- Last Revision   : &lt;br /&gt;-- Function    :&lt;br /&gt;--     : &lt;br /&gt;-------------------------------------------------------------------------------------------&lt;br /&gt;**/&lt;br /&gt;CREATE PROCEDURE  [dbo].[eCspAddressInfoSave]&lt;br /&gt;(&lt;br /&gt;@AddressID   INT,&lt;br /&gt;@RefID   INT,&lt;br /&gt;@RefType  VARCHAR(50),&lt;br /&gt;@Street  VARCHAR(50)=Null,&lt;br /&gt;@Location  VARCHAR(50)=Null,&lt;br /&gt;@City  VARCHAR(50)=Null,&lt;br /&gt;@State   INT=0,&lt;br /&gt;@Country   INT=0,&lt;br /&gt;@Zip  VARCHAR(50)=Null,&lt;br /&gt;@Phone1  VARCHAR(50)=Null,&lt;br /&gt;@Phone2  VARCHAR(50)=Null,&lt;br /&gt;@Fax  VARCHAR(50)=Null,&lt;br /&gt;@Email  VARCHAR(200)=Null,&lt;br /&gt;@CreatedBy  VARCHAR(50)=Null,&lt;br /&gt;@ModifiedBy  VARCHAR(50)=Null&lt;br /&gt;)&lt;br /&gt;AS&lt;br /&gt;DECLARE @RECORDCOUNT INT&lt;br /&gt;SET @RECORDCOUNT=0&lt;br /&gt;SELECT @RECORDCOUNT=COUNT(*)&lt;br /&gt;FROM AddressInfo&lt;br /&gt;WHERE AddressID=@AddressID &lt;br /&gt;  &lt;br /&gt;IF @RECORDCOUNT=0&lt;br /&gt;BEGIN&lt;br /&gt;   &lt;br /&gt;  INSERT INTO AddressInfo (&lt;br /&gt;  RefID,&lt;br /&gt;  RefType,&lt;br /&gt;  Street,&lt;br /&gt;  Location,&lt;br /&gt;  City,&lt;br /&gt;  State,&lt;br /&gt;  Country,&lt;br /&gt;  Zip,&lt;br /&gt;  Phone1,&lt;br /&gt;  Phone2,&lt;br /&gt;  Fax,&lt;br /&gt;  Email,&lt;br /&gt;  CreatedBy,&lt;br /&gt;  CreatedDate,&lt;br /&gt;  ModifiedBy,&lt;br /&gt;  ModifiedDate&lt;br /&gt;  )&lt;br /&gt;   VALUES (&lt;br /&gt;  @RefID,&lt;br /&gt;  @RefType,&lt;br /&gt;  @Street,&lt;br /&gt;  @Location,&lt;br /&gt;  @City,&lt;br /&gt;  @State,&lt;br /&gt;  @Country,&lt;br /&gt;  @Zip,&lt;br /&gt;  @Phone1,&lt;br /&gt;  @Phone2,&lt;br /&gt;  @Fax,&lt;br /&gt;  @Email,&lt;br /&gt;  @CreatedBy,&lt;br /&gt;  GETDATE() ,&lt;br /&gt;  @ModifiedBy,&lt;br /&gt;  GETDATE()&lt;br /&gt;  )&lt;br /&gt;Select @AddressID=@@Identity&lt;br /&gt;END&lt;br /&gt;ELSE&lt;br /&gt;BEGIN&lt;br /&gt;  UPDATE  AddressInfo&lt;br /&gt;  SET&lt;br /&gt;  RefID=@RefID,&lt;br /&gt;  RefType=@RefType,&lt;br /&gt;  Street=@Street,&lt;br /&gt;  Location=@Location,&lt;br /&gt;  City=@City,&lt;br /&gt;  State=@State,&lt;br /&gt;  Country=@Country,&lt;br /&gt;  Zip=@Zip,&lt;br /&gt;  Phone1=@Phone1,&lt;br /&gt;  Phone2=@Phone2,&lt;br /&gt;  Fax=@Fax,&lt;br /&gt;  Email=@Email,&lt;br /&gt;  ModifiedBy=@ModifiedBy,&lt;br /&gt;  ModifiedDate=GETDATE()&lt;br /&gt;  WHERE AddressID=@AddressID&lt;br /&gt; &lt;br /&gt; &lt;br /&gt; &lt;br /&gt;END&lt;br /&gt;  &lt;br /&gt;select @AddressID   as AddressID&lt;br /&gt;&lt;br /&gt;IF @@error!=0&lt;br /&gt;BEGIN &lt;br /&gt;&lt;br /&gt; RAISERROR 20001 'eCspAddressInfoSave: Failed Insert/Updae Records Into eCtblAddressInfo'&lt;br /&gt;&lt;br /&gt; RETURN(1)&lt;br /&gt;&lt;br /&gt;END&lt;br /&gt;&lt;br /&gt; RETURN(0)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7527040749709927669-5007393053377777447?l=jaan1762.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jaan1762.blogspot.com/feeds/5007393053377777447/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7527040749709927669&amp;postID=5007393053377777447' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/5007393053377777447'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/5007393053377777447'/><link rel='alternate' type='text/html' href='http://jaan1762.blogspot.com/2009/07/stored-procedure-for-saving-address.html' title='Stored Procedure for Saving Address Information'/><author><name>Mansoor</name><uri>http://www.blogger.com/profile/00473621254256960630</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-7527040749709927669.post-240450703339686259</id><published>2009-07-06T23:17:00.000-07:00</published><updated>2009-07-06T23:20:11.396-07:00</updated><title type='text'>Scalar Valued Functions in SQL Server - Sample To Retrieve Name</title><content type='html'>&lt;strong&gt;This Function takes ID as the input Parameter and fetches down the name and returns it.&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;CREATE function [dbo].[fnName](@ID int)&lt;br /&gt;returns varchar(200)&lt;br /&gt;as&lt;br /&gt;begin &lt;br /&gt;declare @Name varchar(200)&lt;br /&gt;set @Name=''&lt;br /&gt;&lt;br /&gt;SELECT @Name= LTRIM(RTRIM(REPLACE(ISNULL(E.FirstName,'')+' '+ISNULL(E.MiddleName,'')+' '+ISNULL(E.LastName,''),'  ',' ')))&lt;br /&gt;  FROM dbo.USERInfo E&lt;br /&gt;WHERE E.USERID=@ID&lt;br /&gt;&lt;br /&gt;set @Name=ISNULL(@Name,'')&lt;br /&gt;&lt;br /&gt;return @Name&lt;br /&gt;end&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7527040749709927669-240450703339686259?l=jaan1762.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jaan1762.blogspot.com/feeds/240450703339686259/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7527040749709927669&amp;postID=240450703339686259' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/240450703339686259'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/240450703339686259'/><link rel='alternate' type='text/html' href='http://jaan1762.blogspot.com/2009/07/scalar-valued-functions-in-sql-server.html' title='Scalar Valued Functions in SQL Server - Sample To Retrieve Name'/><author><name>Mansoor</name><uri>http://www.blogger.com/profile/00473621254256960630</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-7527040749709927669.post-916206976012403120</id><published>2009-07-06T23:13:00.000-07:00</published><updated>2009-07-06T23:15:08.395-07:00</updated><title type='text'>Split Function in SqlServer</title><content type='html'>/**&lt;br /&gt;-----------------------------------------------------------------------------------------&lt;br /&gt;-- Function Name:   Split &lt;br /&gt;-- Function    : Split String and Convert into Table&lt;br /&gt;   Return Type: Table&lt;br /&gt;--     : &lt;br /&gt;-------------------------------------------------------------------------------------------&lt;br /&gt;**/&lt;br /&gt;&lt;br /&gt;CREATE FUNCTION [dbo].[Split](@String nvarchar(4000), @Delimiter char(1))&lt;br /&gt;RETURNS @Results TABLE (RowNo INT ,Items varchar(4000))&lt;br /&gt;AS&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    BEGIN&lt;br /&gt;    DECLARE @INDEX INT&lt;br /&gt;    DECLARE @RowNo INT&lt;br /&gt;    DECLARE @SLICE nvarchar(4000)&lt;br /&gt;    -- HAVE TO SET TO 1 SO IT DOESNT EQUAL Z&lt;br /&gt;    --     ERO FIRST TIME IN LOOP&lt;br /&gt;    SELECT @INDEX = 1&lt;br /&gt;    SELECT @RowNo=0&lt;br /&gt;    -- following line added 02/12/04 as null&lt;br /&gt;    --      values cause issues&lt;br /&gt;    IF @String IS NULL RETURN&lt;br /&gt;    WHILE @INDEX !=0&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        BEGIN &lt;br /&gt;         -- GET THE INDEX OF THE FIRST OCCURENCE OF THE SPLIT CHARACTER&lt;br /&gt;         SELECT @INDEX = CHARINDEX(@Delimiter,@STRING)&lt;br /&gt;         -- NOW PUSH EVERYTHING TO THE LEFT OF IT INTO THE SLICE VARIABLE&lt;br /&gt;         IF @INDEX !=0&lt;br /&gt;          SELECT @SLICE = LEFT(@STRING,@INDEX - 1)&lt;br /&gt;         ELSE&lt;br /&gt;          SELECT @SLICE = @STRING&lt;br /&gt;&lt;br /&gt;   SELECT @RowNo=@ROWNO+1&lt;br /&gt;         -- PUT THE ITEM INTO THE RESULTS SET&lt;br /&gt;         INSERT INTO @Results(RowNo,Items) VALUES(@RowNo,@SLICE)&lt;br /&gt;         -- CHOP THE ITEM REMOVED OFF THE MAIN STRING&lt;br /&gt;         SELECT @STRING = RIGHT(@STRING,LEN(@STRING) - @INDEX)&lt;br /&gt;         -- BREAK OUT IF WE ARE DONE&lt;br /&gt;         IF LEN(@STRING) = 0 BREAK&lt;br /&gt;    END&lt;br /&gt;    RETURN&lt;br /&gt;END&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7527040749709927669-916206976012403120?l=jaan1762.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jaan1762.blogspot.com/feeds/916206976012403120/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7527040749709927669&amp;postID=916206976012403120' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/916206976012403120'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/916206976012403120'/><link rel='alternate' type='text/html' href='http://jaan1762.blogspot.com/2009/07/split-function-in-sqlserver.html' title='Split Function in SqlServer'/><author><name>Mansoor</name><uri>http://www.blogger.com/profile/00473621254256960630</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-7527040749709927669.post-4252868631672324585</id><published>2009-06-29T23:19:00.000-07:00</published><updated>2009-06-29T23:31:13.377-07:00</updated><title type='text'>Gridiview Child Controls Event Firing Sample</title><content type='html'>&amp;lt;div&amp;gt;&lt;br /&gt;        &amp;lt;asp:GridView ID="GridView1" runat="server" AllowPaging="True" &lt;br /&gt;            AllowSorting="True" AutoGenerateColumns="False" BackColor="White" &lt;br /&gt;            BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" CellPadding="3" &lt;br /&gt;            DataKeyNames="CompanyID" DataSourceID="SqlDataSource1" onrowdatabound="GridView1_RowDataBound1" &lt;br /&gt;           &amp;gt;&lt;br /&gt;            &amp;lt;RowStyle ForeColor="#000066" /&amp;gt;&lt;br /&gt;            &amp;lt;Columns&amp;gt;&lt;br /&gt;              &amp;lt;asp:TemplateField ShowHeader="False"&amp;gt;&lt;br /&gt;                    &amp;lt;ItemTemplate&amp;gt;&lt;br /&gt;                        &amp;lt;asp:CheckBox ID="chkchoose" runat="server" AutoPostBack="true" OnCheckedChanged="chkchoose_CheckedChanged" /&amp;gt;&lt;br /&gt;                    &amp;lt;/ItemTemplate&amp;gt;&lt;br /&gt;                &amp;lt;/asp:TemplateField&amp;gt;&lt;br /&gt;            &lt;br /&gt;            &lt;br /&gt;                &amp;lt;asp:TemplateField ShowHeader="False"&amp;gt;&lt;br /&gt;                    &amp;lt;ItemTemplate&amp;gt;&lt;br /&gt;                        &amp;lt;asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" &lt;br /&gt;                            CommandName="Select" Text="Select"&amp;gt;&amp;lt;/asp:LinkButton&amp;gt;&lt;br /&gt;                    &amp;lt;/ItemTemplate&amp;gt;&lt;br /&gt;                &amp;lt;/asp:TemplateField&amp;gt;&lt;br /&gt;                &amp;lt;asp:TemplateField HeaderText="CompanyID" InsertVisible="False" &lt;br /&gt;                    SortExpression="CompanyID"&amp;gt;&lt;br /&gt;                    &amp;lt;EditItemTemplate&amp;gt;&lt;br /&gt;                        &amp;lt;asp:Label ID="Label1" runat="server" Text='&amp;lt;%# Eval("CompanyID") %&amp;gt;'&amp;gt;&amp;lt;/asp:Label&amp;gt;&lt;br /&gt;                    &amp;lt;/EditItemTemplate&amp;gt;&lt;br /&gt;                    &amp;lt;ItemTemplate&amp;gt;&lt;br /&gt;                        &amp;lt;asp:Label ID="Label1" runat="server" Text='&amp;lt;%# Bind("CompanyID") %&amp;gt;'&amp;gt;&amp;lt;/asp:Label&amp;gt;&lt;br /&gt;                    &amp;lt;/ItemTemplate&amp;gt;&lt;br /&gt;                &amp;lt;/asp:TemplateField&amp;gt;&lt;br /&gt;                &amp;lt;asp:TemplateField HeaderText="TargetID" SortExpression="TargetID"&amp;gt;&lt;br /&gt;                    &amp;lt;EditItemTemplate&amp;gt;&lt;br /&gt;                        &amp;lt;asp:TextBox ID="TextBox1" runat="server" Text='&amp;lt;%# Bind("TargetID") %&amp;gt;'&amp;gt;&amp;lt;/asp:TextBox&amp;gt;&lt;br /&gt;                    &amp;lt;/EditItemTemplate&amp;gt;&lt;br /&gt;                    &amp;lt;ItemTemplate&amp;gt;&lt;br /&gt;                        &amp;lt;asp:Label ID="Label2" runat="server" Text='&amp;lt;%# Bind("TargetID") %&amp;gt;'&amp;gt;&amp;lt;/asp:Label&amp;gt;&lt;br /&gt;                    &amp;lt;/ItemTemplate&amp;gt;&lt;br /&gt;                &amp;lt;/asp:TemplateField&amp;gt;&lt;br /&gt;                &amp;lt;asp:TemplateField HeaderText="CompanyName" SortExpression="CompanyName"&amp;gt;&lt;br /&gt;                    &amp;lt;EditItemTemplate&amp;gt;&lt;br /&gt;                        &amp;lt;asp:TextBox ID="TextBox2" runat="server" Text='&amp;lt;%# Bind("CompanyName") %&amp;gt;'&amp;gt;&amp;lt;/asp:TextBox&amp;gt;&lt;br /&gt;                    &amp;lt;/EditItemTemplate&amp;gt;&lt;br /&gt;                    &amp;lt;ItemTemplate&amp;gt;&lt;br /&gt;                        &amp;lt;asp:Label ID="Label3" runat="server" Text='&amp;lt;%# Bind("CompanyName") %&amp;gt;'&amp;gt;&amp;lt;/asp:Label&amp;gt;&lt;br /&gt;                    &amp;lt;/ItemTemplate&amp;gt;&lt;br /&gt;                &amp;lt;/asp:TemplateField&amp;gt;&lt;br /&gt;                &amp;lt;asp:TemplateField HeaderText="Email" SortExpression="Email"&amp;gt;&lt;br /&gt;                    &amp;lt;EditItemTemplate&amp;gt;&lt;br /&gt;                        &amp;lt;asp:TextBox ID="TextBox3" runat="server" Text='&amp;lt;%# Bind("Email") %&amp;gt;'&amp;gt;&amp;lt;/asp:TextBox&amp;gt;&lt;br /&gt;                    &amp;lt;/EditItemTemplate&amp;gt;&lt;br /&gt;                    &amp;lt;ItemTemplate&amp;gt;&lt;br /&gt;                        &amp;lt;asp:Label ID="Label4" runat="server" Text='&amp;lt;%# Bind("Email") %&amp;gt;'&amp;gt;&amp;lt;/asp:Label&amp;gt;&lt;br /&gt;                    &amp;lt;/ItemTemplate&amp;gt;&lt;br /&gt;                &amp;lt;/asp:TemplateField&amp;gt;&lt;br /&gt;                &amp;lt;asp:TemplateField HeaderText="URL" SortExpression="URL"&amp;gt;&lt;br /&gt;                    &amp;lt;EditItemTemplate&amp;gt;&lt;br /&gt;                        &amp;lt;asp:TextBox ID="TextBox4" runat="server" Text='&amp;lt;%# Bind("URL") %&amp;gt;'&amp;gt;&amp;lt;/asp:TextBox&amp;gt;&lt;br /&gt;                    &amp;lt;/EditItemTemplate&amp;gt;&lt;br /&gt;                    &amp;lt;ItemTemplate&amp;gt;&lt;br /&gt;                        &amp;lt;asp:Label ID="Label5" runat="server" Text='&amp;lt;%# Bind("URL") %&amp;gt;'&amp;gt;&amp;lt;/asp:Label&amp;gt;&lt;br /&gt;                    &amp;lt;/ItemTemplate&amp;gt;&lt;br /&gt;                &amp;lt;/asp:TemplateField&amp;gt;&lt;br /&gt;                &amp;lt;asp:TemplateField HeaderText="Country" SortExpression="Country"&amp;gt;&lt;br /&gt;                    &amp;lt;EditItemTemplate&amp;gt;&lt;br /&gt;                          &amp;lt;asp:Label ID="Label6" runat="server" Text='&amp;lt;%# Bind("Country") %&amp;gt;'&amp;gt;&amp;lt;/asp:Label&amp;gt;&lt;br /&gt;                    &amp;lt;/EditItemTemplate&amp;gt;&lt;br /&gt;                    &amp;lt;ItemTemplate&amp;gt;&lt;br /&gt;                    &amp;lt;asp:DropDownList ID="ddlCountry" runat="server"   AutoPostBack="True" &lt;br /&gt;                    OnSelectedIndexChanged="ddlCountry_SelectedIndexChanged" &amp;gt;&amp;lt;/asp:DropDownList&amp;gt;&lt;br /&gt;                      &lt;br /&gt;                    &amp;lt;/ItemTemplate&amp;gt;&lt;br /&gt;                &amp;lt;/asp:TemplateField&amp;gt;&lt;br /&gt;            &amp;lt;/Columns&amp;gt;&lt;br /&gt;            &amp;lt;FooterStyle BackColor="White" ForeColor="#000066" /&amp;gt;&lt;br /&gt;            &amp;lt;PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" /&amp;gt;&lt;br /&gt;            &amp;lt;SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" /&amp;gt;&lt;br /&gt;            &amp;lt;HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" /&amp;gt;&lt;br /&gt;        &amp;lt;/asp:GridView&amp;gt;&lt;br /&gt;    &amp;lt;/div&amp;gt;&lt;br /&gt;    &amp;lt;asp:SqlDataSource ID="SqlDataSource1" runat="server" &lt;br /&gt;        ConnectionString="&amp;lt;%$ ConnectionStrings:MCCMSConnectionString4 %&amp;gt;" &lt;br /&gt;        SelectCommand="SELECT [CompanyID], [TargetID], [CompanyName], [Email], [URL], [Country] FROM [CMStbCompanies]"&amp;gt;&amp;lt;/asp:SqlDataSource&amp;gt;&lt;br /&gt;    &amp;lt;asp:SqlDataSource ID="SqlDataSource2" runat="server" &lt;br /&gt;        ConnectionString="&amp;lt;%$ ConnectionStrings:MCCMSConnectionString %&amp;gt;" &lt;br /&gt;        SelectCommand="SELECT [Acronym], [AcronymID] FROM [CMStbAcronyms] WHERE ([AcrCat] = @AcrCat)"&amp;gt;&lt;br /&gt;        &amp;lt;SelectParameters&amp;gt;&lt;br /&gt;            &amp;lt;asp:Parameter DefaultValue="Countries" Name="AcrCat" Type="String" /&amp;gt;&lt;br /&gt;        &amp;lt;/SelectParameters&amp;gt;&lt;br /&gt;    &amp;lt;/asp:SqlDataSource&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://2.bp.blogspot.com/_URzpGoyPbng/SkmxCNseCSI/AAAAAAAAC9A/WkYdjLbQh2s/s1600-h/GridViewChildEventRaising.JPG"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 320px; height: 155px;" src="http://2.bp.blogspot.com/_URzpGoyPbng/SkmxCNseCSI/AAAAAAAAC9A/WkYdjLbQh2s/s320/GridViewChildEventRaising.JPG" border="0" alt=""id="BLOGGER_PHOTO_ID_5353004283700578594" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;In Code Behind Page inorder to fire the events&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;    protected void chkchoose_CheckedChanged(object sender, EventArgs e)&lt;br /&gt;    {&lt;br /&gt;        CheckBox chk = (CheckBox)sender;&lt;br /&gt;        TableCell cell = chk.Parent as TableCell;&lt;br /&gt;        GridViewRow item = cell.Parent as GridViewRow;&lt;br /&gt;&lt;br /&gt;        int index = item.RowIndex;&lt;br /&gt;        string content = item.Cells[0].Text;&lt;br /&gt;&lt;br /&gt;        if (chk.Checked)&lt;br /&gt;        {&lt;br /&gt;            Response.Write(String.Format("Checked Row {0} contains {1}", index, content));&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;  &lt;br /&gt;    protected void ddlCountry_SelectedIndexChanged(object sender, EventArgs e)&lt;br /&gt;    {&lt;br /&gt;        DropDownList list = (DropDownList)sender;&lt;br /&gt;&lt;br /&gt;        TableCell cell = list.Parent as TableCell;&lt;br /&gt;        GridViewRow item = cell.Parent as GridViewRow;&lt;br /&gt;&lt;br /&gt;        int index = item.RowIndex;&lt;br /&gt;        string content = item.Cells[0].Text;&lt;br /&gt;&lt;br /&gt;        Response.Write(String.Format("Row {0} contains {1}", index, content));&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Also You bind the DropDown in Code Behind instead at the Item Template Level&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; protected void GridView1_RowDataBound1(object sender, GridViewRowEventArgs e)&lt;br /&gt;    {&lt;br /&gt;        if (e.Row.RowType == DataControlRowType.DataRow)&lt;br /&gt;        {&lt;br /&gt;            DropDownList ddl = (DropDownList)e.Row.FindControl("ddlCountry");&lt;br /&gt;&lt;br /&gt;            if (ddl != null)&lt;br /&gt;            {&lt;br /&gt;                ddl.DataTextField = "Acronym";&lt;br /&gt;                ddl.DataValueField = "AcronymID";&lt;br /&gt;                ddl.DataSource = SqlDataSource2;&lt;br /&gt;                ddl.DataBind();&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;    }&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7527040749709927669-4252868631672324585?l=jaan1762.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jaan1762.blogspot.com/feeds/4252868631672324585/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7527040749709927669&amp;postID=4252868631672324585' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/4252868631672324585'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/4252868631672324585'/><link rel='alternate' type='text/html' href='http://jaan1762.blogspot.com/2009/06/gridiview-child-controls-event-firing.html' title='Gridiview Child Controls Event Firing Sample'/><author><name>Mansoor</name><uri>http://www.blogger.com/profile/00473621254256960630</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/_URzpGoyPbng/SkmxCNseCSI/AAAAAAAAC9A/WkYdjLbQh2s/s72-c/GridViewChildEventRaising.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7527040749709927669.post-2703479678436531202</id><published>2009-06-29T23:12:00.000-07:00</published><updated>2009-06-29T23:19:17.433-07:00</updated><title type='text'>DropDownList Controls Events In an ASP.Net DataGrid</title><content type='html'>In this article we will demonstrate how to add a data bound, event raising control into a column of an ASP.Net DataGrid. We will also see how to place a control into the header row of a DataGrid. We will demonstrate this using the DropDownList control.&lt;br /&gt;&lt;br /&gt;The following screen shot shows a web form in design mode. We are going to query the authors table in SQL Server’s pubs table. You can see we have one column (au_fname) to display the au_fname column from the table. In the second column we have added DropDownList controls to both the header line, and in each row with a data record. &lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;Let’s first take a look at the ASPX markup to create the grid. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;asp:DataGrid &lt;br /&gt;    id="DataGrid1" runat="server" &lt;br /&gt;    AutoGenerateColumns="False" &lt;br /&gt;    OnItemDataBound="DataGrid1_ItemDataBound"&amp;gt;&lt;br /&gt;    &amp;lt;Columns&gt;&lt;br /&gt;        &amp;lt;asp:BoundColumn DataField="au_fname" HeaderText="au_fname" /&amp;gt;&lt;br /&gt;        &amp;lt;asp:TemplateColumn&amp;gt;&lt;br /&gt;            &amp;lt;HeaderTemplate&amp;gt;&lt;br /&gt;                &amp;lt;asp:DropDownList &lt;br /&gt;                    ID="HeaderDropDown" Runat="server" &lt;br /&gt;                    AutoPostBack="True" &lt;br /&gt;                    OnSelectedIndexChanged="DropDown_SelectedIndexChanged" /&amp;gt;&lt;br /&gt;            &amp;lt;/HeaderTemplate&amp;gt;&lt;br /&gt;            &amp;lt;ItemTemplate&amp;gt;&lt;br /&gt;                &amp;lt;asp:DropDownList &lt;br /&gt;                    ID="ItemDropDown" Runat="server"&lt;br /&gt;                    AutoPostBack="True" &lt;br /&gt;                    OnSelectedIndexChanged="DropDown_SelectedIndexChanged" /&amp;gt;&lt;br /&gt;            &amp;lt;/ItemTemplate&amp;gt;&lt;br /&gt;        &amp;lt;/asp:TemplateColumn&amp;gt;&lt;br /&gt;    &lt;/Columns&amp;gt;&lt;br /&gt;&amp;lt;/asp:DataGrid&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.odetocode.com/aimages/datagridddl/designer.gif"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 458px; height: 382px;" src="http://www.odetocode.com/aimages/datagridddl/designer.gif" border="0" alt="" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;We have a DropDownList in the header declared as HeaderDropDown, and a DropDownList in the Item template declared as ItemDropDown. Notice we set the AutoPostBack property to true. Setting AutoPostBack to true allows the form to post back to the server and raise an event each time the user changes a selection in the DropDownList control. We also assign an event handler for the SelectedIndexChanged event. Notice we are sharing the same event handler (DropDown_SelectedIndexChanged) for all DropDownList controls. We will see later in the code how we can still identity the exact control firing the event. &lt;br /&gt;&lt;br /&gt;Before we look at the SelectedIndexChanged event handlers, let’s think about populating the drop down controls with data for the user to select. When the DataGrid binds to a data source it will create a DropDownList control to place in the header row, and also a DropDownList for each row of data rendered. We need to catch when ASP.NET creates these controls so we can populate them with data for the user to select from. The best place to do this is during the ItemDataBound event. You can see in the ASPX above we are handling this event using the DataGrid1_ItemDataBound method, shown below. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;protected void DataGrid1_ItemDataBound(object sender, DataGridItemEventArgs e)&lt;br /&gt;{&lt;br /&gt;   if(e.Item.ItemType == ListItemType.AlternatingItem ||&lt;br /&gt;      e.Item.ItemType == ListItemType.Item)&lt;br /&gt;   {&lt;br /&gt;      string[] options = { "Option1", "Option2", "Option3" };&lt;br /&gt;&lt;br /&gt;      DropDownList list = (DropDownList)e.Item.FindControl("ItemDropDown");&lt;br /&gt;      list.DataSource = options;&lt;br /&gt;      list.DataBind();&lt;br /&gt;   }&lt;br /&gt;   else if(e.Item.ItemType == ListItemType.Header)&lt;br /&gt;   {&lt;br /&gt;      string[] options = { "OptionA", "OptionB", "OptionC" };&lt;br /&gt;&lt;br /&gt;      DropDownList list = (DropDownList)e.Item.FindControl("HeaderDropDown");&lt;br /&gt;      list.DataSource = options;&lt;br /&gt;      list.DataBind();&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;ItemDataBound occurs after a DataGridItem is bound to the grid. The event fires for each row, including the header and the footer rows. We know if the item belongs to the header, the footer, or one of the items by checking the Item.ItemType property of the event. Rows of data will always have a ListItemType of Item or AlternatingItem. &lt;br /&gt;&lt;br /&gt;We use the FindControl method to obtain a reference to the DropDownList control for each row. To learn more about using FindControl in these scenarios, see ‘In Search Of ASP.NET Controls’. We specify the control to find by name. For the header remember we specified a name of “HeaderDropDown”, while rows with data will have a name of “ItemDropDown”. &lt;br /&gt;&lt;br /&gt;We have an array of strings to represent data for the DropDownList control to bind against. Note that this event will fire for each row of the grid, so you’ll want to make sure this method performs well. You would not want to perform a database query each time the event fires. In this example, the DropDownList control in the header binds against a different set of strings than the DropDownList controls in the item rows. &lt;br /&gt;&lt;br /&gt;Whenever the user modifies any of the DropDownList selections in our grid, the DropDown_SelectedIndexChanged event will fire. Remember, we assigned the same event handler for all of our lists, and we set the AutoPostBack property to true so a new selection should post back to the server and raise the event immediately. The event handler is shown below. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;protected void DropDown_SelectedIndexChanged(object sender, EventArgs e)&lt;br /&gt;{&lt;br /&gt;   DropDownList list = (DropDownList)sender;&lt;br /&gt;&lt;br /&gt;   TableCell cell = list.Parent as TableCell;&lt;br /&gt;   DataGridItem item = cell.Parent as DataGridItem;&lt;br /&gt;&lt;br /&gt;   int index = item.ItemIndex;&lt;br /&gt;   string content = item.Cells[0].Text;&lt;br /&gt;&lt;br /&gt;   Response.Write(&lt;br /&gt;         String.Format("Row {0} contains {1}", index, content)&lt;br /&gt;      );&lt;br /&gt;   &lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;First, notice the sender parameter will be the DropDownList control modified by the user. By casting the object reference to a DropDownList we get a reference to the modified control and can see what the user has selected. &lt;br /&gt;&lt;br /&gt;Secondly, notice the DropDownList control’s parent will be a TableCell of the grid. The parent of the TableCell will be a DataGridItem. Once we have a reference to the DataGridItem, we can see which row was selected by using the ItemIndex property. (Note: ItemIndex will be -1 for the header row). With the DataGridItem we can also inspect the values of other cells in the row. &lt;br /&gt;&lt;br /&gt;The following image shows the form in action just after we made a new selection to the list in Cheryl's row. &lt;br /&gt;&lt;br /&gt; &lt;a href="http://www.odetocode.com/aimages/datagridddl/form1.gif"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 391px; height: 387px;" src="http://www.odetocode.com/aimages/datagridddl/form1.gif" border="0" alt="" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Once you know the control invoking the event you can find almost any other piece of information you need about the grid or the underlying data source by getting to the DataGridItem object and inspecting the ItemIndex property or the collection of TableCells. With this information in hand, adding controls to the rows of your DataGrid should become a straightforward process. You can download the code for this article. Add this code to an empty web project as an existing item.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Original POST at &lt;a href="http://www.odetocode.com/Articles/231.aspx"&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7527040749709927669-2703479678436531202?l=jaan1762.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jaan1762.blogspot.com/feeds/2703479678436531202/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7527040749709927669&amp;postID=2703479678436531202' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/2703479678436531202'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/2703479678436531202'/><link rel='alternate' type='text/html' href='http://jaan1762.blogspot.com/2009/06/dropdownlist-controls-events-in-aspnet.html' title='DropDownList Controls Events In an ASP.Net DataGrid'/><author><name>Mansoor</name><uri>http://www.blogger.com/profile/00473621254256960630</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-7527040749709927669.post-4990615684686176531</id><published>2009-06-29T02:30:00.000-07:00</published><updated>2009-06-29T02:36:17.915-07:00</updated><title type='text'>How to Maintain Checkbox state in a Gridview for an Header</title><content type='html'>&amp;lt;script type="text/javascript"&amp;gt;&lt;br /&gt;        function ChangeCheckBoxState(id, checkState) {&lt;br /&gt;            var cb = document.getElementById(id);&lt;br /&gt;            if (cb != null)&lt;br /&gt;                cb.checked = checkState;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        function ChangeAllCheckBoxStates(checkState) {&lt;br /&gt;            if (EmplloyeeCheckBoxIDs != null) {&lt;br /&gt;                for (var i = 0; i &lt; EmplloyeeCheckBoxIDs.length; i++)&lt;br /&gt;                    ChangeCheckBoxState(EmplloyeeCheckBoxIDs[i], checkState);&lt;br /&gt;                ChangeCheckBoxState(EmplloyeeCheckBoxIDs[0], checkState);&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        function ChangeHeaderAsNeeded() {&lt;br /&gt;            if (EmplloyeeCheckBoxIDs != null) {&lt;br /&gt;                var txt = document.getElementById("&lt;%= gvcountvalEmplyeeMaster.ClientID %&gt;");&lt;br /&gt;                for (var i = 1; i &lt; txt.value; i++) {&lt;br /&gt;                    var cb = document.getElementById(EmplloyeeCheckBoxIDs[i]);&lt;br /&gt;                    if (!cb.checked) {&lt;br /&gt;                        ChangeCheckBoxState(EmplloyeeCheckBoxIDs[0], false);&lt;br /&gt;                        return;&lt;br /&gt;                    }&lt;br /&gt;                }&lt;br /&gt;                ChangeCheckBoxState(EmplloyeeCheckBoxIDs[0], true);&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;    &amp;lt;/script&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;  &lt;asp:Literal ID="EmployeeCheckBoxIDArrayScript" runat="server"&gt;&lt;/asp:Literal&gt;&lt;br /&gt;&lt;br /&gt; &lt;asp:HiddenField ID="gvcountvalEmplyeeMaster" runat="server"&gt;&lt;/asp:HiddenField&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;IN ROWDATABOUND&lt;br /&gt;---------------&lt;br /&gt;&lt;br /&gt;if (e.Row.RowType == DataControlRowType.Header)&lt;br /&gt;       {&lt;br /&gt;           CheckBox cbHeader = (CheckBox)e.Row.FindControl("chkEmployeeHeader");&lt;br /&gt;           cbHeader.Attributes.Add("onclick", "ChangeAllCheckBoxStates(this.checked);");&lt;br /&gt;           EmplloyeeCheckBoxIDsArray.Add(string.Concat("'", cbHeader.ClientID, "'"));&lt;br /&gt;       }&lt;br /&gt;       else if (e.Row.RowType == DataControlRowType.DataRow)&lt;br /&gt;       {&lt;br /&gt;           CheckBox cb = (CheckBox)e.Row.FindControl("chkEmployee");&lt;br /&gt;           cb.Attributes.Add("onclick", "ChangeHeaderAsNeeded();");&lt;br /&gt;           EmplloyeeCheckBoxIDsArray.Add(string.Concat("'", cb.ClientID, "'"));&lt;br /&gt;       }&lt;br /&gt;       else if (e.Row.RowType == DataControlRowType.Footer)&lt;br /&gt;       {&lt;br /&gt;           gvcountvalEmplyeeMaster.Value = EmplloyeeCheckBoxIDsArray.Count.ToString();&lt;br /&gt;           EmployeeCheckBoxIDArrayScript.Text = string.Format("&lt;script type=\"text/javascript\"&gt;{0}&lt;!--{0}var EmplloyeeCheckBoxIDs = new Array({1});{0}// --&gt;{0}&lt;/script&gt;", System.Environment.NewLine, string.Join(",", EmplloyeeCheckBoxIDsArray.ToArray()));&lt;br /&gt;       }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;Declarattion at Page Level inorder to Maintain the Count at Footer&lt;br /&gt;&lt;br /&gt;List&lt;string&gt; EmplloyeeCheckBoxIDsArray = new List&lt;string&gt;();&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7527040749709927669-4990615684686176531?l=jaan1762.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jaan1762.blogspot.com/feeds/4990615684686176531/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7527040749709927669&amp;postID=4990615684686176531' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/4990615684686176531'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/4990615684686176531'/><link rel='alternate' type='text/html' href='http://jaan1762.blogspot.com/2009/06/function-changecheckboxstateid.html' title='How to Maintain Checkbox state in a Gridview for an Header'/><author><name>Mansoor</name><uri>http://www.blogger.com/profile/00473621254256960630</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-7527040749709927669.post-2210978729682153547</id><published>2009-06-22T23:34:00.001-07:00</published><updated>2009-06-22T23:34:43.822-07:00</updated><title type='text'>How to find Nth Highest Salary of Employee</title><content type='html'>This question is quite a popular question and it is interesting that I have been receiving this question every other day. I have already answer this question here. “How to find Nth Highest Salary of Employee”.&lt;br /&gt;&lt;br /&gt;Please read my article here to find Nth Highest Salary of Employee table : SQL SERVER – Query to Retrieve the Nth Maximum value&lt;br /&gt;&lt;br /&gt;I have re-wrote the same article here with example of SQL Server 2005 Database AdventureWorks : SQL SERVER – 2005 – Find Nth Highest Record from Database Table&lt;br /&gt;&lt;br /&gt;Just a day ago, I have received another script to get the same result from one of the blog reader Pravin Phatangare, let us see his simple method here.&lt;br /&gt;&lt;br /&gt;For particular example of employee :&lt;br /&gt;&lt;br /&gt;How to get 1st, 2nd, 3rd, 4th, nth topmost salary from an Employee table&lt;br /&gt;&lt;br /&gt;The following solution is for getting 6th highest salary from Employee table ,&lt;br /&gt;SELECT TOP 1 salary&lt;br /&gt;FROM (&lt;br /&gt;SELECT DISTINCT TOP 6 salary&lt;br /&gt;FROM employee&lt;br /&gt;ORDER BY salary DESC) a&lt;br /&gt;ORDER BY salary&lt;br /&gt;You can change and use it for getting nth highest salary from Employee table as follows&lt;br /&gt;SELECT TOP 1 salary&lt;br /&gt;FROM (&lt;br /&gt;SELECT DISTINCT TOP n salary&lt;br /&gt;FROM employee&lt;br /&gt;ORDER BY salary DESC) a&lt;br /&gt;ORDER BY salary&lt;br /&gt;where n &gt; 1 (n is always greater than one)&lt;br /&gt;&lt;br /&gt;Same example converted in SQL Server 2005 to work with Database AdventureWorks.&lt;br /&gt;USE AdventureWorks;&lt;br /&gt;GO&lt;br /&gt;SELECT TOP 1 Rate&lt;br /&gt;FROM (&lt;br /&gt;SELECT DISTINCT TOP 4 Rate&lt;br /&gt;FROM HumanResources.EmployeePayHistory&lt;br /&gt;ORDER BY Rate DESC) A&lt;br /&gt;ORDER BY Rate&lt;br /&gt;GO&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7527040749709927669-2210978729682153547?l=jaan1762.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jaan1762.blogspot.com/feeds/2210978729682153547/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7527040749709927669&amp;postID=2210978729682153547' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/2210978729682153547'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/2210978729682153547'/><link rel='alternate' type='text/html' href='http://jaan1762.blogspot.com/2009/06/how-to-find-nth-highest-salary-of.html' title='How to find Nth Highest Salary of Employee'/><author><name>Mansoor</name><uri>http://www.blogger.com/profile/00473621254256960630</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-7527040749709927669.post-4832974609433625354</id><published>2009-06-22T22:08:00.000-07:00</published><updated>2009-06-22T22:09:22.145-07:00</updated><title type='text'>How do you find the Second highest Salary?</title><content type='html'>This is the most common question asked in Interviews.&lt;br /&gt;&lt;br /&gt;EMPLOYEE table has fields EMP_ID and SALARY how do you find the second highest salary?&lt;br /&gt;&lt;br /&gt;Answer:&lt;br /&gt;&lt;br /&gt;We can write a sub-query to achieve the result&lt;br /&gt;&lt;br /&gt;SELECT MAX(SALARY) FROM EMPLOYEE WHERE SALARY NOT IN (SELECT MAX(SALARY) FROM EMPLOYEE)&lt;br /&gt;&lt;br /&gt;The first sub-query in the WHERE clause will return the MAX SALARY in the table, the main query SELECT’s the MAX SALARY from the results which doesn’t have the highest SALARY.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;--------------------------------------------------------------------------------&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7527040749709927669-4832974609433625354?l=jaan1762.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jaan1762.blogspot.com/feeds/4832974609433625354/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7527040749709927669&amp;postID=4832974609433625354' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/4832974609433625354'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/4832974609433625354'/><link rel='alternate' type='text/html' href='http://jaan1762.blogspot.com/2009/06/how-do-you-find-second-highest-salary.html' title='How do you find the Second highest Salary?'/><author><name>Mansoor</name><uri>http://www.blogger.com/profile/00473621254256960630</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-7527040749709927669.post-2917537233785257307</id><published>2009-06-22T03:53:00.000-07:00</published><updated>2009-06-22T03:54:36.665-07:00</updated><title type='text'>SQL SYNTAX</title><content type='html'>SQL Syntax Introduction&lt;br /&gt;&lt;br /&gt;CREATE TABLE syntax&lt;br /&gt;&lt;br /&gt;ALTER TABLE syntax&lt;br /&gt;&lt;br /&gt;DROP TABLE syntax&lt;br /&gt;&lt;br /&gt;CREATE VIEW syntax&lt;br /&gt;&lt;br /&gt;DROP VIEW syntax&lt;br /&gt;&lt;br /&gt;CREATE SEQUENCE syntax&lt;br /&gt;&lt;br /&gt;DROP SEQUENCE syntax&lt;br /&gt;&lt;br /&gt;COMPACT TABLE syntax&lt;br /&gt;&lt;br /&gt;CREATE SCHEMA syntax&lt;br /&gt;&lt;br /&gt;DROP SCHEMA syntax&lt;br /&gt;&lt;br /&gt;INSERT syntax&lt;br /&gt;&lt;br /&gt;DELETE syntax&lt;br /&gt;&lt;br /&gt;UPDATE syntax&lt;br /&gt;&lt;br /&gt;SELECT syntax&lt;br /&gt;&lt;br /&gt;COMMIT and ROLLBACK syntax&lt;br /&gt;&lt;br /&gt;CREATE USER, ALTER USER and DROP USER syntax&lt;br /&gt;&lt;br /&gt;GRANT/REVOKE syntax&lt;br /&gt;&lt;br /&gt;SET syntax&lt;br /&gt;&lt;br /&gt;DESCRIBE syntax&lt;br /&gt;&lt;br /&gt;SHOW syntax&lt;br /&gt;&lt;br /&gt;SHUTDOWN syntax&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;--------------------------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;1. SQL Syntax Introduction &lt;br /&gt;This section is a reference for the SQL grammar that Mckoi SQL Database supports. Mckoi SQL Database supports a subset of entry level ANSI SQL-92. This section is not intended to be a tutorial for learning SQL. For SQL books and online tutorials see the links section on the home page. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;2. CREATE TABLE syntax &lt;br /&gt;&lt;br /&gt;CREATE TABLE [ IF NOT EXISTS ] table_name&lt;br /&gt;  ( column_declare1, column_declare2, constraint_declare1, ... )&lt;br /&gt;  &lt;br /&gt;&lt;br /&gt;column_declare ::= column_name type [ DEFAULT expression ]&lt;br /&gt;  [ NULL | NOT NULL ] [ INDEX_BLIST | INDEX_NONE ] &lt;br /&gt;&lt;br /&gt;type ::= BIT | REAL | CHAR | TEXT | DATE | TIME |&lt;br /&gt;  FLOAT | BIGINT | DOUBLE | STRING | BINARY | NUMERIC |&lt;br /&gt;  DECIMAL | BOOLEAN | TINYINT | INTEGER | VARCHAR |&lt;br /&gt;  SMALLINT | VARBINARY | TIMESTAMP | LONGVARCHAR |&lt;br /&gt;  JAVA_OBJECT | LONGVARBINARY &lt;br /&gt;&lt;br /&gt;constraint_declare :: = [ CONSTRAINT constraint_name ]&lt;br /&gt;  PRIMARY KEY ( col1, col2, ... ) |&lt;br /&gt;  FOREIGN KEY ( col1, col2, ... ) REFERENCES f_table [ ( col1, col2, ... ) ]&lt;br /&gt;             [ ON UPDATE triggered_action ] [ ON DELETE triggered_action ] |&lt;br /&gt;  UNIQUE ( col1, col2, ... ) |&lt;br /&gt;  CHECK ( expression )&lt;br /&gt;  [ INITIALLY DEFERRED | INITIALLY IMMEDIATE ]&lt;br /&gt;  [ NOT DEFERRABLE | DEFERRABLE ]&lt;br /&gt;&lt;br /&gt;triggered_action :: =&lt;br /&gt;  NO ACTION | SET NULL | SET DEFAULT | CASCADE&lt;br /&gt;  &lt;br /&gt;When declaring string or binary column types the maximum size must be specified. The following example declares a string column that can grow to a maximum of 100 characters, &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;CREATE TABLE Table ( str_col VARCHAR(100) )&lt;br /&gt;When handling strings the database will only allocate as much storage space as the string uses up. If a 10 character string is stored in str_col then only space for 10 characters will be allocated in the database. So if you need a column that can store a string of any size, use an arbitrarily large number when declaring the column. Mckoi SQL Database does not use a fixed size storage mechanism when storing variable length column data. &lt;br /&gt;&lt;br /&gt;JAVA_OBJECT is a column type that can contain serializable Java objects. The JAVA_OBJECT type has an optional Java class definition that is used for runtime class constraint checking. The following example demonstrates creating a JAVA_OBJECT column. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;CREATE TABLE ObjectTable (&lt;br /&gt;        obj_id NUMERIC, obj JAVA_OBJECT(java.awt.Point))&lt;br /&gt;If the Java class is not specified the column defaults to java.lang.Object which effectively means any type of serializable Java object can be kept in the column. &lt;br /&gt;&lt;br /&gt;String types may have a COLLATE clause that changes the collation ordering of the string based on a language. For example, the folling statement creates a string that can store and order Japanese text; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;CREATE TABLE InternationalTable (&lt;br /&gt;        japanese_text VARCHAR(4000) COLLATE 'jaJP')&lt;br /&gt;The 'jaJP' is an ISO localization code for the Japanese language in Japan. Other locale codes can be found in the documentation to java.text.Collate. &lt;br /&gt;&lt;br /&gt;Unique, primary/foreign key and check integrity constraints can be defined in the CREATE TABLE statement. The following is an example of defining a table with integrity constraints. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;CREATE TABLE Customer (&lt;br /&gt;  number VARCHAR(40)  NOT NULL,&lt;br /&gt;  name   VARCHAR(100) NOT NULL,&lt;br /&gt;  ssn    VARCHAR(50)  NOT NULL,&lt;br /&gt;  age    INTEGER      NOT NULL,&lt;br /&gt;    &lt;br /&gt;  CONSTRAINT cust_pk PRIMARY KEY (number),&lt;br /&gt;  UNIQUE ( ssn ),              // (An anonymous constraint)&lt;br /&gt;  CONSTRAINT age_check CHECK (age &gt;= 0 AND age &lt; 200)&lt;br /&gt;)&lt;br /&gt;  &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;3. ALTER TABLE syntax &lt;br /&gt;&lt;br /&gt;ALTER TABLE table_name ADD [COLUMN] column_declare&lt;br /&gt;ALTER TABLE table_name ADD constraint_declare&lt;br /&gt;ALTER TABLE table_name DROP [COLUMN] column_name &lt;br /&gt;ALTER TABLE table_name DROP CONSTRAINT constraint_name&lt;br /&gt;ALTER TABLE table_name DROP PRIMARY KEY&lt;br /&gt;ALTER TABLE table_name ALTER [COLUMN] column_name SET default_expr &lt;br /&gt;ALTER TABLE table_name ALTER [COLUMN] column_name DROP DEFAULT&lt;br /&gt;&lt;br /&gt;ALTER CREATE TABLE .... &lt;br /&gt;ALTER is used to add / remove / modify the columns and integrity constraints of a table. The ADD [COLUMN] form adds a new column definition to the table (using the same column declaration syntax in the CREATE command). The DROP [COLUMN] form drops the column with the name from the table. ALTER [COLUMN] column_name SET default_expr alters the default value for the column. ALTER [COLUMN] column_name DROP DEFAULT removes the default value set for the column. &lt;br /&gt;&lt;br /&gt;The following example adds a new column to a table; &lt;br /&gt;&lt;br /&gt;ALTER TABLE Order ADD notes VARCHAR(60000) DEFAULT 'n/a'&lt;br /&gt;&lt;br /&gt;ADD constraint_declare is used to define a new integrity constraint on a table (using the same constraint declaration syntax in the CREATE command). DROP CONSTRAINT is used to drop a named constraint from a table. &lt;br /&gt;&lt;br /&gt;The other form of this statement is ALTER CREATE TABLE .... This alters the table to the specification of the given CREATE statement. Any columns that are in the original table are not lost provided the column name is in the new table specification. Any columns that were not in the original table are set to the default value. &lt;br /&gt;&lt;br /&gt;The following example demonstrates this form of ALTER statement; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;ALTER CREATE TABLE table&lt;br /&gt;  ( col1 INTEGER NOT NULL UNIQUE,&lt;br /&gt;    col2 NUMERIC,&lt;br /&gt;    col3 VARCHAR(90000) )&lt;br /&gt;The ALTER CREATE TABLE ... syntax is an extension to the SQL-92 standard. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;4. DROP TABLE syntax &lt;br /&gt;&lt;br /&gt;DROP TABLE [ IF EXISTS ] table_name1, table_name2, .... &lt;br /&gt;Removes the table(s) from the database. The IF EXISTS clause will drop the table only if it exists. If this clause is not present an error is generated if the table does not exist. Any data that was in a dropped table is lost so use with care. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;5. CREATE VIEW syntax &lt;br /&gt;&lt;br /&gt;CREATE VIEW table_name [ ( column_name1, column_name2, ... ) ]&lt;br /&gt;  AS SELECT ...&lt;br /&gt;Creates a new view. A view is a virtual table based on the result of a SELECT query. The content of a view may reference any number of other tables and views. &lt;br /&gt;&lt;br /&gt;A simple example of a view follows; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;CREATE VIEW ViewOfTableA AS SELECT col1 FROM TableA&lt;br /&gt;A view acts like a regular table and can be queried as you would a table made with the CREATE TABLE statement. Views are read-only. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;6. DROP VIEW syntax &lt;br /&gt;&lt;br /&gt;DROP VIEW table_name&lt;br /&gt;Removes a view from the database. A view can be changed by dropping and recreating it.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;7. CREATE SEQUENCE syntax &lt;br /&gt;&lt;br /&gt;CREATE SEQUENCE name&lt;br /&gt;  [ INCREMENT increment_value ]&lt;br /&gt;  [ MINVALUE minimum_value ]&lt;br /&gt;  [ MAXVALUE maximum_value ]&lt;br /&gt;  [ START start_value ]&lt;br /&gt;  [ CACHE cache_value ]&lt;br /&gt;  [ CYCLE ]&lt;br /&gt;Creates a new sequence generator that can be used to generate an iterative sequence of values. Sequence generators have a number of uses including the creation of primary keys for a table. The INCREMENT, MINVALUE, MAXVALUE, START, and CACHE values are all optional. &lt;br /&gt;&lt;br /&gt;The INCREMENT value specifies how the sequence increments each iteration. By default a sequence generator increments by 1. The MINVALUE and MAXVALUE values specify the bounds of the sequence generator. By default MINVALUE and MAXVALUE are 0 and Long.MAX_VALUE respectively. The START value specifies the first key (exclusive) of the generator. The CACHE value specifies how many keys should be cached ahead of time. &lt;br /&gt;&lt;br /&gt;Below is an example that creates a new sequence generator called 'seq_key_1' that starts at 10 and increments by 2 each iteration; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;CREATE SEQUENCE seq_key_1 INCREMENT 2 START 10&lt;br /&gt;A sequence generator is accessed by a call to the NEXTVAL function. The NEXTVAL function iterates the generator and returns the next value from the sequence. The NEXTVAL function is an atomic operation and guarantees that no two identical values will be returned regardless of the frequency or concurrency of calls to the function. Below is a simple example; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;SELECT NEXTVAL('seq_key_1')&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;8. DROP SEQUENCE syntax &lt;br /&gt;&lt;br /&gt;DROP SEQUENCE name&lt;br /&gt;Drops a sequence generator previously created with the CREATE SEQUENCE statement. A sequence generator may be changed by dropping the sequence and then recreating it. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;9. COMPACT TABLE syntax &lt;br /&gt;&lt;br /&gt;COMPACT TABLE table_name&lt;br /&gt;Compacts the table data file in the file system. This removes all unused space from the table file and may rearrange the structure of the table to a form that better fits the characteristics of the data being stored. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;10. CREATE SCHEMA syntax &lt;br /&gt;&lt;br /&gt;CREATE SCHEMA schema_name&lt;br /&gt;Creates a schema with the given name. By default a database has three schema initially defined, SYS_INFO, SYS_JDBC and APP. The SYS_INFO and SYS_JDBC schema contain a number of important system tables and the APP schema is the default user schema. &lt;br /&gt;&lt;br /&gt;The following is an example of creating a new schema and changing to it; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;CREATE SCHEMA my_schema;&lt;br /&gt;SET SCHEMA my_schema;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;11. DROP SCHEMA syntax &lt;br /&gt;&lt;br /&gt;DROP SCHEMA schema_name&lt;br /&gt;Drops the schema with the given name. A schema may only be dropped if it contains no tables. The SYS_INFO and APP schema may not be dropped. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;12. INSERT syntax &lt;br /&gt;&lt;br /&gt;INSERT INTO table_name [ ( col_name1, col_name2, .... ) ]&lt;br /&gt;  VALUES ( expression1_1, expression1_2, .... ),&lt;br /&gt;         ( expression2_1, expression2_2, .... ), .... &lt;br /&gt;&lt;br /&gt;INSERT INTO table_name [ ( col_name1, col_name2, .... ) ]&lt;br /&gt;  SELECT ... &lt;br /&gt;&lt;br /&gt;INSERT INTO table_name&lt;br /&gt;  SET col_name1 = expression1, col_name2 = expression2, .... &lt;br /&gt;This is the SQL command to insert records into a table in the database. This statement comes in three forms. The first inserts data from a VALUES clause; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;INSERT INTO table ( col1, col2, col3 )&lt;br /&gt;  VALUES ( 10, 4 + 3, CONCAT('1', '1', 'c') ),&lt;br /&gt;         ( 11, (28 / 2) - 7, CONCAT(col1, 'c') )&lt;br /&gt;The second form is used to copy information from a SELECT query into the table specified in the INSERT statement. For example; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;INSERT INTO table ( col1, col2, col3 )&lt;br /&gt;  SELECT id, num, description&lt;br /&gt;    FROM table2&lt;br /&gt;   WHERE description LIKE '11%'&lt;br /&gt;The third form uses a list of column SET assignments. For example; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;INSERT INTO table&lt;br /&gt;  SET col1 = 10, col2 = 4 + 3, col3 = CONCAT(col1, 'c')&lt;br /&gt;If a column of the table is not specified in an INSERT the default value declared for the column is used. If no default value was declared a NULL value is inserted in the column. If the column is declared as NOT NULL the insert operation fails. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;13. DELETE syntax &lt;br /&gt;&lt;br /&gt;DELETE FROM table_name&lt;br /&gt;  [ WHERE expression ]&lt;br /&gt;  [ LIMIT limit_amount ]&lt;br /&gt;Deletes all the rows from the table that match the WHERE clause. An optional LIMIT clause specifies the maximum number of matched rows to be removed. An example of using the DELETE statement; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;DELETE FROM table&lt;br /&gt;  WHERE col3 LIKE '11%' AND col1 &lt; 1000 LIMIT 200&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;14. UPDATE syntax &lt;br /&gt;&lt;br /&gt;UPDATE table_name&lt;br /&gt;  SET col_name1 = expression1, col_name2 = expression2, ....&lt;br /&gt;  [ WHERE expression ]&lt;br /&gt;  [ LIMIT limit_amount ]&lt;br /&gt;Updates information in a table. The SET clause is a list of assignments that describe how the columns of the data matched by the WHERE clause are to be updated. Any columns not assigned in the SET clause are left unchanged. Examples of using UPDATE; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;UPDATE Employee&lt;br /&gt;  SET salary = salary * 1.25&lt;br /&gt;  WHERE name = 'Bob'&lt;br /&gt;&lt;br /&gt;UPDATE Order&lt;br /&gt;  SET id = id + 3, part = CONCAT(part, '-00')&lt;br /&gt;  WHERE part LIKE 'PO-%'&lt;br /&gt;  LIMIT 10&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;15. SELECT syntax &lt;br /&gt;&lt;br /&gt;SELECT [ DISTINCT | ALL ]&lt;br /&gt;  column_expression1, column_expression2, ....&lt;br /&gt;  [ FROM from_clause ]&lt;br /&gt;  [ WHERE where_expression ]&lt;br /&gt;  [ GROUP BY expression1, expression2, .... ]&lt;br /&gt;  [ HAVING having_expression ]&lt;br /&gt;  [ ORDER BY order_column_expr1, order_column_expr2, .... ]&lt;br /&gt;&lt;br /&gt;column_expression ::= expression [ AS ] [ column_alias ]&lt;br /&gt;&lt;br /&gt;from_clause ::= select_table1, select_table2, ...&lt;br /&gt;from_clause ::= select_table1 LEFT [OUTER] JOIN select_table2 ON expr  ...&lt;br /&gt;from_clause ::= select_table1 RIGHT [OUTER] JOIN select_table2 ON expr  ...&lt;br /&gt;from_clause ::= select_table1 [INNER] JOIN select_table2  ...&lt;br /&gt;&lt;br /&gt;select_table ::= table_name [ AS ] [ table_alias ]&lt;br /&gt;select_table ::= ( sub_select_statement ) [ AS ] [ table_alias ]&lt;br /&gt;&lt;br /&gt;order_column_expr ::= expression [ ASC | DESC ]&lt;br /&gt;The SELECT statement is used to form queries for extracting information out of the database. The following example query will return the number, quantity and price of all orders for more than 5 items sorted in descending order by order number. In addition it rounds the order price to two decimal places and applies a dollar ($) sign to the output. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;  SELECT number, quantity, CONCAT('$', ROUND(price, 2))&lt;br /&gt;    FROM Order&lt;br /&gt;   WHERE quantity &gt; 5&lt;br /&gt;ORDER BY number DESC &lt;br /&gt;The ORDER BY and GROUP BY clause may refer to a column, a column alias, or an expression. The HAVING clause is evaluated after the grouping and aggregate columns have been resolved. &lt;br /&gt;&lt;br /&gt;For examples of using SELECT with aggregate functions see the 'Internal SQL Functions' section. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;16. COMMIT and ROLLBACK syntax &lt;br /&gt;&lt;br /&gt;COMMIT&lt;br /&gt;ROLLBACK&lt;br /&gt;Transactional operations for closing a transaction and either committing all the changes made or rolling back and disposing all changes. COMMIT may cause a concurrent transaction conflict exception to be thrown. If a conflict is detected the transaction is automatically rolled back. See the 'Transactions' section of the documentation for further details of how Mckoi handles transactions. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;17. CREATE USER, ALTER USER and DROP USER syntax &lt;br /&gt;&lt;br /&gt;CREATE USER username SET PASSWORD 'password'&lt;br /&gt;[ SET GROUPS groups_list ]&lt;br /&gt;[ SET ACCOUNT ( LOCK | UNLOCK ) ]&lt;br /&gt;&lt;br /&gt;ALTER USER username SET PASSWORD 'password'&lt;br /&gt;[ SET GROUPS groups_list ]&lt;br /&gt;[ SET ACCOUNT ( LOCK | UNLOCK ) ]&lt;br /&gt;&lt;br /&gt;DROP USER username&lt;br /&gt;These are user management commands for creating/altering and dropping users in the system. Only members of the 'secure access' group are permitted to perform these operations, which includes the administrator user that is setup when the Mckoi database is created. &lt;br /&gt;&lt;br /&gt;The following example creates a user called 'harry' with the password 'cat'; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;  CREATE USER harry SET PASSWORD 'cat' &lt;br /&gt;See the 'JDBC Driver' section for documentation on connecting to a database using a username and password to connect to a database. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;18. GRANT/REVOKE syntax &lt;br /&gt;&lt;br /&gt;GRANT privileges ON database_object TO ( PUBLIC | user_list )&lt;br /&gt;[ WITH GRANT OPTION ]&lt;br /&gt;&lt;br /&gt;REVOKE [ GRANT OPTION FOR ] privileges ON database_object&lt;br /&gt;FROM ( PUBLIC | user_list )&lt;br /&gt;&lt;br /&gt;privileges ::= priv_item1, priv_item2, ...&lt;br /&gt;&lt;br /&gt;priv_item ::= ALL [ PRIVILEGES ] | SELECT | INSERT | UPDATE |&lt;br /&gt;              DELETE | REFERENCES | USAGE&lt;br /&gt;&lt;br /&gt;database_object ::= [ TABLE ] table_name | SCHEMA schema_name&lt;br /&gt;&lt;br /&gt;user_list ::= PUBLIC | username1, username2, ...&lt;br /&gt;Grants or revokes types of access on a table or view to a user. When a table or view is created the system gives full grant options to the user that created the object. The user is given the option to grant other users selective access to the object through the GRANT and REVOKE syntax. For example, the follow statement shows how a user would grant user 'toby' permission to SELECT from a table called MyTable; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;  GRANT SELECT ON TABLE MyTable TO toby&lt;br /&gt;The GRANT command allows granting all users access to an object. The following statement makes MyTable globally readable; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;  GRANT SELECT ON TABLE MyTable TO PUBLIC&lt;br /&gt;If you wish to give a user the option of granting a privilege to another user, add WITH GRANT OPTION to the GRANT statement. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;19. SET syntax &lt;br /&gt;&lt;br /&gt;SET variable = expression&lt;br /&gt;SET AUTO COMMIT ( ON | OFF )&lt;br /&gt;SET TRANSACTION ISOLATION LEVEL ( SERIALIZABLE )&lt;br /&gt;SET SCHEMA schema_name&lt;br /&gt;&lt;br /&gt;Makes a change to the state of the connection. SET AUTO COMMIT is used to switch transaction 'auto commit mode' on or off. When auto commit mode is on the engine commits after every statement. By default, a connection starts with auto commit mode switched on. SET TRANSACTION ISOLATION LEVEL currently only supports the SERIALIZABLE isolation level. See the 'Transactions' section of the documentation for details of how Mckoi handles transactions. &lt;br /&gt;&lt;br /&gt;SET SCHEMA is used to change the default schema of a connection. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;20. DESCRIBE syntax &lt;br /&gt;&lt;br /&gt;DESCRIBE table_name&lt;br /&gt;This command provides information about the columns of the table. It shows the column names, the type / size and scale (if applicable) and other useful information. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;21. SHOW syntax &lt;br /&gt;&lt;br /&gt;SHOW engine_variable&lt;br /&gt;&lt;br /&gt;engine_variable ::= TABLES | SCHEMA | STATUS | CONNECTIONS&lt;br /&gt;Shows internal information about the database system. SHOW TABLES returns a list of tables in the database. SHOW STATUS returns debugging and statistical information about the internal state of the database engine. SHOW CONNECTIONS returns a snapshot of the current connections on the database. SHOW SCHEMA lists all the schema defined. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;22. SHUTDOWN syntax &lt;br /&gt;&lt;br /&gt;SHUTDOWN&lt;br /&gt;Shuts down the database. If the database is running as a server the database shuts down cleanly and the process is stopped. If the database is embedded in a Java application it is cleanly put into a shut down state. &lt;br /&gt;&lt;br /&gt;Only a user with the correct grants may successfully execute this command.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7527040749709927669-2917537233785257307?l=jaan1762.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jaan1762.blogspot.com/feeds/2917537233785257307/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7527040749709927669&amp;postID=2917537233785257307' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/2917537233785257307'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/2917537233785257307'/><link rel='alternate' type='text/html' href='http://jaan1762.blogspot.com/2009/06/sql-syntax.html' title='SQL SYNTAX'/><author><name>Mansoor</name><uri>http://www.blogger.com/profile/00473621254256960630</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-7527040749709927669.post-8990807256329215534</id><published>2009-06-04T02:46:00.000-07:00</published><updated>2009-06-04T02:52:11.604-07:00</updated><title type='text'>Navigate to another URL by pressing enter key</title><content type='html'>&lt;strong&gt;Problem :&lt;/strong&gt; When I press enter , I want to navigate to another web page. I do not want to use form onsubmit event, as I am having the form tag on the master page. &lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;br /&gt;Solution:&lt;/strong&gt; &lt;br /&gt;I have a form which has a search text box. The user enters the search keywords and presses enter. &lt;br /&gt;Below is the code (HTML rendering in this blog is awful, sorry about the illegible code) which does that&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        &amp;lt;script language="javascript" type="text/javascript"&amp;gt;&lt;br /&gt;         function submitOnEnter(event)&lt;br /&gt;         {&lt;br /&gt;         var keycode;&lt;br /&gt;         if (window.event)&lt;br /&gt;          keycode = window.event.keyCode;&lt;br /&gt;          else if (e) keycode = e.which;&lt;br /&gt;          else return true;&lt;br /&gt;          if (keycode ==13)&lt;br /&gt;          {&lt;br /&gt;          location.href ="default.aspx";&lt;br /&gt;          location.reload; &lt;br /&gt;          // this always get me!! I forget to call the reload}&lt;br /&gt;&lt;br /&gt;          }&lt;br /&gt;          &amp;lt;/script&amp;gt;&lt;br /&gt;&lt;br /&gt;        &lt;div&gt;&lt;br /&gt;            Search&lt;input type="text" id="txtSearch" onkeypress="submitOnEnter(event)"&gt;&lt;br /&gt;            &lt;input   type="image" onmouseover="images/search1.gif" onmouseout="images/search2.gif"&lt;br /&gt;                onclick="default.aspx"&gt;&lt;br /&gt;        &lt;/div&gt;&lt;br /&gt;&lt;br /&gt;A much more simpler implementation can be done using JQuery. &lt;br /&gt;&lt;br /&gt;Thanks to  &lt;strong&gt;jackson pushpanathan  &lt;/strong&gt;for this piece of work.You can find the original code here &lt;/br&gt;&lt;br /&gt;http://technosia.blogspot.com/2008/10/navigate-to-another-url-by-pressing.html&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7527040749709927669-8990807256329215534?l=jaan1762.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jaan1762.blogspot.com/feeds/8990807256329215534/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7527040749709927669&amp;postID=8990807256329215534' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/8990807256329215534'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/8990807256329215534'/><link rel='alternate' type='text/html' href='http://jaan1762.blogspot.com/2009/06/navigate-to-another-url-by-pressing.html' title='Navigate to another URL by pressing enter key'/><author><name>Mansoor</name><uri>http://www.blogger.com/profile/00473621254256960630</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-7527040749709927669.post-5248467593529724538</id><published>2009-06-01T04:33:00.002-07:00</published><updated>2009-06-01T04:34:09.376-07:00</updated><title type='text'>c # Question and Answers</title><content type='html'>1) Explain about C#?&lt;br /&gt;C # is also known as c sharp. It is a programming language introduced by Microsoft. &lt;br /&gt;C# contains features similar to Java and C++. It is specially designed to work with Microsoft .NET platform.&lt;br /&gt;&lt;br /&gt;2) Explain about the rules for naming classes in C#?&lt;br /&gt;These are the rules for naming classes in c sharp.&lt;br /&gt;• Must begin with a letter. This letter may be followed by a sequence of letters, digits (0-9), or ‘_’. The first character in a class name cannot be a digit.&lt;br /&gt;• Must not contain any embedded space or symbol like ? - + ! @ # % &amp; * ( ) { } [ ] , : ; ‘ “ \ and/. However an underscore _ can be used wherever a space is required.&lt;br /&gt;• Must not use a keyword for a class name. &lt;br /&gt;&lt;br /&gt;3) What are the rules to be followed while naming variables in C#.&lt;br /&gt;The following rules are used for naming variables in C#.&lt;br /&gt;* Must begin with a letter or an underscore _ which may be followed by a sequence of letters, digits (0-9), or ‘_’. The first character in a variable name cannot be a digit.&lt;br /&gt;* Must not contain any embedded space or symbol like ? - + ! @ # % &amp; * ( ) { } [ ] , : ; ‘ “ \ and/. However an underscore _ can be used wherever a space is required.&lt;br /&gt;• Must be unique&lt;br /&gt;• Can have any number of characters&lt;br /&gt;• Keywords cannot be used as variable names. &lt;br /&gt;&lt;br /&gt;4) What are the different types of Data?&lt;br /&gt;There are two different types of data supported by C#. They are&lt;br /&gt;1) Value types: -They directly contain data. When you declare an int variable, the system allocates memory to store the value.&lt;br /&gt;2) Reference type: -The reference types do not maintain data but they contain a reference to the variables, which are stored in memory. This means that if the value in the memory location is modified by one of the variables, the other variables automatically reflect the changes value&lt;br /&gt;&lt;br /&gt;5) Explain about member functions?&lt;br /&gt;A function is a set of statements that perform a specific task in response to a message. The functions of a class are called member functions in Csharp. Member functions are declared inside the class. The function declaration introduces the function in the class and the function definition contains the function code.&lt;br /&gt;&lt;br /&gt;6) Explain about comment entry?&lt;br /&gt;Comments are a part of the program and are used to explain the code. Compilers ignore comment entries. If a comment entry spans more than one line, it has to be enclosed within ‘/*’ and ‘*/’. The symbol ‘//’ treats the rest of code within the same line as a comment.&lt;br /&gt;&lt;br /&gt;7) What are operators?&lt;br /&gt;Applications use operators to process the data entered by a user. Operators like + and – are used to process variables and return a value. An operator is a set of one or more characters that is used for computations or comparisons. Operators can transform one or more data values, called operands into a new data value. &lt;br /&gt;&lt;br /&gt;8) Explain about the break statement?&lt;br /&gt;A break statement is used to exit the switch statement. This prevents the execution of the remaining case structures by ending the execution of the switch case construct. Each break statement terminates the enclosing switch statement and the flow of control. If none of the cases match the default case is invoked.&lt;br /&gt;&lt;br /&gt;9) Define encapsulation?&lt;br /&gt;Encapsulation literally means to enclose in or as if in a capsule. Encapsulation is defined as the process of enclosing one or more items within a physical or logical package. It involves preventing access to nonessential details.&lt;br /&gt;&lt;br /&gt;10) Define access specifier with reference to class?&lt;br /&gt;An access specifier defines the scope of a class member. A class member refers to the variables and functions in a class. A program can have one or more classes. You may want some members of a class to be accessible to other classes. But, you may not want some other members of the class to be accessible outside the class.&lt;br /&gt;&lt;br /&gt;11) Describe about private access specifier?&lt;br /&gt;&lt;br /&gt;The private access specifier allows a class to hide its member variables and member functions from other class objects and functions. Therefore, the private member of a class is not visible outside a class. If a member is declared private, only the functions of that class can access the member. Even the instance of the class cannot access its members&lt;br /&gt;&lt;br /&gt;12) Explain about protected internal access specifier?&lt;br /&gt;This specifier allows a class to hide its member variables and member functions to be accessed from other class objects and functions, except the child class, within the application. The protected internal access specifier becomes important while implementing inheritance.&lt;br /&gt;&lt;br /&gt;13) Define parameter by value?&lt;br /&gt;Pass by value is the default mechanism for passing parameters to a method. The simplest definition of a value parameter is a data type name followed by a variable name. When a method is called, a new storage location is created for each value parameter. The values of the corresponding expressions are copied into them. The expression supplied for each value parameter must be similar to the declaration of the value parameter.&lt;br /&gt;&lt;br /&gt;14) State the methods through which parameters can be passed?&lt;br /&gt;Parameters can be passed by using any one of the following mechanism.&lt;br /&gt;Value: -They are sometimes called in or out parameters; therefore, the data can be transferred into the method but cannot be transferred out.&lt;br /&gt;Reference: -Are sometimes called in or out parameters, therefore, the data can be transferred into the method and out again.&lt;br /&gt;Output: -Are sometimes called out parameters, data can be transferred out of the method.&lt;br /&gt;&lt;br /&gt;15) Explain about reference parameter?&lt;br /&gt;A reference parameter is a reference to a memory location of a data member. Unlike a value parameter, a reference parameter does not create a new storage location. Instead a reference parameter represents the same location in memory as the variable that is supplied in the method call.&lt;br /&gt;&lt;br /&gt;16) How do you use a structure?&lt;br /&gt;A structure is a value type data type. When you want a single variable to hold related data of various data types, you can create a structure. To create a structure you use the struct keyword.&lt;br /&gt;&lt;br /&gt;17) What is an enumerator?&lt;br /&gt;Enumeration is a value data type, which means that enumeration contains its own values and cannot inherit or pass inheritance. Enumerator allows you to assign symbolic names or integral constants.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7527040749709927669-5248467593529724538?l=jaan1762.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jaan1762.blogspot.com/feeds/5248467593529724538/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7527040749709927669&amp;postID=5248467593529724538' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/5248467593529724538'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/5248467593529724538'/><link rel='alternate' type='text/html' href='http://jaan1762.blogspot.com/2009/06/c-question-and-answers.html' title='c # Question and Answers'/><author><name>Mansoor</name><uri>http://www.blogger.com/profile/00473621254256960630</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-7527040749709927669.post-8880307458395489819</id><published>2009-06-01T04:33:00.001-07:00</published><updated>2009-06-01T04:33:34.602-07:00</updated><title type='text'>.NET Assembly</title><content type='html'>What is a .NET assembly?&lt;br /&gt;An assembly is the primary building block of a .NET application and can take the form of a dynamic link library (DLL) or executable file (EXE). An assembly is a collection of functionality that is built, versioned, and deployed as a single implementation unit.&lt;br /&gt;&lt;br /&gt;What does an assembly contain?&lt;br /&gt;A .NET assembly may contain the following elements:&lt;br /&gt;&lt;br /&gt;Assembly Manifest - Metadata that describes the assembly and its contents (see below) &lt;br /&gt;Source Code - Compiled into Microsoft intermediate language (MSIL) &lt;br /&gt;Type Metadata - Defines all types, their properties and methods, and most importantly, public types exported from this assembly &lt;br /&gt;Resources - Icons, images, text strings and other resources &lt;br /&gt;The assembly manifest is required; the other elements are optional.&lt;br /&gt;&lt;br /&gt;What is an assembly manifest?&lt;br /&gt;An assembly manifest is metadata inside an assembly that describes everything there is to know about the assembly and its contents. The manifest contains:&lt;br /&gt;&lt;br /&gt;Strong Name - The assembly's name, version, culture, optional processor architecture, and public key (for shared assemblies) &lt;br /&gt;File Contents - Name and hash of all files in the assembly &lt;br /&gt;Type List - Types defined in the assembly, including public types that are exported from the assembly &lt;br /&gt;Resource List - Icons, images, text strings and other resources contained in the assembly &lt;br /&gt;Dependencies - Compile-time dependencies on other assemblies &lt;br /&gt;Security - Permissions required for the assembly to run properly &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;What is a multi-file assembly?&lt;br /&gt;An assembly can consist of one or more files called modules. Exactly one of these modules contains the assembly manifest. Note that the files in a multi-file assembly can reside in separate locations and are linked together with the assembly manifest.&lt;br /&gt;&lt;br /&gt;Multi-file assemblies are rare, and Visual Studio doesn't directly support their creation. The most common reason for multi-file assemblies is when a single assembly combines code from multiple programming languages. (more)&lt;br /&gt;&lt;br /&gt;What is the difference between a private and shared assembly?&lt;br /&gt;A private assembly is used only by a single application and is stored in that application's installation folder (or subfolder therein). The name of a private assembly name must be unique within the application that uses it.&lt;br /&gt;&lt;br /&gt;A shared assembly is used by multiple applications and is typically stored in a global folder known as the Global Assembly Cache (GAC). When building an assembly, a developer must specifically choose to build it as a shared assembly by giving it a cryptographically strong name. For example, the .NET Framework is a collection of shared assemblies.&lt;br /&gt;&lt;br /&gt;What is the difference between an assembly and a namespace?&lt;br /&gt;Namespaces are logical, whereas assemblies are physical.&lt;br /&gt;&lt;br /&gt;A namespace is a logical naming scheme to group related types. Namespaces can contain other namespaces to form a hierarchy. The "fully qualified name" of a type is its namespace followed by its type name, separated by a period (for example, System.Windows.Forms.Button). Type names must be unique within a namespace, but the same type name can be used in different namespaces.&lt;br /&gt;&lt;br /&gt;An assembly is a physical deployment scheme to group related types. An assembly can contain one or many namespaces. A namespace can exist in one or many assemblies.&lt;br /&gt;&lt;br /&gt;What are assembly attributes?&lt;br /&gt;Assembly attributes are values (typically set by the developer) that provide additional information about a .NET assembly. Assembly attributes are grouped as follows:&lt;br /&gt;&lt;br /&gt;Identity Attributes - Determine the identity of an assembly: name, version, culture and flags. &lt;br /&gt;Informational Attributes - Provide additional information about an assembly: company name, product name, copyright, trademark, and file version. &lt;br /&gt;Manifest Attributes - Provide information in the assembly manifest: assembly title, description, alias, and configuration (such as debug or release). &lt;br /&gt;Strong Name Attributes - Used to help set an assembly's strong name, including key file, key name, and whether delay signing is used. &lt;br /&gt;How do I set assembly attributes?&lt;br /&gt;There are two ways to set the attributes for an assembly in your development project. Using Visual Studio 2005:&lt;br /&gt;&lt;br /&gt;Option 1: AssemblyInfo File&lt;br /&gt;In the Visual Studio Solution Explorer, navigate to the Properties folder, then open the AssemblyInfo.cs file. You can directly edit the attributes in the AssemblyInfo file:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;// General information about an assembly is controlled through the following&lt;br /&gt;// set of attributes. Change these attribute values to modify the information&lt;br /&gt;// associated with an assembly.&lt;br /&gt;[assembly: AssemblyTitle( "MyAssembly" )]&lt;br /&gt;[assembly: AssemblyDescription( "Description of MyAssembly" )]&lt;br /&gt;[assembly: AssemblyConfiguration( "" )]&lt;br /&gt;[assembly: AssemblyCompany( "MyCompany" )]&lt;br /&gt;[assembly: AssemblyProduct( "MyProduct" )]&lt;br /&gt;[assembly: AssemblyCopyright( "Copyright (c) 2007 MyCompany Inc" )]&lt;br /&gt;[assembly: AssemblyTrademark( "MyProduct is a trademark of MyCompany Inc." )]&lt;br /&gt;[assembly: AssemblyCulture( "" )]&lt;br /&gt;&lt;br /&gt;// Setting ComVisible to false makes the types in this assembly not visible&lt;br /&gt;// to COM components.  If you need to access a type in this assembly from&lt;br /&gt;// COM, set the ComVisible attribute to true on that type.&lt;br /&gt;[assembly: ComVisible( false )]&lt;br /&gt;&lt;br /&gt;// The following GUID is for the ID of the typelib if this project is exposed to COM&lt;br /&gt;[assembly: Guid( "b7bfd909-f048-4d5b-9f33-1d0642398e4f" )]&lt;br /&gt;&lt;br /&gt;// Version information for an assembly consists of the following four values:&lt;br /&gt;//      Major Version&lt;br /&gt;//      Minor Version&lt;br /&gt;//      Build Number&lt;br /&gt;//      Revision&lt;br /&gt;[assembly: AssemblyVersion( "1.0.0.*" )]&lt;br /&gt;[assembly: AssemblyFileVersion( "1.0.0.0" )]&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Option 2: Project Properties&lt;br /&gt;Select your assembly project in the Visual Studio Solution Explorer. Click the Properties button. Select the Application tab. Then click the Assembly Information button. The following dialog will appear, allowing you to edit the assembly attributes:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;How do I access a loaded assembly?&lt;br /&gt;When working with assemblies, be sure to include the Reflection namespace:&lt;br /&gt;&lt;br /&gt;using System.Reflection;&lt;br /&gt;To access your application's main assembly (i.e., the executable file):&lt;br /&gt;&lt;br /&gt;Assembly asm = Assembly.GetExecutingAssembly();&lt;br /&gt;To access an external assembly loaded by your application, call GetAssembly with a type defined in the external assembly:&lt;br /&gt;&lt;br /&gt;Assembly asm = Assembly.GetAssembly( typeof( MyType ) );&lt;br /&gt;How do I retrieve assembly attributes programmatically?&lt;br /&gt;Once you have the Assembly object as shown above, you can obtain its identity attributes from its associated AssemblyName object:&lt;br /&gt;&lt;br /&gt;AssemblyName asmName = asm.GetName();&lt;br /&gt;Console.WriteLine( "Name={0}, Version={1}, Culture={2}, ProcessorArchitecture={3}",&lt;br /&gt;    asmName.Name, asmName.Version, asmName.CultureInfo, asmName.ProcessorArchitecture );For all other assembly attributes, you can load the attribute directly with the GetCustomAttributes method:&lt;br /&gt;&lt;br /&gt;// assembly description attribute&lt;br /&gt;string asmDesc = ((AssemblyDescriptionAttribute)asm.GetCustomAttributes(&lt;br /&gt;    typeof( AssemblyDescriptionAttribute ), false )[0]).Description;&lt;br /&gt;// assembly title attribute&lt;br /&gt;string asmTitle = ((AssemblyTitleAttribute)asm.GetCustomAttributes(&lt;br /&gt;    typeof( AssemblyTitleAttribute ), false )[0]).Title;&lt;br /&gt;// etc.&lt;br /&gt;&lt;br /&gt;To view all attributes for an assembly:&lt;br /&gt;&lt;br /&gt;object[] attributes = asm.GetCustomAttributes( true );&lt;br /&gt;foreach (object obj in attributes)&lt;br /&gt;{&lt;br /&gt;    Console.WriteLine( obj.ToString() );&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;What is a strong name?&lt;br /&gt;A strong name is a .NET assembly name combined with its version number and other information to uniquely identify the assembly. This allows multiple versions of the same assembly to peacefully co-exist in the global assembly cache, where shared assemblies are typically stored.&lt;br /&gt;&lt;br /&gt;A strong name consists of five parts:&lt;br /&gt;&lt;br /&gt;Simple Name - Usually the name of the file (without the extension) that contains the assembly &lt;br /&gt;Public Key - RSA cryptographic public key that helps verify the assembly's authenticity &lt;br /&gt;Version - Four-part version number, in the form of Major.Minor.Build.Revision &lt;br /&gt;Culture - Target audience for the assembly, such as "neutral" (default audience), "en-us" (English - United States) or "fr" (France) etc. &lt;br /&gt;Processor Architecture - Defines the assembly's format, such as MSIL (intermediate language) or x86 (binary for Intel x86 processors) &lt;br /&gt;An example strong name is "Mini-Launcher, Version=0.3.612.24542, Culture=neutral, PublicKeyToken=ffa52ed9739048b4, ProcessorArchitecture=MSIL".&lt;br /&gt;&lt;br /&gt;Why use strong names?&lt;br /&gt;Strong names are required to store shared assemblies in the global assembly cache (GAC). This is because the GAC allows multiple versions of the same assembly to reside on your system simultaneously, so that each application can find and use its own version of your assembly. This helps avoid DLL Hell, where applications that may be compiled to different versions of your assembly could potentially break because they are all forced to use the same version of your assembly.&lt;br /&gt;&lt;br /&gt;Another reason to use strong names is to make it difficult for hackers to spoof your assembly, in other words, replace or inject your assembly with a virus or malicious code.&lt;br /&gt;&lt;br /&gt;What is a strong name key file?&lt;br /&gt;A strong name key file has a .snk extension and contains a unique public-private key pair. You use the strong name key file to digitally sign your assembly (see below). Note that this type of file is not secure, as the private key in a .snk file can be easily compromised.&lt;br /&gt;&lt;br /&gt;For added protection, Visual Studio can encrypt a strong name key file, which produces a file with the .pfx (Personal Information eXchange) extension. The .pfx file is more secure because whenever someone attempts to use the encrypted key, she will be prompted for the password.&lt;br /&gt;&lt;br /&gt;How do I create a strong name key file for a .NET assembly?&lt;br /&gt;Visual Studio 2005 makes it easy to create a strong name key file:&lt;br /&gt;&lt;br /&gt;Select your assembly project in the Visual Studio Solution Explorer. &lt;br /&gt;Click the Properties button. The project properties will appear in the main window. &lt;br /&gt;Select the Signing tab: &lt;br /&gt;Check the Sign the assembly checkbox. &lt;br /&gt;In the Choose a strong name key file drop-down, select New. The "Create Strong Name Key" dialog appears: &lt;br /&gt;In the Key file name text box, type the desired key name. Typically this is the name of your assembly but can be anything. Visual Studio will automatically append the proper file extension. &lt;br /&gt;If desired, you can protect the strong name key file with a password. To do so, check the Protect my key file with a password checkbox, then enter and confirm the password. &lt;br /&gt;Click the OK button. &lt;br /&gt;Now when you compile your project, Visual Studio will automatically sign your assembly with the new strong name key you have just created.&lt;br /&gt;&lt;br /&gt;Or if you prefer to use the command-line, you can create a key pair file with the strong name utility sn.exe in the .NET SDK, for example:&lt;br /&gt;&lt;br /&gt;sn -k MyKey.snk&lt;br /&gt;&lt;br /&gt;Then you reference that key file to when compiling your code with the C# compiler csc.exe:&lt;br /&gt;&lt;br /&gt;csc /keyfile:MyKey.snk MyCodeFile.cs&lt;br /&gt;&lt;br /&gt;What does it mean to sign an assembly?&lt;br /&gt;.NET uses digital signatures to verify the integrity of an assembly. The signatures are generated and verified using public key cryptography, specifically the RSA public key algorithm and SHA-1 hash algorithm. The developer uses a pair of cryptographic keys: a public key, which everyone can see, and a private key, which the developer must keep secret.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;To create a strong-named assembly, the developer signs the assembly with his private key when building the assembly. When the system later loads the assembly, it verifies the assembly with the corresponding public key.&lt;br /&gt;&lt;br /&gt;How do I sign an assembly?&lt;br /&gt;When you compile your assembly with a strong name key file, the compiler digitally signs the assembly:&lt;br /&gt;&lt;br /&gt;The compiler calculates the cryptographic digest (a hash) of your assembly contents. This is known as the compile-time digest. Modifying just a single byte of your assembly will change this hash value. &lt;br /&gt;The compiler encrypts the digest using the 1024-bit private key from your public-private key pair file. &lt;br /&gt;The compiler then stores the encrypted digest and public key into the assembly. &lt;br /&gt;How does the system verify a signed assembly?&lt;br /&gt;Sometime later, when an application attempts to load your signed assembly:&lt;br /&gt;&lt;br /&gt;The .NET assembly loader calculates the cryptographic digest of the current assembly contents. This is known as the run-time digest. &lt;br /&gt;The loader extracts the stored compile-time digest and public key from the assembly. &lt;br /&gt;The loader uses the public key to decrypt the compile-time digest. &lt;br /&gt;The loader then compares the run-time digest with the decrypted compile-time digest to ensure they match. If not, then the assembly has been modified since you compiled it, and the assembly load fails. &lt;br /&gt;This process is different when loading shared assemblies from the GAC. Because assemblies are verified when they are first installed into the GAC–and they cannot be modified while in the GAC–the .NET assembly loader does not verify an assembly when loading it from the GAC. This can improve the startup speed of your application if you load many shared assemblies.&lt;br /&gt;&lt;br /&gt;What is delay signing?&lt;br /&gt;Delay signing is signing an assembly with its strong name public key, which is freely distributable, instead of using the private key as usual. This allows developers to use and test a strong-named assembly without access to the private key. Then at a later stage (typically just before shipping the assembly), a manager or trusted keyholder must sign the assembly with the corresponding private key. (more)&lt;br /&gt;&lt;br /&gt;How do I protect my private keys?&lt;br /&gt;Private keys must remain secret. A hacker with your private key could spoof your signed assemblies by replacing or injecting them with a virus or other malicious code. There are a few strategies you can use to protect your private keys:&lt;br /&gt;&lt;br /&gt;Password Protection. As shown above, Visual Studio will allow you to protect your strong name key file with a password. &lt;br /&gt;Delay Signing. As mentioned above, delay signing enables your development team to build and test your assembly without access to the private key. &lt;br /&gt;Cryptographic Container. One of the most secure ways to protect your strong name key is to store it in a secure cryptographic container (see sidebar "Protecting Your Keys" in this article). &lt;br /&gt;How many private keys should I have?&lt;br /&gt;There are three main strategies for how many private keys a developer should use:&lt;br /&gt;&lt;br /&gt;One private key for all your applications and assemblies &lt;br /&gt;One private key for each application (an application may have multiple assemblies) &lt;br /&gt;One private key for each assembly &lt;br /&gt;Which option to use depends on your security situation and risk tolerance. With option 1, it's easier to keep a single key secure, but if your one private key is compromised, then all of your assemblies are compromised. With option 3, there are more keys to manage and hence lose, but if one key is compromised, then only one of your many assemblies is compromised. I recommend option 2 or 3 to reduce your overall exposure.&lt;br /&gt;&lt;br /&gt;Are there problems with using strong names?&lt;br /&gt;Strong names are not perfect. There are some issues to consider when using strong names:&lt;br /&gt;&lt;br /&gt;Requires Exact Match. If you use strong names, your application or library must load the assembly with the exact strong name that you specify, including version and culture. Note that you can bypass this requirement with a publisher policy (to be discussed in a future article). &lt;br /&gt;Cannot Lose Private Key. If your private key is lost or stolen, the security of your assembly is compromised. You will be forced to re-issue a new assembly signed with a new public-private key pair. &lt;br /&gt;Cannot Stop Full Replacement. Strong names cannot prevent a hacker from removing the strong name signature, maliciously modifying your assembly, re-signing it with his own key, and then passing off his assembly as yours. The user must have some way to ensure the public key they have from your assembly is valid and truly came from you. Note that you can use more sophisticated signing schemes (such as Authenticode) to help with this issue.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Where are shared assemblies stored?&lt;br /&gt;A shared assembly is used by multiple applications. You can store shared assemblies pretty much anywhere. However, the challenge is to ensure that all dependent applications can find the shared assembly. The recommended way to ensure this is to store shared assemblies in the Global Assembly Cache.&lt;br /&gt;&lt;br /&gt;What is the Global Assembly Cache (GAC)?&lt;br /&gt;The Global Assembly Cache is a system folder (typically C:\Windows\assembly) that contains .NET shared assemblies. Companies that wish to share assemblies with others or even just among their own applications typically store these shared assemblies in the GAC. All of the .NET framework libraries are stored in the GAC.&lt;br /&gt;&lt;br /&gt;Why should I store my shared assemblies in the GAC?&lt;br /&gt;You should install assemblies in the GAC only when necessary. As a general guideline, assemblies should be kept private and stored in the application's folder unless you explicitly need to share them. There are some benefits to storing shared assemblies in the GAC:&lt;br /&gt;&lt;br /&gt;Global Location&lt;br /&gt;&lt;br /&gt;The GAC is the known standard location for .NET shared assemblies. When an application attempts to load an assembly, the GAC is one of the first places it looks. If there's any chance that an application outside your control may someday require access to your shared assembly, you should install your assembly in the GAC so the application is sure to find it.&lt;br /&gt;&lt;br /&gt;Security&lt;br /&gt;The GAC is a system folder typically protected by administrator rights. Once an assembly is installed in the GAC, it cannot be easily modified. Also, assemblies stored in the GAC must be signed with a cryptographic key. These protections make it difficult to spoof your assembly, in other words, replace or inject your assembly with a virus or malicious code.&lt;br /&gt;&lt;br /&gt;Version Management&lt;br /&gt;.NET allows multiple versions of the same assembly to reside in the GAC so that each application can find and use the version of your assembly to which it was compiled. This helps avoid DLL Hell, where applications that may be compiled to different versions of your assembly could potentially break because they are all forced to use a single version of your assembly.&lt;br /&gt;&lt;br /&gt;Faster Loading&lt;br /&gt;The system verifies assemblies when they are first installed in the GAC, eliminating the need to verify an assembly each time it is loaded from the GAC. This can improve the startup speed of your application if you load many shared assemblies.&lt;br /&gt;&lt;br /&gt;Why would I avoid the GAC?&lt;br /&gt;The GAC should contain "global" shared assemblies only, so there are many instances when you would NOT install an assembly in the GAC:&lt;br /&gt;&lt;br /&gt;The assembly is private to your application and not to be shared with other applications. &lt;br /&gt;You want to use XCOPY or FTP copy to install a .NET application to a single folder. This eliminates the need to access the Registry and GAC and does not require administrator rights. &lt;br /&gt;The assembly is not strong-named or you do not want tight version control. &lt;br /&gt;COM interop and unmanaged code do not require the GAC. &lt;br /&gt;How do I see assemblies installed in the GAC?&lt;br /&gt;The .NET Framework includes an Assembly Cache Viewer. Open Windows Explorer, enter %windir%\assembly in the address bar, and all global assemblies will appear in a special view that shows the assembly name, version, culture, public key token, and processor architecture.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Can I install multiple versions of the same assembly in the GAC?&lt;br /&gt;Yes. Normally you would not be able to have two files with the same name in a Windows folder, but the GAC is a special folder that stores its contents by strong name. Hence, two assemblies with the same name but different versions or cultures may coexist in the GAC.&lt;br /&gt;&lt;br /&gt;How do I add/remove assemblies from the GAC?&lt;br /&gt;Assemblies added to the GAC must be signed with a strong name. There are multiple ways to add/remove assemblies from the GAC:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Windows Installer&lt;br /&gt;The preferred way to add/remove assemblies from the GAC is with Microsoft Windows Installer 2.0. Visual Studio includes a limited version of Windows Installer, and most major setup programs such as InstallShield also use Windows Installer. There are benefits to using Windows Installer:&lt;br /&gt;&lt;br /&gt;Windows Installer provides a simple interface for developers to add/remove shared assemblies in the GAC and can handle private assemblies as well. &lt;br /&gt;Installer provides a familiar interface and setup experience for the user. &lt;br /&gt;Installer can also install application shortcuts and supporting files such as ReadMe and license agreements and can run other installation programs and scripts. &lt;br /&gt;Installer registers and tracks references to assemblies installed in the GAC to determine which assemblies are still required. &lt;br /&gt;Installer can repair and patch assemblies and rollback unsuccessful installations. &lt;br /&gt;Installer can install assemblies on-demand as they are needed by applications. &lt;br /&gt;GAC Utility&lt;br /&gt;The .NET developer's kit includes a command line utility GACutil.exe to interact with the GAC. This utility is intended for use in a development environment only and should not be used to install assemblies on a client PC because:&lt;br /&gt;&lt;br /&gt;The GACutil license agreement states that it is not freely distributable. &lt;br /&gt;GACutil is part of the .NET SDK, which may not be installed on many target PCs. &lt;br /&gt;GACutil lacks many important features found in Windows Installer such as assembly repair and rollback. &lt;br /&gt;Assembly Cache Viewer&lt;br /&gt;Using the Assembly Cache Viewer shown above, you can drag &amp; drop assemblies from any folder into the GAC and also delete assemblies installed in the GAC.&lt;br /&gt;&lt;br /&gt;.NET Framework Configuration Administrative Tool&lt;br /&gt;To access the .NET Framework Configuration Tool:&lt;br /&gt;&lt;br /&gt;Click Start &gt; Control Panel. &lt;br /&gt;Double-click on Administrative Tools. &lt;br /&gt;Double-click on Microsoft .NET Framework 2.0 Configuration. &lt;br /&gt;Ensure My Computer is selected in the tree. &lt;br /&gt;In the Tasks group, click the Manage the Assembly Cache link. &lt;br /&gt;Two links appear, enabling you to view and add assemblies in the GAC. &lt;br /&gt;How do I access the GAC programmatically?&lt;br /&gt;You can access the GAC from code with the fusion.dll library. Here is an excellent C# wrapper for the GAC.&lt;br /&gt;&lt;br /&gt;You are strongly advised NOT to access the GAC from code unless you are creating an administrative or setup tool. The Fusion APIs expose your application to the inner workings of assembly binding and may cause your application to fail on future .NET versions.&lt;br /&gt;&lt;br /&gt;How do I add my shared assembly to the Visual Studio "Add Reference" dialog?&lt;br /&gt;If you add an assembly to the GAC, it will NOT automatically appear in the Visual Studio "Add Reference" dialog; instead you must add your assembly manually.&lt;br /&gt;&lt;br /&gt;How do I move the GAC?&lt;br /&gt;When installing .NET, you cannot configure the GAC location, however you can move the GAC after it is installed. See this article and scroll down to "Relocating the GAC."&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7527040749709927669-8880307458395489819?l=jaan1762.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jaan1762.blogspot.com/feeds/8880307458395489819/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7527040749709927669&amp;postID=8880307458395489819' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/8880307458395489819'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7527040749709927669/posts/default/8880307458395489819'/><link rel='alternate' type='text/html' href='http://jaan1762.blogspot.com/2009/06/net-assembly.html' title='.NET Assembly'/><author><name>Mansoor</name><uri>http://www.blogger.com/profile/00473621254256960630</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-7527040749709927669.post-3333101039403092429</id><published>2009-06-01T02:29:00.000-07:00</published><updated>2009-06-01T02:31:07.963-07:00</updated><title type='text'>Constraints</title><content type='html'>&lt;p&gt;&lt;br /&gt;&lt;strong&gt;CONSTRAINTS&lt;br /&gt;&lt;br /&gt;&lt;/strong&gt;A constraint is a property assigned to a column or the set of columns in&lt;br /&gt;a table that prevents certain types of inconsistent data values from being placed&lt;br /&gt;in the column(s). &lt;strong&gt;Constraints are used to enforce the data integrity&lt;/strong&gt;.&lt;br /&gt;This ensures the accuracy and reliability of the data in the database.&lt;br /&gt;&lt;br /&gt;The following categories of the data integrity exist:&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Entity Integrity&lt;/b&gt; : Entity Integrity ensures that there are no duplicate rows&lt;br /&gt;in a table.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Domain Integrity :&lt;/b&gt; Domain Integrity enforces valid entries for a given column&lt;br /&gt;by restricting the type, the format, or the range of possible values.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Referential integrity&lt;/b&gt; : Referential integrity ensures that rows cannot be&lt;br /&gt;deleted, which are used by other records (for example,corresponding data values&lt;br /&gt;between tables will be vital).&lt;br /&gt;&lt;br /&gt;&lt;b&gt;User-Defined Integrity&lt;/b&gt; : User-Defined Integrity enforces some specific business&lt;br /&gt;rules that do not fall into entity, domain, or referential integrity categories.&lt;br /&gt;Each of these categories of the data integrity can be enforced by the appropriate&lt;br /&gt;constraints.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;Microsoft SQL Server supports the following constraints:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/strong&gt;PRIMARY KEY&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;UNIQUE&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;FOREIGN KEY&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;CHECK&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;NOT NULL&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;A PRIMARY KEY constraint&lt;/strong&gt; is a unique identifier for a row within&lt;br /&gt;a database table. Every table should have a primary key constraint to uniquely identify&lt;br /&gt;each row and only one primary key constraint can be created for each table. The&lt;br /&gt;primary key constraints are used to enforce entity integrity.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;A UNIQUE constraint&lt;/strong&gt; enforces the uniqueness of the values in a&lt;br /&gt;set of columns, so no duplicate values are entered. The unique key constraints are&lt;br /&gt;used to enforce entity integrity as the primary key constraints.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Each table can have only one primary key. If there are multiple UNIQUE identifiers&lt;br /&gt;for a multiple columns, such column pairs are often referred to as alternate keys&lt;br /&gt;or candidate keys (these terms are not used by SQL Server). In practice, one of&lt;br /&gt;two columns is logically promoted to primary key using the PRIMARY KEY constraint,&lt;br /&gt;and the other is usually declared by a UNIQUE constraint. Internally, PRIMARY KEY&lt;br /&gt;and UNIQUE constraints are handled almost identically.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Here two ways to create a table:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;           Create table customer(cust_id int IDENTITY&lt;br /&gt;not null PRIMARY KEY, cust_name varchar(30) not null)&lt;br /&gt;&lt;br /&gt;           Create table customer(cust_id int IDENTITY&lt;br /&gt;not null, cust_name varchar(30) not null, PRIMARY KEY(cust_id))&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;A FOREIGN KEY constraint&lt;/strong&gt; prevents any actions that would destroy&lt;br /&gt;link between tables with the corresponding data values. A foreign key in one table&lt;br /&gt;points to a primary key in another table. Foreign keys prevent actions that would&lt;br /&gt;leave rows with foreign key values when there are no primary keys with that value.&lt;br /&gt;The foreign key constraints are used to enforce referential integrity.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;A FOREIGN KEY is a column whose values are derived from the PRIMARY KEY or UNIQUE&lt;br /&gt;KEY of some other table.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    By using ON DELETE CASCADE option and if a user deletes a record in&lt;br /&gt;the master table, all corresponding recording in the detail table along with the&lt;br /&gt;record in the master table will be deleted.&lt;br /&gt;&lt;br /&gt;              Create table orders(order_id&lt;br /&gt;int not null PRIMARY KEY, cust_id int not null REFERENCES customer(cust_id) ON DELETE&lt;br /&gt;CASCADE)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;A table can have a maximum of 253 FOREIGN KEY references. This limit is derived&lt;br /&gt;from the internal limit of 256 tables in a single query. If you’re dropping tables,&lt;br /&gt;you must drop all the referencing tables or drop the referencing FOREIGN KEY constraint&lt;br /&gt;before dropping the referenced table.&lt;br /&gt;&lt;br /&gt;               DROP TABLE orders DROP TABLE&lt;br /&gt;customer&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt; A CHECK constraint&lt;/strong&gt; is used to limit the values that can be&lt;br /&gt;placed in a column. The check constraints are used to enforce domain integrity.&lt;br /&gt;&lt;br /&gt;Check constraints allow us to define an expression for a table that must not evaluate&lt;br /&gt;to FALSE for a data modification statement to succeed.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Check constraints deal only with some logical expression for the specific row already&lt;br /&gt;being operated on, so no additional I/O required.&lt;br /&gt;&lt;br /&gt;       Create table employee(emp_id int not null PRIMARY KEY&lt;br /&gt;&lt;br /&gt;                  CHECK(emp_id between&lt;br /&gt;0 and 1000), emp_name varchar(30) not null constraint no_nums&lt;br /&gt;&lt;br /&gt;                  CHECK(emp_name&lt;br /&gt;not like ‘%[0-9]%’), entered_date datetime null&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;                  CHECK(entered_date&amp;gt;=CURRENT_TIMESTAMP),&lt;br /&gt;dept_no int CHECK(dept_no &amp;lt; 0 and dept_no &amp;gt; 100))&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;A NOT NULL constraint&lt;/strong&gt; enforces that the column will not accept&lt;br /&gt;null values. The not null constraints are used to enforce domain integrity, as the&lt;br /&gt;check constraints.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;A&lt;/strong&gt; &lt;strong&gt;DEFAULT Constraints:&lt;/strong&gt; A default allows you to&lt;br /&gt;specify a constant value, NULL or the run-time value of a system function if no&lt;br /&gt;known value exists or if the column is missing in an INSERT statement.&lt;br /&gt;&lt;br /&gt;                     &lt;br /&gt;Create table employee(emp_id int not null PRIMARY KEY DEFAULT 1000 CHECK(emp_id&lt;br /&gt;between 0 and 1000), emp_name varchar(20) DEFAULT 'Radha Krishna')&lt;br /&gt;&lt;br /&gt;Insert into employee values(DEFAULT, DEFAULT)&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;The order of Integrity checks is as follows&lt;/strong&gt;:&lt;br /&gt;&lt;br /&gt;1. Defaults are applied as appropriate.&lt;br /&gt;&lt;br /&gt;2. NOT NULL violations are raised.&lt;br /&gt;&lt;br /&gt;3. CHECK constraints are evaluated.&lt;br /&gt;&lt;br /&gt;4. FOREIGN KEY checks of referencing tables are applied.&lt;br /&gt;&lt;br /&gt;5. FOREIGN KEY checks of referenced tables are applied.&lt;br /&gt;&lt;br /&gt;6. UNIQUE/PRIMARY KEY is checked for correctness.&lt;br /&gt;&lt;br /&gt;7. Triggers fire.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;You can add constraints to an existing table by using the &lt;strong&gt;ALTER TABLE statement&lt;/strong&gt;.&lt;br /&gt;&lt;br /&gt;The following example adds a pk_employee primary key constraint on an employee table:&lt;br /&gt;&lt;br /&gt;            ALTER TABLE employee&lt;br /&gt;&lt;br /&gt;            ADD CONSTRAINT pk_employee PRIMARY KEY&lt;br /&gt;(EmployeeId)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;You can add the primary or unique key constraint into an existing table only when&lt;br /&gt;there are no duplicate rows in the table. You can drop constraints in an existing&lt;br /&gt;table by using the ALTER TABLE statement.&lt;br /&gt;&lt;br /&gt;The following example drops the pk_employee primary key constraint in the employee&lt;br /&gt;table:&lt;br /&gt;&lt;br /&gt;            ALTER TABLE employee&lt;br /&gt;            DROP CONSTRAINT pk_employee&lt;br /&gt;&lt;br /&gt;Sometimes you need to perform some actions that require the FOREIGN KEY or CHECK&lt;br /&gt;constraints be disabled, for example, your company do not hire foreign employees,&lt;br /&gt;you made the appropriate constraint, but the situation was changed and your boss&lt;br /&gt;need to hire the foreign employee, but only this one.&lt;br /&gt;&lt;br /&gt;In this case, you need to disable the constraint by using the ALTER TABLE statement.&lt;br /&gt;&lt;br /&gt;After these actions will be performed, you can re-enable the FOREIGN KEY and CHECK&lt;br /&gt;constraints by using the ALTER TABLE state
