<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2enclosuresfull.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:media="http://search.yahoo.com/mrss/" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0"><channel><title>DOTNET TUTORIALS</title><link>http://dotnetfaqs-edu.blogspot.com/</link><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/blogspot/ynBt" /><description>ASP.NET,VB.NET,C#.NET,SQL Tutorials</description><language>en</language><managingEditor>noreply@blogger.com (Tiru)</managingEditor><lastBuildDate>Thu, 12 Feb 2009 05:24:48 PST</lastBuildDate><generator>Blogger http://www.blogger.com</generator><openSearch:totalResults xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/">667</openSearch:totalResults><openSearch:startIndex xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/">1</openSearch:startIndex><openSearch:itemsPerPage xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/">25</openSearch:itemsPerPage><itunes:owner><itunes:email>noreply@blogger.com</itunes:email></itunes:owner><itunes:explicit>no</itunes:explicit><itunes:subtitle>ASP.NET,VB.NET,C#.NET,SQL Tutorials</itunes:subtitle><creativeCommons:license>http://creativecommons.org/licenses/by/2.0/</creativeCommons:license><image><link>http://creativecommons.org/licenses/by/2.0/</link><url>http://creativecommons.org/images/public/somerights20.gif</url><title>Some Rights Reserved</title></image><feedburner:emailServiceId>blogspot/ynBt</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><item><title>How to open popup windows in IE/Firefox and return values using ASP.NET and Javascript</title><link>http://feedproxy.google.com/~r/blogspot/ynBt/~3/fgxpEy9lTMc/how-to-open-popup-windows-in-iefirefox.html</link><category>ASP.NET Tutorials</category><author>noreply@blogger.com (Tiru)</author><pubDate>Thu, 12 Feb 2009 05:24:48 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-6426652519813936980.post-601685180541068564</guid><description>&lt;div style="margin: 0in 0in 10pt;" align="justify"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Verdana;"&gt;With the forums flooded with questions of opening a popup window, passing values to the popup window and then return values back to the parent p&lt;span&gt;age using both Internet Explorer and Firefox, I decided to take a plunge into the subject and experiment with an easy implementation. This article explains how to transfer values between the Parent page and a Pop-up window. The code has been tested against IE7 and Firefox.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;" align="justify"&gt;&lt;span style="font-family:Verdana;font-size:85%;"&gt;Internet Explorer(IE) contains the &lt;/span&gt;&lt;span style="font-family:Verdana;font-size:85%;color:#0000ff;"&gt;showModalDialog()&lt;/span&gt;&lt;span style="font-family:Verdana;font-size:85%;"&gt; method which proves very effective while creating a &lt;u&gt;modal&lt;/u&gt; dialog box and displaying a html document in it. One caveat being, showModalDialog() is not a W3C implementation. So it is not supported in Firefox (as of version 2.0.0.11). Firefox supports the &lt;/span&gt;&lt;span style="font-family:Verdana;font-size:85%;color:#0000ff;"&gt;window.open()&lt;/span&gt;&lt;span style="font-family:Verdana;font-size:85%;"&gt; method. However there is no built in functionality in Firefox that keeps the popup modal. At the most, you can use �??modal=yes�?? to make the popup appear in front. However unlike the showModalDialog() in IE, you cannot restrict the user to access the parent page when the popup is opened in Firefox. In short, it is not truly modal. There are different ways to get around this problem, however in this article, we will only focus on exchanging values between the parent and popup page.&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;" align="justify"&gt;&lt;span style="font-family:Verdana;font-size:85%;"&gt;In this article, we will see how to take a simple approach and create a popup window using both IE and Firefox. In the first part, we will pass in the first name from the parent page to the popup window. In the second part, the popup window will reverse the name and return the reversed string to the parent window. All set!! Let us get started.&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;" align="justify"&gt;&lt;b&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Verdana;"&gt;Part 1 - Passing value to Popup window&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;" align="justify"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Verdana;"&gt;&lt;b&gt;Step 1:&lt;/b&gt; Open Visual Studio. Create a new website (File &gt; New &gt; Website). Set the location, filename and language of the project.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;" align="justify"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Verdana;"&gt;&lt;b&gt;Step 2:&lt;/b&gt; In your Default.aspx, add a label (lblFName), textbox (txtFName) and a button (btnPopup). Set the �??Text�?? property of the label to �??FirstName�??. Similarly set the �??Text�?? property of the button control to �??Show Popup�??.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;" align="justify"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Verdana;"&gt;&lt;b&gt;Step 3:&lt;/b&gt; Now add the popup form. Right click your project &gt; Add New Item &gt; Web Form &gt; Rename form as �??PopupWin.aspx�?? and click on Add.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;" align="justify"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Verdana;"&gt;&lt;b&gt;Step 4:&lt;/b&gt; In the PopupWin.aspx, add a textbox (txtReverse) and a button (btnReverse).&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;" align="justify"&gt;&lt;span style="font-family:Verdana;font-size:85%;"&gt;Well now we have two pages, Default.aspx which is the parent page and PopupWin.aspx which will be the popup page. Let us now pass a value from Default.aspx to the popup window.&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;" align="justify"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Verdana;"&gt;&lt;b&gt;Step 5:&lt;/b&gt; We will invoke the popup window on the button (btnPopup) click of Default.aspx. To do so, we will use Button.Attribute.Add and call a javascript function that will open the popup window. The javascript function will be contained in a seperate pop.js file which we will create shortly. Add this code in the code behind file of your Default.aspx.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;"&gt;&lt;span style="font-family:Verdana;font-size:85%;"&gt;C#&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color: blue; font-family: 'Courier New';"&gt;protected&lt;/span&gt;&lt;span style="font-family: 'Courier New';"&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; Page_Load(&lt;span style="color: blue;"&gt;object&lt;/span&gt; sender, &lt;span style="color: rgb(43, 145, 175);"&gt;EventArgs&lt;/span&gt; e)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;    {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;        btnPopup.Attributes.Add(&lt;span style="color: rgb(163, 21, 21);"&gt;"onClick"&lt;/span&gt;, &lt;span style="color: rgb(163, 21, 21);"&gt;"javascript:InvokePop('"&lt;/span&gt; + txtFName.ClientID + &lt;span style="color: rgb(163, 21, 21);"&gt;"');"&lt;/span&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;    } &lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;"&gt;&lt;span style="font-family:Verdana;font-size:85%;"&gt;VB.NET&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color: blue; font-family: 'Courier New';"&gt;Protected&lt;/span&gt;&lt;span style="font-family: 'Courier New';"&gt; &lt;span style="color: blue;"&gt;Sub&lt;/span&gt; Page_Load(&lt;span style="color: blue;"&gt;ByVal&lt;/span&gt; sender &lt;span style="color: blue;"&gt;As&lt;/span&gt; &lt;span style="color: blue;"&gt;Object&lt;/span&gt;, &lt;span style="color: blue;"&gt;ByVal&lt;/span&gt; e &lt;span style="color: blue;"&gt;As&lt;/span&gt; System.EventArgs) &lt;span style="color: blue;"&gt;Handles&lt;/span&gt; &lt;span style="color: blue;"&gt;Me&lt;/span&gt;.Load&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;        btnPopup.Attributes.Add(&lt;span style="color: rgb(163, 21, 21);"&gt;"onClick"&lt;/span&gt;, &lt;span style="color: rgb(163, 21, 21);"&gt;"javascript:InvokePop('"&lt;/span&gt; &amp;amp; txtFName.ClientID &amp;amp; &lt;span style="color: rgb(163, 21, 21);"&gt;"');"&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;    &lt;span style="color: blue;"&gt;End&lt;/span&gt; &lt;span style="color: blue;"&gt;Sub&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;" align="justify"&gt;&lt;span style="font-family:Verdana;font-size:85%;"&gt;Over here we are passing the ClientID of the textbox. ClientID is the identifier of the server control, generated by ASP.NET. You must be wondering why I am not passing the value of the textbox directly. Well passing the control has an advantage where there is more than one control that is passed to the popup page. While returning back the values from the popup to the parent page; it helps you to decide and determine which control receives which value. Even though we will be using only one textbox for simplicity, I thought of creating a sample which can be extended later by you to suit your needs. If the use of ClientID is not clear to you, wait till we get to part 2 of this article, and I will again touch upon the subject.&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;" align="justify"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Verdana;"&gt;&lt;b&gt;Step 6:&lt;/b&gt; Let us now create the javascript functionality which will open the Popup. Right click your project &gt; Add New Item &gt; Jscript file &gt; Rename the file to pop.js. Add the following function to the pop.js file&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color: blue; font-family: 'Courier New';"&gt;function&lt;/span&gt;&lt;span style="font-family: 'Courier New';"&gt; InvokePop(fname)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;        val = document.getElementById(fname).value;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;        &lt;span style="color: green;"&gt;// to handle in IE 7.0           &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;        &lt;span style="color: blue;"&gt;if&lt;/span&gt; (window.showModalDialog) &lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;        {       &lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;            retVal = window.showModalDialog(&lt;span style="color: rgb(163, 21, 21);"&gt;"PopupWin.aspx?Control1="&lt;/span&gt; + fname + &lt;span style="color: rgb(163, 21, 21);"&gt;"&amp;amp;ControlVal="&lt;/span&gt; + val ,&lt;span style="color: rgb(163, 21, 21);"&gt;'Show Popup Window'&lt;/span&gt;,&lt;span style="color: rgb(163, 21, 21);"&gt;"dialogHeight:90px,dialogWidth:250px,resizable:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;yes,center:yes,"&lt;/span&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;            document.getElementById(fname).value = retVal;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;        } &lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;        &lt;span style="color: green;"&gt;// to handle in Firefox&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;        &lt;span style="color: blue;"&gt;else&lt;/span&gt; &lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;        {      &lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;            retVal = window.open(&lt;span style="color: rgb(163, 21, 21);"&gt;"PopupWin.aspx?Control1="&lt;/span&gt;+fname + &lt;span style="color: rgb(163, 21, 21);"&gt;"&amp;amp;ControlVal="&lt;/span&gt; + val,&lt;span style="color: rgb(163, 21, 21);"&gt;'Show Popup Window'&lt;/span&gt;,&lt;span style="color: rgb(163, 21, 21);"&gt;'height=90,width=250,resizable=yes,modal=yes'&lt;/span&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;            retVal.focus();            &lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;        }          &lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;" align="justify"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Verdana;"&gt;This function accepts the textbox control, retrieve�??s the value of the textbox that needs to be reversed and passes the textbox control and its value to PopupWin.aspx through query string. This is the function which will be called on the btnPopup click.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;" align="justify"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Verdana;"&gt;&lt;b&gt;Step 7:&lt;/b&gt; To wire up the .js with your asp.net pages, add a link to the javascript file in both the pages as shown below:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Verdana;"&gt;Default.aspx&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color: blue; font-family: 'Courier New';"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21); font-family: 'Courier New';"&gt;head&lt;/span&gt;&lt;span style="font-family: 'Courier New';"&gt; &lt;span style="color: red;"&gt;runat&lt;/span&gt;&lt;span style="color: blue;"&gt;="server"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;    &lt;span style="color: blue;"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;title&lt;/span&gt;&lt;span style="color: blue;"&gt;&gt;&lt;/span&gt;Parent Page&lt;span style="color: blue;"&gt;&lt;/&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;title&lt;/span&gt;&lt;span style="color: blue;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;    &lt;span style="color: blue;"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;script&lt;/span&gt; &lt;span style="color: red;"&gt;type&lt;/span&gt;&lt;span style="color: blue;"&gt;="text/javascript"&lt;/span&gt; &lt;span style="color: red;"&gt;src&lt;/span&gt;&lt;span style="color: blue;"&gt;="pop.js"&gt;&lt;/&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;script&lt;/span&gt;&lt;span style="color: blue;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color: blue; font-family: 'Courier New';"&gt;&lt;/&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21); font-family: 'Courier New';"&gt;head&lt;/span&gt;&lt;span style="color: blue; font-family: 'Courier New';"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Verdana;"&gt;PopupWin.aspx&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color: blue; font-family: 'Courier New';"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21); font-family: 'Courier New';"&gt;head&lt;/span&gt;&lt;span style="font-family: 'Courier New';"&gt; &lt;span style="color: red;"&gt;runat&lt;/span&gt;&lt;span style="color: blue;"&gt;="server"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;    &lt;span style="color: blue;"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;title&lt;/span&gt;&lt;span style="color: blue;"&gt;&gt;&lt;/span&gt;Popup Page&lt;span style="color: blue;"&gt;&lt;/&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;title&lt;/span&gt;&lt;span style="color: blue;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;    &lt;span style="color: blue;"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;script&lt;/span&gt; &lt;span style="color: red;"&gt;type&lt;/span&gt;&lt;span style="color: blue;"&gt;="text/javascript"&lt;/span&gt; &lt;span style="color: red;"&gt;src&lt;/span&gt;&lt;span style="color: blue;"&gt;="pop.js"&gt;&lt;/&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;script&lt;/span&gt;&lt;span style="color: blue;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color: blue; font-family: 'Courier New';"&gt;&lt;/&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21); font-family: 'Courier New';"&gt;head&lt;/span&gt;&lt;span style="color: blue; font-family: 'Courier New';"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;" align="justify"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Verdana;"&gt;&lt;b&gt;Step 8:&lt;/b&gt; In the code behind file of PopupWin.aspx, add the following code at the Page_Load() to retrieve the value from the querystring and display the value in the TextBox �??txtReverse�??, placed in the popup window.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Verdana;"&gt;C#&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color: blue; font-family: 'Courier New';"&gt;protected&lt;/span&gt;&lt;span style="font-family: 'Courier New';"&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; Page_Load(&lt;span style="color: blue;"&gt;object&lt;/span&gt; sender, &lt;span style="color: rgb(43, 145, 175);"&gt;EventArgs&lt;/span&gt; e)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;    {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;        txtReverse.Text = Request.QueryString[&lt;span style="color: rgb(163, 21, 21);"&gt;"ControlVal"&lt;/span&gt;].ToString();&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;    }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Verdana;"&gt;VB.NET&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color: blue; font-family: 'Courier New';"&gt;Protected&lt;/span&gt;&lt;span style="font-family: 'Courier New';"&gt; &lt;span style="color: blue;"&gt;Sub&lt;/span&gt; Page_Load(&lt;span style="color: blue;"&gt;ByVal&lt;/span&gt; sender &lt;span style="color: blue;"&gt;As&lt;/span&gt; &lt;span style="color: blue;"&gt;Object&lt;/span&gt;, &lt;span style="color: blue;"&gt;ByVal&lt;/span&gt; e &lt;span style="color: blue;"&gt;As&lt;/span&gt; System.EventArgs) &lt;span style="color: blue;"&gt;Handles&lt;/span&gt; &lt;span style="color: blue;"&gt;Me&lt;/span&gt;.Load&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;        txtReverse.Text = Request.QueryString(&lt;span style="color: rgb(163, 21, 21);"&gt;"ControlVal"&lt;/span&gt;).ToString()&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family: 'Courier New';"&gt;    &lt;span style="color: blue;"&gt;End&lt;/span&gt; &lt;span style="color: blue;"&gt;Sub&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;" align="justify"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Verdana;"&gt;If you are eager to test the value going from Parent page to the popup window, you can do so now. Make Default.aspx as �??Set as Start page�?? and run the sample. Enter your name in txtFName TextBox and click on Show Popup button. A popup window opens with the value entered in the Parent page. &lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;" align="justify"&gt;&lt;b&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Verdana;"&gt;Part 2 - Passing value from Popup window to the Parent page&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;" align="justify"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Verdana;"&gt;In this second part, we will reverse the string and pass the reversed string back to the parent page. To do so, follow these steps:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;" align="justify"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Verdana;"&gt;&lt;b&gt;Step 1:&lt;/b&gt; Add additional functions to the pop.js file which will reverse the string and return the string back to the parent page.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color: green; font-family: 'Courier New';"&gt;// pop.js&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color: blue; font-family: 'Courier New';"&gt;function&lt;/span&gt;&lt;span style="font-family: 'Courier New';"&gt; ReverseString()&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;         &lt;span style="color: blue;"&gt;var&lt;/span&gt; originalString = document.getElementById(&lt;span style="color: rgb(163, 21, 21);"&gt;'txtReverse'&lt;/span&gt;).value;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;         &lt;span style="color: blue;"&gt;var&lt;/span&gt; reversedString = Reverse(originalString);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;         RetrieveControl();&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;         &lt;span style="color: green;"&gt;// to handle in IE 7.0&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;         &lt;span style="color: blue;"&gt;if&lt;/span&gt; (window.showModalDialog)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;         {              &lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;              window.returnValue = reversedString;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;              window.close();&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;         }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;         &lt;span style="color: green;"&gt;// to handle in Firefox&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;         &lt;span style="color: blue;"&gt;else&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;         {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;              &lt;span style="color: blue;"&gt;if&lt;/span&gt; ((window.opener != &lt;span style="color: blue;"&gt;null&lt;/span&gt;) &amp;amp;&amp;amp; (!window.opener.closed)) &lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;              {               &lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;                &lt;span style="color: green;"&gt;// Access the control.        &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;                window.opener.document.getElementById(ctr[1]).value = reversedString; &lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;              }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;              window.close();&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;         }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt; &lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color: blue; font-family: 'Courier New';"&gt;function&lt;/span&gt;&lt;span style="font-family: 'Courier New';"&gt; Reverse(str)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;   &lt;span style="color: blue;"&gt;var&lt;/span&gt; revStr = &lt;span style="color: rgb(163, 21, 21);"&gt;""&lt;/span&gt;; &lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;   &lt;span style="color: blue;"&gt;for&lt;/span&gt; (i=str.length - 1 ; i &gt; - 1 ; i--)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;   { &lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;      revStr += str.substr(i,1); &lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;   } &lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;   &lt;span style="color: blue;"&gt;return&lt;/span&gt; revStr;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt; &lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color: blue; font-family: 'Courier New';"&gt;function&lt;/span&gt;&lt;span style="font-family: 'Courier New';"&gt; RetrieveControl()&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;        &lt;span style="color: green;"&gt;//Retrieve the query string &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;        queryStr = window.location.search.substring(1); &lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;        &lt;span style="color: green;"&gt;// Seperate the control and its value&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;        ctrlArray = queryStr.split(&lt;span style="color: rgb(163, 21, 21);"&gt;"&amp;amp;"&lt;/span&gt;); &lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;        ctrl1 = ctrlArray[0]; &lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;        &lt;span style="color: green;"&gt;//Retrieve the control passed via querystring &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family: 'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;        ctr = ctrl1.split(&lt;span style="color: rgb(163, 21, 21);"&gt;"="&lt;/span&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family: 'Courier New';"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;" align="justify"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Verdana;"&gt;As you saw in part 1, the value was passed from the parent window to the popup window and was kept in the txtReverse TextBox. The function ReverseString() retrieves the value from this textbox and passes the string to the Reverse() function which reverses the string. The reversed string is then kept in the �??&lt;/span&gt;&lt;span style="font-family: 'Courier New';"&gt;reversedString�??&lt;/span&gt;&lt;span style="font-family:Verdana;"&gt; variable. The �??RetrieveControl�?? splits the query string and identifies the control in the parent page to which the reversed string value is to be sent.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;" align="justify"&gt;&lt;i&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Verdana;"&gt;Note: If you observe, in the IE implementation, I am not really making use of the RetrieveControl(), however in Firefox I am. If you remember, in the beginning of part1 , I had mentioned the use of ClientID, using which both controls and their values can be passed to determine which control recieves which value. This is especially needed when there are multiple controls. Well the RetrieveControl seperates the different controls and you can use the variables in this method to return values to the respective contro.l&lt;/span&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;" align="justify"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Verdana;"&gt;The value is then returned to the parent window and the popup window is closed.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;" align="justify"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Verdana;"&gt;&lt;b&gt;Step 2:&lt;/b&gt; Now in order to use these newly added javacript functions, just call the ReverseString() function on the btnReverse click. To do so, add the onclick attribute to the btnReverse.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color: blue; font-family: 'Courier New';"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21); font-family: 'Courier New';"&gt;input&lt;/span&gt;&lt;span style="font-family: 'Courier New';"&gt; &lt;span style="color: red;"&gt;class&lt;/span&gt;&lt;span style="color: blue;"&gt;="button"&lt;/span&gt; &lt;span style="color: red;"&gt;type&lt;/span&gt;&lt;span style="color: blue;"&gt;="button"&lt;/span&gt; &lt;span style="color: red;"&gt;id&lt;/span&gt;&lt;span style="color: blue;"&gt;="btnReverse"&lt;/span&gt; &lt;span style="color: red;"&gt;value&lt;/span&gt;&lt;span style="color: blue;"&gt;="Reverse value back"&lt;/span&gt; &lt;span style="color: red;"&gt;onclick&lt;/span&gt;&lt;span style="color: blue;"&gt;="ReverseString();"/&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;" align="justify"&gt;&lt;span style="font-family:Verdana;font-size:85%;"&gt;That�??s it. Now test the code. Pass your name from the Parent window to the Popup window and then reverse the string and pass it back to the Parent window.&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;" align="justify"&gt;&lt;span style="font-family:Verdana;font-size:85%;"&gt;I would like to mention that there are multiple ways of doing the task demoed in this article. I have seen some cool examples by experts. One of them I would like to mention is that of &lt;/span&gt;&lt;span style="font-family:Verdana;font-size:85%;"&gt;NC01&lt;/span&gt;&lt;span style="font-family:Verdana;font-size:85%;"&gt; where he makes use of properties and ViewState, to pass values to the Popup window. I would encourage you to use this article as a base and try out your own implementations that would work on multiple browsers. &lt;/span&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/ynBt/~4/fgxpEy9lTMc" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://purl.org/atom/app#">2009-02-12T18:54:48.281+05:30</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://dotnetfaqs-edu.blogspot.com/2009/02/how-to-open-popup-windows-in-iefirefox.html</feedburner:origLink></item><item><title>GridView Tips and Tricks using ASP.NET 2.0 </title><link>http://feedproxy.google.com/~r/blogspot/ynBt/~3/J2WIDJGxZjI/handle-error-simple-way-in-aspnet.html</link><category>ASP.NET Tutorials</category><author>noreply@blogger.com (Tiru)</author><pubDate>Thu, 12 Feb 2009 05:23:10 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-6426652519813936980.post-5128242060688636693</guid><description>&lt;div style="margin: 0in 0in 10pt;" align="justify"&gt; &lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;" align="justify"&gt;&lt;span style=";font-family:Verdana;font-size:85%;"  &gt;The GridView control is quiet a handy control and is the most commonly used control when building an ASP.NET site. The more you work with it, the more you realize how powerful it can be while presenting data. In this article, we will explore some of the most frequently asked questions about the GridView control. The article discusses ten tips and tricks that you can use while using the GridView control. &lt;/span&gt;&lt;/div&gt;&lt;div style="margin: 0in 0in 10pt;" align="justify"&gt; &lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;" align="justify"&gt;&lt;b&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Verdana;"&gt;Tip 1: Add, Update, Delete Records in a Gridview using SqlDataSource&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;" align="justify"&gt;&lt;span style=";font-family:Verdana;font-size:85%;"  &gt;By default, the GridView control doesn�??t have support for inserting new records. However you can use the built-in edit or delete functionality of the GridView control. Let us explore how to insert new records and Update and Delete existing records in Gridview. Just copy and paste the code in your project. We will be using the �??Categories�?? table in the �??Northwind�?? database.&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;"&gt;&lt;u&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Verdana;"&gt;GridView.aspx&lt;/span&gt;&lt;/span&gt;&lt;/u&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="background: yellow none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;font-family:'Courier New';" &gt;&lt;%&lt;/span&gt;&lt;span style=";font-family:'Courier New';color:blue;"  &gt;@&lt;/span&gt;&lt;span style="font-family:'Courier New';"&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;Page&lt;/span&gt; &lt;span style="color:red;"&gt;Language&lt;/span&gt;&lt;span style="color:blue;"&gt;="C#"&lt;/span&gt; &lt;span style="color:red;"&gt;AutoEventWireup&lt;/span&gt;&lt;span style="color:blue;"&gt;="true"&lt;/span&gt; &lt;span style="color:red;"&gt;CodeFile&lt;/span&gt;&lt;span style="color:blue;"&gt;="GridView.aspx.cs"&lt;/span&gt; &lt;span style="color:red;"&gt;Inherits&lt;/span&gt;&lt;span style="color:blue;"&gt;="GridView"&lt;/span&gt; &lt;span style="background: yellow none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;%&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt; &lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style=";font-family:'Courier New';color:blue;"  &gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(163, 21, 21);font-family:'Courier New';" &gt;DOCTYPE&lt;/span&gt;&lt;span style="font-family:'Courier New';"&gt; &lt;span style="color:red;"&gt;html&lt;/span&gt; &lt;span style="color:red;"&gt;PUBLIC&lt;/span&gt; &lt;span style="color:blue;"&gt;"-//W3C//DTD XHTML 1.0 Transitional//EN"&lt;/span&gt; &lt;span style="color:blue;"&gt;"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt; &lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style=";font-family:'Courier New';color:blue;"  &gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);font-family:'Courier New';" &gt;html&lt;/span&gt;&lt;span style="font-family:'Courier New';"&gt; &lt;span style="color:red;"&gt;xmlns&lt;/span&gt;&lt;span style="color:blue;"&gt;="http://www.w3.org/1999/xhtml"&lt;/span&gt; &lt;span style="color:blue;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style=";font-family:'Courier New';color:blue;"  &gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);font-family:'Courier New';" &gt;head&lt;/span&gt;&lt;span style="font-family:'Courier New';"&gt; &lt;span style="color:red;"&gt;runat&lt;/span&gt;&lt;span style="color:blue;"&gt;="server"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;    &lt;span style="color:blue;"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;title&lt;/span&gt;&lt;span style="color:blue;"&gt;&gt;&lt;/span&gt;Grid View Add Update Delete&lt;span style="color:blue;"&gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;title&lt;/span&gt;&lt;span style="color:blue;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style=";font-family:'Courier New';color:blue;"  &gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(163, 21, 21);font-family:'Courier New';" &gt;head&lt;/span&gt;&lt;span style=";font-family:'Courier New';color:blue;"  &gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style=";font-family:'Courier New';color:blue;"  &gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);font-family:'Courier New';" &gt;body&lt;/span&gt;&lt;span style=";font-family:'Courier New';color:blue;"  &gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;    &lt;span style="color:blue;"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;form&lt;/span&gt; &lt;span style="color:red;"&gt;id&lt;/span&gt;&lt;span style="color:blue;"&gt;="form1"&lt;/span&gt; &lt;span style="color:red;"&gt;runat&lt;/span&gt;&lt;span style="color:blue;"&gt;="server"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;    &lt;span style="color:blue;"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;div&lt;/span&gt;&lt;span style="color:blue;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;        &lt;span style="color:red;"&gt;    &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;        &lt;span style="color:blue;"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;asp&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;GridView&lt;/span&gt; &lt;span style="color:red;"&gt;ID&lt;/span&gt;&lt;span style="color:blue;"&gt;="GridView1"&lt;/span&gt; &lt;span style="color:red;"&gt;runat&lt;/span&gt;&lt;span style="color:blue;"&gt;="server"&lt;/span&gt; &lt;span style="color:red;"&gt;AutoGenerateColumns&lt;/span&gt;&lt;span style="color:blue;"&gt;="False"&lt;/span&gt; &lt;span style="color:red;"&gt;DataKeyNames&lt;/span&gt;&lt;span style="color:blue;"&gt;="CategoryID"&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;            &lt;span style="color:red;"&gt;DataSourceID&lt;/span&gt;&lt;span style="color:blue;"&gt;="SqlDataSource1"&lt;/span&gt; &lt;span style="color:red;"&gt;ShowFooter&lt;/span&gt;&lt;span style="color:blue;"&gt;="true"&lt;/span&gt; &lt;span style="color:red;"&gt;AllowPaging&lt;/span&gt;&lt;span style="color:blue;"&gt;="True"&lt;/span&gt; &lt;span style="color:red;"&gt;AllowSorting&lt;/span&gt;&lt;span style="color:blue;"&gt;="True"&lt;/span&gt; &lt;span style="color:red;"&gt;OnRowCommand&lt;/span&gt;&lt;span style="color:blue;"&gt;="GridView1_RowCommand"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;            &lt;span style="color:blue;"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;Columns&lt;/span&gt;&lt;span style="color:blue;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;            &lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;                &lt;span style="color:blue;"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;asp&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;CommandField&lt;/span&gt; &lt;span style="color:red;"&gt;ShowDeleteButton&lt;/span&gt;&lt;span style="color:blue;"&gt;="True"&lt;/span&gt; &lt;span style="color:red;"&gt;ShowEditButton&lt;/span&gt;&lt;span style="color:blue;"&gt;="True"/&gt;&lt;/span&gt;                &lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;                &lt;span style="color:blue;"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;asp&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;TemplateField&lt;/span&gt; &lt;span style="color:red;"&gt;HeaderText&lt;/span&gt;&lt;span style="color:blue;"&gt;="CategoryID"&lt;/span&gt; &lt;span style="color:red;"&gt;InsertVisible&lt;/span&gt;&lt;span style="color:blue;"&gt;="False"&lt;/span&gt; &lt;span style="color:red;"&gt;SortExpression&lt;/span&gt;&lt;span style="color:blue;"&gt;="CategoryID"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;                    &lt;span style="color:blue;"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;EditItemTemplate&lt;/span&gt;&lt;span style="color:blue;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;                        &lt;span style="color:blue;"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;asp&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;Label&lt;/span&gt; &lt;span style="color:red;"&gt;ID&lt;/span&gt;&lt;span style="color:blue;"&gt;="Label1"&lt;/span&gt; &lt;span style="color:red;"&gt;runat&lt;/span&gt;&lt;span style="color:blue;"&gt;="server"&lt;/span&gt; &lt;span style="color:red;"&gt;Text&lt;/span&gt;&lt;span style="color:blue;"&gt;='&lt;/span&gt;&lt;span style="background: yellow none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;%&lt;/span&gt;# Eval("CategoryID") &lt;span style="background: yellow none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;%&gt;&lt;/span&gt;&lt;span style="color:blue;"&gt;'&gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;asp&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;Label&lt;/span&gt;&lt;span style="color:blue;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;                    &lt;span style="color:blue;"&gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;EditItemTemplate&lt;/span&gt;&lt;span style="color:blue;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;                    &lt;span style="color:blue;"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;ItemTemplate&lt;/span&gt;&lt;span style="color:blue;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;                        &lt;span style="color:blue;"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;asp&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;Label&lt;/span&gt; &lt;span style="color:red;"&gt;ID&lt;/span&gt;&lt;span style="color:blue;"&gt;="Label1"&lt;/span&gt; &lt;span style="color:red;"&gt;runat&lt;/span&gt;&lt;span style="color:blue;"&gt;="server"&lt;/span&gt; &lt;span style="color:red;"&gt;Text&lt;/span&gt;&lt;span style="color:blue;"&gt;='&lt;/span&gt;&lt;span style="background: yellow none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;%&lt;/span&gt;# Bind("CategoryID") &lt;span style="background: yellow none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;%&gt;&lt;/span&gt;&lt;span style="color:blue;"&gt;'&gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;asp&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;Label&lt;/span&gt;&lt;span style="color:blue;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;                    &lt;span style="color:blue;"&gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;ItemTemplate&lt;/span&gt;&lt;span style="color:blue;"&gt;&gt;&lt;/span&gt;                   &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;                &lt;span style="color:blue;"&gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;asp&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;TemplateField&lt;/span&gt;&lt;span style="color:blue;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;                &lt;span style="color:blue;"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;asp&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;TemplateField&lt;/span&gt; &lt;span style="color:red;"&gt;HeaderText&lt;/span&gt;&lt;span style="color:blue;"&gt;="CategoryName"&lt;/span&gt; &lt;span style="color:red;"&gt;SortExpression&lt;/span&gt;&lt;span style="color:blue;"&gt;="CategoryName"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;                    &lt;span style="color:blue;"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;EditItemTemplate&lt;/span&gt;&lt;span style="color:blue;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;                        &lt;span style="color:blue;"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;asp&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;TextBox&lt;/span&gt; &lt;span style="color:red;"&gt;ID&lt;/span&gt;&lt;span style="color:blue;"&gt;="TextBox1"&lt;/span&gt; &lt;span style="color:red;"&gt;runat&lt;/span&gt;&lt;span style="color:blue;"&gt;="server"&lt;/span&gt; &lt;span style="color:red;"&gt;Text&lt;/span&gt;&lt;span style="color:blue;"&gt;='&lt;/span&gt;&lt;span style="background: yellow none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;%&lt;/span&gt;# Bind("CategoryName") &lt;span style="background: yellow none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;%&gt;&lt;/span&gt;&lt;span style="color:blue;"&gt;'&gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;asp&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;TextBox&lt;/span&gt;&lt;span style="color:blue;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;                    &lt;span style="color:blue;"&gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;EditItemTemplate&lt;/span&gt;&lt;span style="color:blue;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;                    &lt;span style="color:blue;"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;ItemTemplate&lt;/span&gt;&lt;span style="color:blue;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;                        &lt;span style="color:blue;"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;asp&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;Label&lt;/span&gt; &lt;span style="color:red;"&gt;ID&lt;/span&gt;&lt;span style="color:blue;"&gt;="Label2"&lt;/span&gt; &lt;span style="color:red;"&gt;runat&lt;/span&gt;&lt;span style="color:blue;"&gt;="server"&lt;/span&gt; &lt;span style="color:red;"&gt;Text&lt;/span&gt;&lt;span style="color:blue;"&gt;='&lt;/span&gt;&lt;span style="background: yellow none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;%&lt;/span&gt;# Bind("CategoryName") &lt;span style="background: yellow none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;%&gt;&lt;/span&gt;&lt;span style="color:blue;"&gt;'&gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;asp&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;Label&lt;/span&gt;&lt;span style="color:blue;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;                    &lt;span style="color:blue;"&gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;ItemTemplate&lt;/span&gt;&lt;span style="color:blue;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;                    &lt;span style="color:blue;"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;FooterTemplate&lt;/span&gt;&lt;span style="color:blue;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;                        &lt;span style="color:blue;"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;asp&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;TextBox&lt;/span&gt; &lt;span style="color:red;"&gt;ID&lt;/span&gt;&lt;span style="color:blue;"&gt;="CategoryNameTextBox"&lt;/span&gt; &lt;span style="color:red;"&gt;Runat&lt;/span&gt;&lt;span style="color:blue;"&gt;="server"&gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;asp&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;TextBox&lt;/span&gt;&lt;span style="color:blue;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;                        &lt;span style="color:blue;"&gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;FooterTemplate&lt;/span&gt;&lt;span style="color:blue;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;                &lt;span style="color:blue;"&gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;asp&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;TemplateField&lt;/span&gt;&lt;span style="color:blue;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;                &lt;span style="color:blue;"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;asp&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;TemplateField&lt;/span&gt; &lt;span style="color:red;"&gt;HeaderText&lt;/span&gt;&lt;span style="color:blue;"&gt;="Description"&lt;/span&gt; &lt;span style="color:red;"&gt;SortExpression&lt;/span&gt;&lt;span style="color:blue;"&gt;="Description"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;                    &lt;span style="color:blue;"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;EditItemTemplate&lt;/span&gt;&lt;span style="color:blue;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;                        &lt;span style="color:blue;"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;asp&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;TextBox&lt;/span&gt; &lt;span style="color:red;"&gt;ID&lt;/span&gt;&lt;span style="color:blue;"&gt;="TextBox2"&lt;/span&gt; &lt;span style="color:red;"&gt;runat&lt;/span&gt;&lt;span style="color:blue;"&gt;="server"&lt;/span&gt; &lt;span style="color:red;"&gt;Text&lt;/span&gt;&lt;span style="color:blue;"&gt;='&lt;/span&gt;&lt;span style="background: yellow none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;%&lt;/span&gt;# Bind("Description") &lt;span style="background: yellow none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;%&gt;&lt;/span&gt;&lt;span style="color:blue;"&gt;'&gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;asp&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;TextBox&lt;/span&gt;&lt;span style="color:blue;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;                    &lt;span style="color:blue;"&gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;EditItemTemplate&lt;/span&gt;&lt;span style="color:blue;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;                    &lt;span style="color:blue;"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;ItemTemplate&lt;/span&gt;&lt;span style="color:blue;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;                        &lt;span style="color:blue;"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;asp&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;Label&lt;/span&gt; &lt;span style="color:red;"&gt;ID&lt;/span&gt;&lt;span style="color:blue;"&gt;="Label3"&lt;/span&gt; &lt;span style="color:red;"&gt;runat&lt;/span&gt;&lt;span style="color:blue;"&gt;="server"&lt;/span&gt; &lt;span style="color:red;"&gt;Text&lt;/span&gt;&lt;span style="color:blue;"&gt;='&lt;/span&gt;&lt;span style="background: yellow none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;%&lt;/span&gt;# Bind("Description") &lt;span style="background: yellow none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;%&gt;&lt;/span&gt;&lt;span style="color:blue;"&gt;'&gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;asp&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;Label&lt;/span&gt;&lt;span style="color:blue;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;                    &lt;span style="color:blue;"&gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;ItemTemplate&lt;/span&gt;&lt;span style="color:blue;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;                    &lt;span style="color:blue;"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;FooterTemplate&lt;/span&gt;&lt;span style="color:blue;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;                        &lt;span style="color:blue;"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;asp&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;TextBox&lt;/span&gt; &lt;span style="color:red;"&gt;ID&lt;/span&gt;&lt;span style="color:blue;"&gt;="DescriptionTextBox"&lt;/span&gt; &lt;span style="color:red;"&gt;Runat&lt;/span&gt;&lt;span style="color:blue;"&gt;="server"&gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;asp&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;TextBox&lt;/span&gt;&lt;span style="color:blue;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;                    &lt;span style="color:blue;"&gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;FooterTemplate&lt;/span&gt;&lt;span style="color:blue;"&gt;&gt;&lt;/span&gt;                  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;                &lt;span style="color:blue;"&gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;asp&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;TemplateField&lt;/span&gt;&lt;span style="color:blue;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;                &lt;span style="color:blue;"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;asp&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;templatefield&lt;/span&gt;&lt;span style="color:blue;"&gt;&gt;&lt;/span&gt;                   &lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;                        &lt;span style="color:blue;"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;footertemplate&lt;/span&gt;&lt;span style="color:blue;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;                              &lt;span style="color:blue;"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;asp&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;linkbutton&lt;/span&gt; &lt;span style="color:red;"&gt;id&lt;/span&gt;&lt;span style="color:blue;"&gt;="btnNew"&lt;/span&gt; &lt;span style="color:red;"&gt;runat&lt;/span&gt;&lt;span style="color:blue;"&gt;="server"&lt;/span&gt; &lt;span style="color:red;"&gt;commandname&lt;/span&gt;&lt;span style="color:blue;"&gt;="New"&lt;/span&gt; &lt;span style="color:red;"&gt;text&lt;/span&gt;&lt;span style="color:blue;"&gt;="New"&lt;/span&gt; &lt;span style="color:blue;"&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;                        &lt;span style="color:blue;"&gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;footertemplate&lt;/span&gt;&lt;span style="color:blue;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;                  &lt;span style="color:blue;"&gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;asp&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;templatefield&lt;/span&gt;&lt;span style="color:blue;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;                &lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;            &lt;span style="color:blue;"&gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;Columns&lt;/span&gt;&lt;span style="color:blue;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;        &lt;span style="color:blue;"&gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;asp&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;GridView&lt;/span&gt;&lt;span style="color:blue;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;        &lt;span style="color:blue;"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;asp&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;SqlDataSource&lt;/span&gt; &lt;span style="color:red;"&gt;ID&lt;/span&gt;&lt;span style="color:blue;"&gt;="SqlDataSource1"&lt;/span&gt; &lt;span style="color:red;"&gt;runat&lt;/span&gt;&lt;span style="color:blue;"&gt;="server"&lt;/span&gt; &lt;span style="color:red;"&gt;ConnectionString&lt;/span&gt;&lt;span style="color:blue;"&gt;="Data Source=SUPROTIM;Initial Catalog=Northwind;Integrated Security=True"&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;            &lt;span style="color:red;"&gt;DeleteCommand&lt;/span&gt;&lt;span style="color:blue;"&gt;="DELETE FROM [Categories] WHERE [CategoryID] = @CategoryID"&lt;/span&gt; &lt;span style="color:red;"&gt;InsertCommand&lt;/span&gt;&lt;span style="color:blue;"&gt;="INSERT INTO [Categories] ([CategoryName], [Description]) VALUES (@CategoryName, @Description)"&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;            &lt;span style="color:red;"&gt;ProviderName&lt;/span&gt;&lt;span style="color:blue;"&gt;="System.Data.SqlClient"&lt;/span&gt; &lt;span style="color:red;"&gt;SelectCommand&lt;/span&gt;&lt;span style="color:blue;"&gt;="SELECT [CategoryID], [CategoryName], [Description] FROM [Categories]"&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;            &lt;span style="color:red;"&gt;UpdateCommand&lt;/span&gt;&lt;span style="color:blue;"&gt;="UPDATE [Categories] SET [CategoryName] = @CategoryName, [Description] = @Description WHERE [CategoryID] = @CategoryID"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;            &lt;span style="color:blue;"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;DeleteParameters&lt;/span&gt;&lt;span style="color:blue;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;                &lt;span style="color:blue;"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;asp&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;Parameter&lt;/span&gt; &lt;span style="color:red;"&gt;Name&lt;/span&gt;&lt;span style="color:blue;"&gt;="CategoryID"&lt;/span&gt; &lt;span style="color:red;"&gt;Type&lt;/span&gt;&lt;span style="color:blue;"&gt;="Int32"&lt;/span&gt; &lt;span style="color:blue;"&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;            &lt;span style="color:blue;"&gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;DeleteParameters&lt;/span&gt;&lt;span style="color:blue;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;            &lt;span style="color:blue;"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;UpdateParameters&lt;/span&gt;&lt;span style="color:blue;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;                &lt;span style="color:blue;"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;asp&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;Parameter&lt;/span&gt; &lt;span style="color:red;"&gt;Name&lt;/span&gt;&lt;span style="color:blue;"&gt;="CategoryName"&lt;/span&gt; &lt;span style="color:red;"&gt;Type&lt;/span&gt;&lt;span style="color:blue;"&gt;="String"&lt;/span&gt; &lt;span style="color:blue;"&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;                &lt;span style="color:blue;"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;asp&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;Parameter&lt;/span&gt; &lt;span style="color:red;"&gt;Name&lt;/span&gt;&lt;span style="color:blue;"&gt;="Description"&lt;/span&gt; &lt;span style="color:red;"&gt;Type&lt;/span&gt;&lt;span style="color:blue;"&gt;="String"&lt;/span&gt; &lt;span style="color:blue;"&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;                &lt;span style="color:blue;"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;asp&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;Parameter&lt;/span&gt; &lt;span style="color:red;"&gt;Name&lt;/span&gt;&lt;span style="color:blue;"&gt;="CategoryID"&lt;/span&gt; &lt;span style="color:red;"&gt;Type&lt;/span&gt;&lt;span style="color:blue;"&gt;="Int32"&lt;/span&gt; &lt;span style="color:blue;"&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;            &lt;span style="color:blue;"&gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;UpdateParameters&lt;/span&gt;&lt;span style="color:blue;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;            &lt;span style="color:blue;"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;InsertParameters&lt;/span&gt;&lt;span style="color:blue;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;                &lt;span style="color:blue;"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;asp&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;Parameter&lt;/span&gt; &lt;span style="color:red;"&gt;Name&lt;/span&gt;&lt;span style="color:blue;"&gt;="CategoryName"&lt;/span&gt; &lt;span style="color:red;"&gt;Type&lt;/span&gt;&lt;span style="color:blue;"&gt;="String"&lt;/span&gt; &lt;span style="color:blue;"&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;                &lt;span style="color:blue;"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;asp&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;Parameter&lt;/span&gt; &lt;span style="color:red;"&gt;Name&lt;/span&gt;&lt;span style="color:blue;"&gt;="Description"&lt;/span&gt; &lt;span style="color:red;"&gt;Type&lt;/span&gt;&lt;span style="color:blue;"&gt;="String"&lt;/span&gt; &lt;span style="color:blue;"&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;            &lt;span style="color:blue;"&gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;InsertParameters&lt;/span&gt;&lt;span style="color:blue;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;        &lt;span style="color:blue;"&gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;asp&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;SqlDataSource&lt;/span&gt;&lt;span style="color:blue;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;    &lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;    &lt;span style="color:blue;"&gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;div&lt;/span&gt;&lt;span style="color:blue;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;    &lt;span style="color:blue;"&gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;form&lt;/span&gt;&lt;span style="color:blue;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style=";font-family:'Courier New';color:blue;"  &gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(163, 21, 21);font-family:'Courier New';" &gt;body&lt;/span&gt;&lt;span style=";font-family:'Courier New';color:blue;"  &gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style=";font-family:'Courier New';color:blue;"  &gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(163, 21, 21);font-family:'Courier New';" &gt;html&lt;/span&gt;&lt;span style=";font-family:'Courier New';color:blue;"  &gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;"&gt; &lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;"&gt;&lt;u&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Verdana;"&gt;GridView.aspx.cs&lt;/span&gt;&lt;/span&gt;&lt;/u&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style=";font-family:'Courier New';color:blue;"  &gt;protected&lt;/span&gt;&lt;span style="font-family:'Courier New';"&gt; &lt;span style="color:blue;"&gt;void&lt;/span&gt; GridView1_RowCommand(&lt;span style="color:blue;"&gt;object&lt;/span&gt; sender, &lt;span style="color: rgb(43, 145, 175);"&gt;GridViewCommandEventArgs&lt;/span&gt; e)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;    {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;        &lt;span style="color: rgb(43, 145, 175);"&gt;SqlConnection&lt;/span&gt; conn = &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;SqlConnection&lt;/span&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;                    &lt;span style="color: rgb(43, 145, 175);"&gt;ConfigurationManager&lt;/span&gt;.ConnectionStrings[&lt;span style="color: rgb(163, 21, 21);"&gt;"NorthwindConnectionString"&lt;/span&gt;].ConnectionString);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;        &lt;span style="color:blue;"&gt;try&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;        {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;            &lt;span style="color:blue;"&gt;if&lt;/span&gt; (e.CommandName.Equals(&lt;span style="color: rgb(163, 21, 21);"&gt;"New"&lt;/span&gt;))&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;            {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;                &lt;span style="color: rgb(43, 145, 175);"&gt;LinkButton&lt;/span&gt; btnNew = e.CommandSource &lt;span style="color:blue;"&gt;as&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;LinkButton&lt;/span&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;                &lt;span style="color: rgb(43, 145, 175);"&gt;GridViewRow&lt;/span&gt; row = btnNew.NamingContainer &lt;span style="color:blue;"&gt;as&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;GridViewRow&lt;/span&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;                &lt;span style="color:blue;"&gt;if&lt;/span&gt; (row == &lt;span style="color:blue;"&gt;null&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;                {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;                    &lt;span style="color:blue;"&gt;return&lt;/span&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;                }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;                &lt;span style="color: rgb(43, 145, 175);"&gt;TextBox&lt;/span&gt; txtCatName = row.FindControl(&lt;span style="color: rgb(163, 21, 21);"&gt;"CategoryNameTextBox"&lt;/span&gt;) &lt;span style="color:blue;"&gt;as&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;TextBox&lt;/span&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;                &lt;span style="color: rgb(43, 145, 175);"&gt;TextBox&lt;/span&gt; txtDescription = row.FindControl(&lt;span style="color: rgb(163, 21, 21);"&gt;"DescriptionTextBox"&lt;/span&gt;) &lt;span style="color:blue;"&gt;as&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;TextBox&lt;/span&gt;;                &lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;                &lt;span style="color: rgb(43, 145, 175);"&gt;SqlCommand&lt;/span&gt; cmd = &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;SqlCommand&lt;/span&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;                    &lt;span style="color: rgb(163, 21, 21);"&gt;"INSERT INTO [Categories] ([CategoryName], [Description]) VALUES (@CategoryName, @Description)"&lt;/span&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;                    conn);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;                cmd.Parameters.AddWithValue(&lt;span style="color: rgb(163, 21, 21);"&gt;"CategoryName"&lt;/span&gt;, txtCatName.Text);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;                cmd.Parameters.AddWithValue(&lt;span style="color: rgb(163, 21, 21);"&gt;"Description"&lt;/span&gt;,txtDescription.Text);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;                conn.Open();&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;                &lt;span style="color:blue;"&gt;if&lt;/span&gt; (cmd.ExecuteNonQuery() == 1)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;                {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;                    GridView1.DataBind();&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;                }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;            }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;        }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;        &lt;span style="color:blue;"&gt;catch&lt;/span&gt; (&lt;span style="color: rgb(43, 145, 175);"&gt;Exception&lt;/span&gt; ex)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;        {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt; &lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;        }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;        &lt;span style="color:blue;"&gt;finally&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;        {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;            conn.Close();&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;        }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;    }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;"&gt;&lt;u&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Verdana;"&gt;Web.config&lt;/span&gt;&lt;/span&gt;&lt;/u&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style=";font-family:'Courier New';color:blue;"  &gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);font-family:'Courier New';" &gt;connectionStrings&lt;/span&gt;&lt;span style=";font-family:'Courier New';color:blue;"  &gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style=";font-family:'Courier New';color:blue;"  &gt;            &lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);font-family:'Courier New';" &gt;add&lt;/span&gt;&lt;span style=";font-family:'Courier New';color:red;"  &gt;name&lt;/span&gt;&lt;span style=";font-family:'Courier New';color:blue;"  &gt;=&lt;/span&gt;&lt;span style="font-family:'Courier New';"&gt;"&lt;span style="color:blue;"&gt;NorthwindConnectionString&lt;/span&gt;"&lt;span style="color:red;"&gt;connectionString&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;"&lt;span style="color:blue;"&gt;Data Source =.;Integrated Security = SSPI; Initial Catalog=Northwind;&lt;/span&gt;"&lt;span style="color:blue;"&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style=";font-family:'Courier New';color:blue;"  &gt;&lt;span style="font-size:85%;"&gt;            &lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style=";font-family:'Courier New';color:blue;"  &gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(163, 21, 21);font-family:'Courier New';" &gt;connectionStrings&lt;/span&gt;&lt;span style=";font-family:'Courier New';color:blue;"  &gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;"&gt;&lt;b&gt; &lt;/b&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;" align="justify"&gt;&lt;b&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Verdana;"&gt;Tip 2: Paging and Sorting a GridView without Refreshing a Page&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;" align="justify"&gt;&lt;span style=";font-family:Verdana;font-size:85%;"  &gt;If you have created a GridView and have bound it to a data source control, you can avoid postback during sorting and paging by setting  �??EnableSortingAndPagingCallbacks�?? property of the GridView to True.&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;" align="justify"&gt;&lt;span style=";font-family:Verdana;font-size:85%;"  &gt;Just remember that when you set the 'EnableSortingAndPagingCallbacks' property to true, you cannot use Template Fields in the GridView.&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;"&gt;&lt;b&gt; &lt;/b&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;" align="justify"&gt;&lt;b&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Verdana;"&gt;Tip 3: Pop-up a Confirmation box before Deleting a row in GridView&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;" align="justify"&gt;&lt;span style=";font-family:Verdana;font-size:85%;"  &gt;Add a template field and drop a button in it, using which the user will delete the record. In the OnClientClick event, call the confirm() function as mentioned below:&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style=";font-family:'Courier New';color:blue;"  &gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);font-family:'Courier New';" &gt;asp&lt;/span&gt;&lt;span style=";font-family:'Courier New';color:blue;"  &gt;:&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);font-family:'Courier New';" &gt;TemplateField&lt;/span&gt;&lt;span style=";font-family:'Courier New';color:blue;"  &gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;      &lt;span style="color:blue;"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;ItemTemplate&lt;/span&gt;&lt;span style="color:blue;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;        &lt;span style="color:blue;"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;asp&lt;/span&gt;&lt;span style="color:blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;Button&lt;/span&gt; &lt;span style="color:red;"&gt;ID&lt;/span&gt;&lt;span style="color:blue;"&gt;="btnDel"&lt;/span&gt; &lt;span style="color:red;"&gt;runat&lt;/span&gt;&lt;span style="color:blue;"&gt;="server"&lt;/span&gt; &lt;span style="color:red;"&gt;Text&lt;/span&gt;&lt;span style="color:blue;"&gt;="Delete"&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;            &lt;span style="color:red;"&gt;CommandName&lt;/span&gt;&lt;span style="color:blue;"&gt;="Delete"&lt;/span&gt; &lt;span style="color:red;"&gt;OnClientClick&lt;/span&gt;&lt;span style="color:blue;"&gt;="return confirm('Are you sure you want to delete the record?');"&lt;/span&gt; &lt;span style="color:blue;"&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;      &lt;span style="color:blue;"&gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;ItemTemplate&lt;/span&gt;&lt;span style="color:blue;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style=";font-family:'Courier New';color:blue;"  &gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(163, 21, 21);font-family:'Courier New';" &gt;asp&lt;/span&gt;&lt;span style=";font-family:'Courier New';color:blue;"  &gt;:&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);font-family:'Courier New';" &gt;TemplateField&lt;/span&gt;&lt;span style=";font-family:'Courier New';color:blue;"  &gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;"&gt;&lt;b&gt; &lt;/b&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;" align="justify"&gt;&lt;b&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Verdana;"&gt;Tip 4: Display details of the Row selected in the GridView&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;" align="justify"&gt;&lt;span style=";font-family:Verdana;font-size:85%;"  &gt;Assuming you have a button called �??Select�?? in your GridView with CommandName �??Select�??, to find out the row clicked and display the row�??s details, use this code:&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;"&gt;&lt;span style=";font-family:Verdana;font-size:85%;"  &gt;C#&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style=";font-family:'Courier New';color:blue;"  &gt;private&lt;/span&gt;&lt;span style="font-family:'Courier New';"&gt; &lt;span style="color:blue;"&gt;void&lt;/span&gt; GridView1_RowCommand(&lt;span style="color: rgb(43, 145, 175);"&gt;Object&lt;/span&gt; sender,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color: rgb(43, 145, 175);font-family:'Courier New';" &gt;GridViewCommandEventArgs&lt;/span&gt;&lt;span style="font-family:'Courier New';"&gt; e)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;    {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;        &lt;span style="color:blue;"&gt;if&lt;/span&gt; (e.CommandName == &lt;span style="color: rgb(163, 21, 21);"&gt;"Select"&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;        {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;            &lt;span style="color:blue;"&gt;int&lt;/span&gt; idx = &lt;span style="color: rgb(43, 145, 175);"&gt;Convert&lt;/span&gt;.ToInt32(e.CommandArgument);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;            &lt;span style="color: rgb(43, 145, 175);"&gt;GridViewRow&lt;/span&gt; selrow = GridView1.Rows[idx];&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;            &lt;span style="color:blue;"&gt;string&lt;/span&gt; fstCell  = selrow.Cells[0].Text;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt 0.5in; text-indent: 0.5in; line-height: normal;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style=";font-family:'Courier New';color:blue;"  &gt;string&lt;/span&gt;&lt;span style="font-family:'Courier New';"&gt; scndCell = selrow.Cells[1].Text;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt 0.5in; text-indent: 0.5in; line-height: normal;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style=";font-family:'Courier New';color:blue;"  &gt;// and so on&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt 0.5in; text-indent: 0.5in; line-height: normal;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style=";font-family:'Courier New';color:blue;"  &gt;// Thanks to Mark Rae (MVP) for pointing the typo. Earlier it was Cells[1] and Cells [2]&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;        }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:'Courier New';"&gt;    }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;"&gt;&lt;span style=";font-family:Verdana;font-size:85%;"  &gt;VB.NET&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style=";font-family:'Courier New';color:blue;"  &gt;Private&lt;/span&gt;&lt;span style="font-family:'Courier New';"&gt; &lt;span style="color:blue;"&gt;Sub&lt;/span&gt; GridView1_RowCommand(&lt;span style="color:blue;"&gt;ByVal&lt;/span&gt; sender &lt;span style="color:blue;"&gt;As&lt;/span&gt; &lt;span style="color:blue;"&gt;Object&lt;/span&gt;, &lt;span style="color:blue;"&gt;ByVal&lt;/span&gt; e &lt;span style="color:blue;"&gt;As&lt;/span&gt; GridViewCommandEventArgs)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;      &lt;span style="color:blue;"&gt;If&lt;/span&gt; e.CommandName = "Select" &lt;span style="color:blue;"&gt;Then&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;            &lt;span style="color:blue;"&gt;Dim&lt;/span&gt; idx &lt;span style="color:blue;"&gt;As&lt;/span&gt; &lt;span style="color:blue;"&gt;Integer&lt;/span&gt; = Convert.ToInt32(e.CommandArgument)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;            &lt;span style="color:blue;"&gt;Dim&lt;/span&gt; selrow &lt;span style="color:blue;"&gt;As&lt;/span&gt; GridViewRow = GridView1.Rows(idx)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;            &lt;span style="color:blue;"&gt;Dim&lt;/span&gt; fstCell &lt;span style="color:blue;"&gt;As&lt;/span&gt; &lt;span style="color:blue;"&gt;String&lt;/span&gt; = selrow.Cells(0).Text&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt 0.5in; text-indent: 0.5in; line-height: normal;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style=";font-family:'Courier New';color:blue;"  &gt;Dim&lt;/span&gt;&lt;span style="font-family:'Courier New';"&gt; scndCell &lt;span style="color:blue;"&gt;As&lt;/span&gt; &lt;span style="color:blue;"&gt;String&lt;/span&gt; = selrow.Cells(1).Text&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt 0.5in; text-indent: 0.5in; line-height: normal;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style=";font-family:'Courier New';color:green;"  &gt;' and so on&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;      &lt;span style="color:blue;"&gt;End&lt;/span&gt; &lt;span style="color:blue;"&gt;If&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style=";font-family:'Courier New';color:blue;"  &gt;End&lt;/span&gt;&lt;span style="font-family:'Courier New';"&gt; &lt;span style="color:blue;"&gt;Sub&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;"&gt;&lt;b&gt; &lt;/b&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;"&gt;&lt;b&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Verdana;"&gt;Tip 5: Retrieve Details of the Row being Modified in GridView&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;"&gt;&lt;span style=";font-family:Verdana;font-size:85%;"  &gt;C#&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style=";font-family:'Courier New';color:blue;"  &gt;void&lt;/span&gt;&lt;span style="font-family:'Courier New';"&gt; GridView1_RowUpdated(&lt;span style="color: rgb(43, 145, 175);"&gt;Object&lt;/span&gt; sender, &lt;span style="color: rgb(43, 145, 175);"&gt;GridViewUpdatedEventArgs&lt;/span&gt; e)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;    {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;        &lt;span style="color:green;"&gt;// Retrieve the row being edited.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;        &lt;span style="color:blue;"&gt;int&lt;/span&gt; index = GridView1.EditIndex;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;        &lt;span style="color: rgb(43, 145, 175);"&gt;GridViewRow&lt;/span&gt; row = GridView1.Rows[index];&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt; &lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;        &lt;span style="color:green;"&gt;// Retrieve the value of the first cell &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;        lblMsg.Text = &lt;span style="color: rgb(163, 21, 21);"&gt;"Updated record "&lt;/span&gt; + row.Cells[1].Text;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:'Courier New';"&gt;    }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;"&gt;&lt;span style=";font-family:Verdana;font-size:85%;"  &gt;VB.NET&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style=";font-family:'Courier New';color:blue;"  &gt;Private&lt;/span&gt;&lt;span style="font-family:'Courier New';"&gt; &lt;span style="color:blue;"&gt;Sub&lt;/span&gt; GridView1_RowUpdated(&lt;span style="color:blue;"&gt;ByVal&lt;/span&gt; sender &lt;span style="color:blue;"&gt;As&lt;/span&gt; &lt;span style="color:blue;"&gt;Object&lt;/span&gt;, &lt;span style="color:blue;"&gt;ByVal&lt;/span&gt; e &lt;span style="color:blue;"&gt;As&lt;/span&gt; GridViewUpdatedEventArgs)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;            &lt;span style="color:green;"&gt;' Retrieve the row being edited.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;            &lt;span style="color:blue;"&gt;Dim&lt;/span&gt; index &lt;span style="color:blue;"&gt;As&lt;/span&gt; &lt;span style="color:blue;"&gt;Integer&lt;/span&gt; = GridView1.EditIndex&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;            &lt;span style="color:blue;"&gt;Dim&lt;/span&gt; row &lt;span style="color:blue;"&gt;As&lt;/span&gt; GridViewRow = GridView1.Rows(index)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt; &lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;            &lt;span style="color:green;"&gt;' Retrieve the value of the first cell &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;            lblMsg.Text = "Updated record " &amp;amp; row.Cells(1).Text&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:'Courier New';"&gt; &lt;span style="color:blue;"&gt;End&lt;/span&gt; &lt;span style="color:blue;"&gt;Sub&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;"&gt;&lt;b&gt; &lt;/b&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;" align="justify"&gt;&lt;b&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Verdana;"&gt;Tip 6: Retrieve Details of the Row being Deleted in GridView&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;" align="justify"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Verdana;"&gt;The ID of the row being deleted must be in the GridView.DataKeyNames collection. &lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;"&gt;&lt;span style=";font-family:Verdana;font-size:85%;"  &gt;C#&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style=";font-family:'Courier New';color:blue;"  &gt;protected&lt;/span&gt;&lt;span style="font-family:'Courier New';"&gt; &lt;span style="color:blue;"&gt;void&lt;/span&gt; GridView1_RowDeleting(&lt;span style="color:blue;"&gt;object&lt;/span&gt; sender, &lt;span style="color: rgb(43, 145, 175);"&gt;GridViewDeleteEventArgs&lt;/span&gt; e)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;    {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;        &lt;span style="color:blue;"&gt;int&lt;/span&gt; ID = (&lt;span style="color:blue;"&gt;int&lt;/span&gt;)GridView1.DataKeys[e.RowIndex].Value;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;        &lt;span style="color:green;"&gt;// Query the database and get the values based on the ID&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;    }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;"&gt;&lt;span style=";font-family:Verdana;font-size:85%;"  &gt;VB.NET&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;Protected Sub GridView1_RowDeleting(ByVal sender As Object, ByVal e As GridViewDeleteEventArgs) &lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;        Dim ID As Integer = CInt(GridView1.DataKeys(e.RowIndex).Value) &lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;        &lt;span style="color: rgb(163, 21, 21);"&gt;' Query the database and get the values based on the ID &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:'Courier New';"&gt;    End Sub&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;"&gt;&lt;b&gt; &lt;/b&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;" align="justify"&gt;&lt;b&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Verdana;"&gt;Tip 7: Cancelling Update and Delete in a GridView&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;" align="justify"&gt;&lt;span style=";font-family:Verdana;font-size:85%;"  &gt;RowUpdating - Occurs when a row's Update button is clicked, but before the GridView control updates the row.&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;" align="justify"&gt;&lt;span style=";font-family:Verdana;font-size:85%;"  &gt;RowDeleting �?? Occurs when a row's Delete button is clicked, but before the GridView control deletes the row.&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;"&gt;&lt;span style=";font-family:Verdana;font-size:85%;"  &gt;C#&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style=";font-family:'Courier New';color:blue;"  &gt;protected&lt;/span&gt;&lt;span style="font-family:'Courier New';"&gt; &lt;span style="color:blue;"&gt;void&lt;/span&gt; gvDetail_RowUpdating(&lt;span style="color:blue;"&gt;object&lt;/span&gt; sender, &lt;span style="color: rgb(43, 145, 175);"&gt;GridViewUpdateEventArgs&lt;/span&gt; e)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;    {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;        e.Cancel = &lt;span style="color:blue;"&gt;true&lt;/span&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;    }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style=";font-family:'Courier New';color:blue;"  &gt;void&lt;/span&gt;&lt;span style="font-family:'Courier New';"&gt; GridView1_RowDeleting(&lt;span style="color: rgb(43, 145, 175);"&gt;Object&lt;/span&gt; sender, &lt;span style="color: rgb(43, 145, 175);"&gt;GridViewDeleteEventArgs&lt;/span&gt; e)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;    {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;        &lt;span style="color:green;"&gt;// Check for a condition and cancel the delete&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;        &lt;span style="color:green;"&gt;// There should be atleast one row left in the GridView&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;        &lt;span style="color:blue;"&gt;if&lt;/span&gt; (GridView1.Rows.Count &lt;= 1)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;        {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;            e.Cancel = &lt;span style="color:blue;"&gt;true&lt;/span&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;        }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;    }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;"&gt;&lt;span style=";font-family:Verdana;font-size:85%;"  &gt;VB.NET&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style=";font-family:'Courier New';color:blue;"  &gt;Protected&lt;/span&gt;&lt;span style="font-family:'Courier New';"&gt; &lt;span style="color:blue;"&gt;Sub&lt;/span&gt; gvDetail_RowUpdating(&lt;span style="color:blue;"&gt;ByVal&lt;/span&gt; sender &lt;span style="color:blue;"&gt;As&lt;/span&gt; &lt;span style="color:blue;"&gt;Object&lt;/span&gt;, &lt;span style="color:blue;"&gt;ByVal&lt;/span&gt; e &lt;span style="color:blue;"&gt;As&lt;/span&gt; GridViewUpdateEventArgs)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;   e.Cancel = &lt;span style="color:blue;"&gt;True&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style=";font-family:'Courier New';color:blue;"  &gt;End&lt;/span&gt;&lt;span style="font-family:'Courier New';"&gt; &lt;span style="color:blue;"&gt;Sub&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style=";font-family:'Courier New';color:blue;"  &gt;Private&lt;/span&gt;&lt;span style="font-family:'Courier New';"&gt; &lt;span style="color:blue;"&gt;Sub&lt;/span&gt; GridView1_RowDeleting(&lt;span style="color:blue;"&gt;ByVal&lt;/span&gt; sender &lt;span style="color:blue;"&gt;As&lt;/span&gt; &lt;span style="color:blue;"&gt;Object&lt;/span&gt;, &lt;span style="color:blue;"&gt;ByVal&lt;/span&gt; e &lt;span style="color:blue;"&gt;As&lt;/span&gt; GridViewDeleteEventArgs)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;            &lt;span style="color:green;"&gt;' Check for a condition and cancel the delete&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;            &lt;span style="color:green;"&gt;' There should be atleast one row left in the GridView&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;            &lt;span style="color:blue;"&gt;If&lt;/span&gt; GridView1.Rows.Count &lt;= 1 &lt;span style="color:blue;"&gt;Then&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;                  e.Cancel = &lt;span style="color:blue;"&gt;True&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;            &lt;span style="color:blue;"&gt;End&lt;/span&gt; &lt;span style="color:blue;"&gt;If&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style=";font-family:'Courier New';color:blue;"  &gt;End&lt;/span&gt;&lt;span style="font-family:'Courier New';"&gt; &lt;span style="color:blue;"&gt;Sub&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;"&gt;&lt;b&gt; &lt;/b&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;" align="justify"&gt;&lt;b&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Verdana;"&gt;Tip 8: Paging and Sorting in GridView without using Datasource control&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;" align="justify"&gt;&lt;span style=";font-family:Verdana;font-size:85%;"  &gt;Original Code Author: &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);font-family:Verdana;font-size:85%;"  &gt;Ryan Olshan&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;"&gt;&lt;span style=";font-family:Verdana;font-size:85%;"  &gt;C#&lt;/span&gt;&lt;/div&gt; &lt;div&gt;&lt;span style=";font-family:'Courier New';font-size:10;color:blue;"   &gt;&lt;&lt;/span&gt;&lt;span style=";font-family:'Courier New';font-size:10;color:brown;"   &gt;asp&lt;/span&gt;&lt;span style=";font-family:'Courier New';font-size:10;color:blue;"   &gt;:&lt;/span&gt;&lt;span style=";font-family:'Courier New';font-size:10;color:brown;"   &gt;GridView&lt;/span&gt;&lt;span style=";font-family:'Courier New';font-size:10;"  &gt; &lt;span style="color:red;"&gt;ID&lt;/span&gt;&lt;span style="color:blue;"&gt;="gridView"&lt;/span&gt; &lt;span style="color:red;"&gt;OnPageIndexChanging&lt;/span&gt;&lt;span style="color:blue;"&gt;="gridView_PageIndexChanging"&lt;/span&gt; &lt;/span&gt;&lt;/div&gt; &lt;div&gt;&lt;span style=";font-family:'Courier New';font-size:10;"  &gt;&lt;span style="color:red;"&gt;OnSorting&lt;/span&gt;&lt;span style="color:blue;"&gt;="gridView_Sorting"&lt;/span&gt; &lt;span style="color:red;"&gt;runat&lt;/span&gt;&lt;span style="color:blue;"&gt;="server" /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div&gt;&lt;span style=";font-family:'Courier New';font-size:10;color:blue;"   &gt;private string&lt;/span&gt;&lt;span style=";font-family:'Courier New';font-size:10;"  &gt; ConvertSortDirectionToSql(&lt;span style="color:teal;"&gt;SortDirection&lt;/span&gt; sortDireciton)
&lt;br /&gt;{
&lt;br /&gt;  &lt;span style="color:blue;"&gt;string&lt;/span&gt; newSortDirection = &lt;span style="color:teal;"&gt;String&lt;/span&gt;.Empty;&lt;/span&gt;&lt;/div&gt; &lt;div&gt;&lt;span style=";font-family:'Courier New';font-size:10;"  &gt;   &lt;span style="color:blue;"&gt;switch&lt;/span&gt; (sortDirection)
&lt;br /&gt;  {
&lt;br /&gt;     &lt;span style="color:blue;"&gt;case&lt;/span&gt; &lt;span style="color:teal;"&gt;SortDirection&lt;/span&gt;.Ascending:
&lt;br /&gt;        newSortDirection = &lt;span style="color:brown;"&gt;"ASC"&lt;/span&gt;;
&lt;br /&gt;        &lt;span style="color:blue;"&gt;break&lt;/span&gt;;&lt;/span&gt;&lt;/div&gt; &lt;div&gt;&lt;span style=";font-family:'Courier New';font-size:10;"  &gt;      &lt;span style="color:blue;"&gt;case&lt;/span&gt; &lt;span style="color:teal;"&gt;SortDirection&lt;/span&gt;.Descending:
&lt;br /&gt;        newSortDirection = &lt;span style="color:brown;"&gt;"DESC"&lt;/span&gt;;
&lt;br /&gt;        &lt;span style="color:blue;"&gt;break&lt;/span&gt;;
&lt;br /&gt;  }&lt;/span&gt;&lt;/div&gt; &lt;div&gt;&lt;span style=";font-family:'Courier New';font-size:10;"  &gt;   &lt;span style="color:blue;"&gt;return&lt;/span&gt; newSortDirection
&lt;br /&gt;}&lt;/span&gt;&lt;/div&gt; &lt;div&gt;&lt;span style=";font-family:'Courier New';font-size:10;color:blue;"   &gt;protected void&lt;/span&gt;&lt;span style=";font-family:'Courier New';font-size:10;"  &gt; gridView_PageIndexChanging(&lt;span style="color:blue;"&gt;object&lt;/span&gt; sender, &lt;span style="color:teal;"&gt;GridViewPageEventArgs&lt;/span&gt; e)
&lt;br /&gt;{
&lt;br /&gt;  gridView.PageIndex = e.NewPageIndex;
&lt;br /&gt;  gridView.DataBind();
&lt;br /&gt;}&lt;/span&gt;&lt;/div&gt; &lt;div&gt;&lt;span style=";font-family:'Courier New';font-size:10;color:blue;"   &gt;protected void&lt;/span&gt;&lt;span style=";font-family:'Courier New';font-size:10;"  &gt; gridView_Sorting(&lt;span style="color:blue;"&gt;object&lt;/span&gt; sender, &lt;span style="color:teal;"&gt;GridViewSortEventArgs&lt;/span&gt; e)
&lt;br /&gt;{
&lt;br /&gt;  &lt;span style="color:teal;"&gt;DataTable&lt;/span&gt; dataTable = gridView.DataSource &lt;span style="color:blue;"&gt;as&lt;/span&gt; &lt;span style="color:teal;"&gt;DataTable&lt;/span&gt;;&lt;/span&gt;&lt;/div&gt; &lt;div&gt;&lt;span style=";font-family:'Courier New';font-size:10;"  &gt;   &lt;span style="color:blue;"&gt;if&lt;/span&gt; (dataTable != &lt;span style="color:blue;"&gt;null&lt;/span&gt;)
&lt;br /&gt;  {
&lt;br /&gt;     &lt;span style="color:teal;"&gt;DataView&lt;/span&gt; dataView = &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color:teal;"&gt;DataView&lt;/span&gt;(dataTable);
&lt;br /&gt;     dataView.Sort = e.SortExpression + &lt;span style="color:brown;"&gt;" "&lt;/span&gt; + ConvertSortDirectionToSql(e.SortDirection);&lt;/span&gt;&lt;/div&gt; &lt;div&gt;&lt;span style=";font-family:'Courier New';font-size:10;"  &gt;      gridView.DataSource = dataView;
&lt;br /&gt;     gridView.DataBind();
&lt;br /&gt;  }
&lt;br /&gt;}&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;"&gt;&lt;span style=";font-family:Verdana;font-size:85%;"  &gt;VB.NET&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style=";font-family:'Courier New';color:blue;"  &gt;Private&lt;/span&gt;&lt;span style="font-family:'Courier New';"&gt; &lt;span style="color:blue;"&gt;Function&lt;/span&gt; ConvertSortDirectionToSql(&lt;span style="color:blue;"&gt;ByVal&lt;/span&gt; sortDireciton &lt;span style="color:blue;"&gt;As&lt;/span&gt; SortDirection) &lt;span style="color:blue;"&gt;As&lt;/span&gt; &lt;span style="color:blue;"&gt;String&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;   &lt;span style="color:blue;"&gt;Dim&lt;/span&gt; newSortDirection &lt;span style="color:blue;"&gt;As&lt;/span&gt; &lt;span style="color:blue;"&gt;String&lt;/span&gt; = &lt;span style="color:blue;"&gt;String&lt;/span&gt;.Empty&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt; &lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;   &lt;span style="color:blue;"&gt;Select&lt;/span&gt; &lt;span style="color:blue;"&gt;Case&lt;/span&gt; sortDirection&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;       &lt;span style="color:blue;"&gt;Case&lt;/span&gt; SortDirection.Ascending&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;             newSortDirection = "ASC"&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt; &lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;       &lt;span style="color:blue;"&gt;Case&lt;/span&gt; SortDirection.Descending&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;             newSortDirection = "DESC"&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;   &lt;span style="color:blue;"&gt;End&lt;/span&gt; &lt;span style="color:blue;"&gt;Select&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt; &lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;   &lt;span style="color:blue;"&gt;Return&lt;/span&gt; newSortDirection&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style=";font-family:'Courier New';color:blue;"  &gt;End&lt;/span&gt;&lt;span style="font-family:'Courier New';"&gt; &lt;span style="color:blue;"&gt;Function&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt; &lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style=";font-family:'Courier New';color:blue;"  &gt;Protected&lt;/span&gt;&lt;span style="font-family:'Courier New';"&gt; &lt;span style="color:blue;"&gt;Sub&lt;/span&gt; gridView_PageIndexChanging(&lt;span style="color:blue;"&gt;ByVal&lt;/span&gt; sender &lt;span style="color:blue;"&gt;As&lt;/span&gt; &lt;span style="color:blue;"&gt;Object&lt;/span&gt;, &lt;span style="color:blue;"&gt;ByVal&lt;/span&gt; e &lt;span style="color:blue;"&gt;As&lt;/span&gt; GridViewPageEventArgs)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;   gridView.PageIndex = e.NewPageIndex&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;   gridView.DataBind()&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style=";font-family:'Courier New';color:blue;"  &gt;End&lt;/span&gt;&lt;span style="font-family:'Courier New';"&gt; &lt;span style="color:blue;"&gt;Sub&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt; &lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style=";font-family:'Courier New';color:blue;"  &gt;Protected&lt;/span&gt;&lt;span style="font-family:'Courier New';"&gt; &lt;span style="color:blue;"&gt;Sub&lt;/span&gt; gridView_Sorting(&lt;span style="color:blue;"&gt;ByVal&lt;/span&gt; sender &lt;span style="color:blue;"&gt;As&lt;/span&gt; &lt;span style="color:blue;"&gt;Object&lt;/span&gt;, &lt;span style="color:blue;"&gt;ByVal&lt;/span&gt; e &lt;span style="color:blue;"&gt;As&lt;/span&gt; GridViewSortEventArgs)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;   &lt;span style="color:blue;"&gt;Dim&lt;/span&gt; dataTable &lt;span style="color:blue;"&gt;As&lt;/span&gt; DataTable = TryCast(gridView.DataSource, DataTable)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt; &lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;   &lt;span style="color:blue;"&gt;If&lt;/span&gt; &lt;span style="color:blue;"&gt;Not&lt;/span&gt; dataTable &lt;span style="color:blue;"&gt;Is&lt;/span&gt; &lt;span style="color:blue;"&gt;Nothing&lt;/span&gt; &lt;span style="color:blue;"&gt;Then&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;       &lt;span style="color:blue;"&gt;Dim&lt;/span&gt; dataView &lt;span style="color:blue;"&gt;As&lt;/span&gt; DataView = &lt;span style="color:blue;"&gt;New&lt;/span&gt; DataView(dataTable)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;       dataView.Sort = e.SortExpression &amp;amp; " " &amp;amp; ConvertSortDirectionToSql(e.SortDirection)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt; &lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;       gridView.DataSource = dataView&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;       gridView.DataBind()&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;   &lt;span style="color:blue;"&gt;End&lt;/span&gt; &lt;span style="color:blue;"&gt;If&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style=";font-family:'Courier New';color:blue;"  &gt;End&lt;/span&gt;&lt;span style="font-family:'Courier New';"&gt; &lt;span style="color:blue;"&gt;Sub&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;"&gt;&lt;b&gt; &lt;/b&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;" align="justify"&gt;&lt;b&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Verdana;"&gt;Tip 9: Delete Multiple rows in a GridView&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;" align="justify"&gt;&lt;span style=";font-family:Verdana;font-size:85%;"  &gt;Check this article of mine over &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);font-family:Verdana;font-size:85%;"  &gt;here&lt;/span&gt;&lt;span style=";font-family:Verdana;font-size:85%;"  &gt;.&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;"&gt; &lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;"&gt;&lt;b&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Verdana;"&gt;Tip 10: Export GridView To Excel&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;"&gt;&lt;span style=";font-family:Verdana;font-size:85%;"  &gt;C#&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style=";font-family:'Courier New';color:blue;"  &gt;protected&lt;/span&gt;&lt;span style="font-family:'Courier New';"&gt; &lt;span style="color:blue;"&gt;void&lt;/span&gt; Button1_Click(&lt;span style="color:blue;"&gt;object&lt;/span&gt; sender, &lt;span style="color: rgb(43, 145, 175);"&gt;EventArgs&lt;/span&gt; e)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;    {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;        Response.AddHeader(&lt;span style="color: rgb(163, 21, 21);"&gt;"content-disposition"&lt;/span&gt;, &lt;span style="color: rgb(163, 21, 21);"&gt;"attachment;filename=FileName.xls"&lt;/span&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;        Response.Charset = &lt;span style="color: rgb(43, 145, 175);"&gt;String&lt;/span&gt;.Empty;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;        Response.ContentType = &lt;span style="color: rgb(163, 21, 21);"&gt;"application/vnd.xls"&lt;/span&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;        System.IO.&lt;span style="color: rgb(43, 145, 175);"&gt;StringWriter&lt;/span&gt; sw = &lt;span style="color:blue;"&gt;new&lt;/span&gt; System.IO.&lt;span style="color: rgb(43, 145, 175);"&gt;StringWriter&lt;/span&gt;();&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;        System.Web.UI.&lt;span style="color: rgb(43, 145, 175);"&gt;HtmlTextWriter&lt;/span&gt; hw = &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;HtmlTextWriter&lt;/span&gt;(sw);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;        GridView1.RenderControl(hw);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;        Response.Write(sw.ToString());&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;        Response.End();&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;    }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;"&gt;&lt;span style=";font-family:Verdana;font-size:85%;"  &gt;VB.NET&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style=";font-family:'Courier New';color:blue;"  &gt;Protected&lt;/span&gt;&lt;span style="font-family:'Courier New';"&gt; &lt;span style="color:blue;"&gt;Sub&lt;/span&gt; Button1_Click(&lt;span style="color:blue;"&gt;ByVal&lt;/span&gt; sender &lt;span style="color:blue;"&gt;As&lt;/span&gt; &lt;span style="color:blue;"&gt;Object&lt;/span&gt;, &lt;span style="color:blue;"&gt;ByVal&lt;/span&gt; e &lt;span style="color:blue;"&gt;As&lt;/span&gt; EventArgs)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;            Response.AddHeader("content-disposition", "attachment;filename=FileName.xls")&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;            Response.Charset = &lt;span style="color:blue;"&gt;String&lt;/span&gt;.Empty&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;            Response.ContentType = "application/vnd.xls"&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;            &lt;span style="color:blue;"&gt;Dim&lt;/span&gt; sw &lt;span style="color:blue;"&gt;As&lt;/span&gt; System.IO.StringWriter = &lt;span style="color:blue;"&gt;New&lt;/span&gt; System.IO.StringWriter()&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;            &lt;span style="color:blue;"&gt;Dim&lt;/span&gt; hw &lt;span style="color:blue;"&gt;As&lt;/span&gt; System.Web.UI.HtmlTextWriter = &lt;span style="color:blue;"&gt;New&lt;/span&gt; HtmlTextWriter(sw)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;            GridView1.RenderControl(hw)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;            Response.Write(sw.ToString())&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt; line-height: normal;"&gt;&lt;span style="font-family:'Courier New';"&gt;&lt;span style="font-size:85%;"&gt;            Response.End()&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style=";font-family:'Courier New';color:blue;"  &gt;End&lt;/span&gt;&lt;span style="font-family:'Courier New';"&gt; &lt;span style="color:blue;"&gt;Sub&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;"&gt; &lt;/div&gt; &lt;div style="margin: 0in 0in 10pt;" align="justify"&gt;&lt;span style=";font-family:Verdana;font-size:85%;"  &gt;Well that was a quick overview of some of the most frequently used features of the GridView control. I hope you liked the article and I thank you for viewing it. &lt;/span&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/ynBt/~4/J2WIDJGxZjI" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://purl.org/atom/app#">2009-02-12T18:53:10.302+05:30</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://dotnetfaqs-edu.blogspot.com/2009/02/handle-error-simple-way-in-aspnet.html</feedburner:origLink></item><item><title>Detect Browser Compatibility with the Request Object</title><link>http://feedproxy.google.com/~r/blogspot/ynBt/~3/nyBE4OeEDPg/listview-and-datapager.html</link><category>Ajax Hacks</category><author>noreply@blogger.com (Tiru)</author><pubDate>Thu, 12 Feb 2009 05:00:08 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-6426652519813936980.post-563733419663794428</guid><description>&lt;p class="docText"&gt;&lt;span class="docEmphBold"  style="font-size:100%;"&gt;Use JavaScript to set up Microsoft's  and the Mozilla-based browsers' different request objects. &lt;/span&gt;&lt;/p&gt; &lt;p class="docText"&gt;&lt;span style="font-size:100%;"&gt;&lt;a name="ID-ID-d472e0-725157"&gt;&lt;/a&gt;Browser compatibility is an  important consideration. You have to make sure the "engine" behind Ajax's server  handshake is properly constructed, but you can never predict which browsers your  users will favor.&lt;/span&gt;&lt;/p&gt; &lt;p class="docText"&gt;&lt;span style="font-size:100%;"&gt;The programming tool that allows Ajax applications to make HTTP  requests to a server is an object that you can use from within JavaScript code.  In the world of Firefox and Netscape (as well as Safari and Opera), this object  is named &lt;tt&gt;&lt;a name="ID-ID-d475e0-725162"&gt;&lt;/a&gt;XMLHttpRequest&lt;/tt&gt;. However,  continuing with the tradition established by IE 5.0, recent vintages of Internet  Explorer implement the software as an &lt;tt&gt;ActiveX&lt;/tt&gt; object named &lt;tt&gt;&lt;a name="ID-ID-d478e0-725163"&gt;&lt;/a&gt;Microsoft.XMLHTTP&lt;/tt&gt; or &lt;tt&gt;&lt;a name="ID-ID-d481e0-725164"&gt;&lt;/a&gt;Msxml2.XMLHTTP&lt;/tt&gt;.&lt;/span&gt;&lt;/p&gt;&lt;p class="docText"&gt;&lt;span style="font-size:100%;"&gt;Although Microsoft and the engineers on the Mozilla project  have chosen to implement this object differently, we will refer to the  &lt;tt&gt;ActiveX&lt;/tt&gt; and &lt;tt&gt;XMLHttpRequest&lt;/tt&gt; objects simply as "&lt;a name="ID-ID-d484e0-725165"&gt;&lt;/a&gt;request objects" throughout this book, because they  have very similar functionality. &lt;/span&gt;&lt;/p&gt; &lt;p class="docText"&gt;&lt;span style="font-size:100%;"&gt;As a first step in using Ajax, you must check if the user's  browser supports either one of the Mozilla-based or &lt;tt&gt;ActiveX&lt;/tt&gt;-related  request objects, and then properly initialize the object.&lt;/span&gt;&lt;/p&gt;&lt;h4 class="docSection2Title" id="title-IDAS0Y1FB"&gt;&lt;span style="font-size:100%;"&gt;Using a Function for Checking  Compatibility&lt;/span&gt;&lt;/h4&gt; &lt;p class="docText"&gt;&lt;span style="font-size:100%;"&gt;&lt;a name="ID-ID-d487e0-725167"&gt;&lt;/a&gt;Wrap the compatibility check  inside a JavaScript function, then call this function before you make any HTTP  requests using the object. For example, in Mozilla-based browsers such as  Netscape 7.1 and Firefox 1.5 (as well as in Safari 2.0 and Opera 8.5), the  request object is available as a property of the top-level &lt;tt&gt;window&lt;/tt&gt;  object. The reference to this object in JavaScript code is &lt;tt&gt;&lt;a name="ID-ID-d490e0-725166"&gt;&lt;/a&gt;window.XMLHttpRequest&lt;/tt&gt;. The compatibility check  for these browser types looks like this:&lt;/span&gt;&lt;/p&gt;&lt;pre&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size:130%;"&gt;if(window.XMLHttpRequest){&lt;br /&gt;request = new XMLHttpRequest(  );&lt;br /&gt;request.onreadystatechange=handleResponse;&lt;br /&gt;request.open("GET",theURL,true);&lt;br /&gt;request.send(null);&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;p class="docText"&gt;&lt;span style="font-size:100%;"&gt;The JavaScript variable &lt;tt&gt;&lt;a name="ID-ID-d493e0-725245"&gt;&lt;/a&gt;request&lt;/tt&gt; is to a top-level variable that will  refer to the request object.&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="docText"&gt;&lt;span style="font-size:100%;"&gt;If the browser supports &lt;tt&gt;XMLHttpRequest&lt;/tt&gt;, then:&lt;/span&gt;&lt;/p&gt; &lt;div style="font-weight: bold;"&gt; &lt;ol class="docList" type="1"&gt;&lt;li&gt; &lt;div style="font-weight: normal;"&gt; &lt;p class="docList"&gt;&lt;span style="font-size:100%;"&gt;&lt;tt&gt;if(window.XMLHttpRequest)&lt;/tt&gt; returns &lt;tt&gt;true&lt;/tt&gt;  because the &lt;tt&gt;XMLHttpRequest&lt;/tt&gt; is not &lt;tt&gt;null&lt;/tt&gt; or  &lt;tt&gt;undefined&lt;/tt&gt;.&lt;/span&gt;&lt;/p&gt;&lt;/div&gt; &lt;/li&gt;&lt;li&gt; &lt;div style="font-weight: normal;"&gt; &lt;p class="docList"&gt;&lt;span style="font-size:100%;"&gt;The object will be instantiated with the &lt;tt&gt;new&lt;/tt&gt;  keyword.&lt;/span&gt;&lt;/p&gt;&lt;/div&gt; &lt;/li&gt;&lt;li&gt; &lt;div style="font-weight: normal;"&gt; &lt;p class="docList"&gt;&lt;span style="font-size:100%;"&gt;Its &lt;tt&gt;onreadystatechange&lt;/tt&gt; event listener (see the section  &lt;/span&gt;&lt;span class="docLink"  style="font-size:100%;"&gt;"&lt;/span&gt;&lt;span class="docLink"  style="font-size:100%;"&gt;XMLHttpRequest&lt;/span&gt;&lt;span style="font-size:100%;"&gt;"  earlier in this chapter) will be defined as a function named &lt;tt&gt;handleResponse(  )&lt;/tt&gt;.&lt;/span&gt;&lt;/p&gt;&lt;/div&gt; &lt;/li&gt;&lt;li&gt; &lt;div style="font-weight: normal;"&gt; &lt;p class="docList"&gt;&lt;span style="font-size:100%;"&gt;The code calls the request object's &lt;tt&gt;open( )&lt;/tt&gt; and  &lt;tt&gt;send( )&lt;/tt&gt; methods.&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt; &lt;p class="docText"&gt;&lt;span style="font-size:100%;"&gt;In this case, the &lt;tt&gt;window.XMLHttpRequest&lt;/tt&gt; object will  not exist in the browser object model. Therefore, another branch of the  &lt;tt&gt;if&lt;/tt&gt; test is necessary in your code:&lt;/span&gt;&lt;/p&gt;&lt;pre&gt;&lt;span style="font-size:130%;"&gt;else if (window.ActiveXObject){&lt;br /&gt;request=new ActiveXObject("Microsoft.XMLHTTP");&lt;br /&gt;if (! request){&lt;br /&gt;    request=new ActiveXObject("Msxml2.XMLHTTP");&lt;br /&gt;}&lt;br /&gt;if(request){&lt;br /&gt;    request.onreadystatechange=handleResponse;&lt;br /&gt;    request.open(reqType,url,true);&lt;br /&gt;    request.send(null);&lt;br /&gt;}&lt;br /&gt;}&lt;/span&gt;&lt;/pre&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;p class="docText"&gt;&lt;span style="font-size:100%;"&gt;&lt;a name="ID-ID-d500e0-876836"&gt;&lt;/a&gt;&lt;a name="ID-ID-d504e0-876834"&gt;&lt;/a&gt;This code fragment tests for the existence of the  top-level &lt;tt&gt;window&lt;/tt&gt; object &lt;tt&gt;ActiveXObject&lt;/tt&gt;, thus signaling the use  of Internet Explorer. The code then initializes the request using two of a  number of possible &lt;a name="ID-ID-d507e0-725246"&gt;&lt;/a&gt;&lt;tt&gt;&lt;a name="ID-ID-d510e0-876782"&gt;&lt;/a&gt;ActiveX&lt;/tt&gt; program IDs (here,  &lt;tt&gt;Microsoft.XMLHTTP&lt;/tt&gt; and &lt;tt&gt;Msxml2.XMLHTTP&lt;/tt&gt;). &lt;/span&gt;&lt;/p&gt; &lt;p class="docText"&gt;&lt;span style="font-size:100%;"&gt;You can get even more fine-grained when testing for different  versions of the IE request object, such as &lt;tt&gt;Msxml2.XMLHTTP.4.0&lt;/tt&gt;. In the  vast majority of cases, however, you will not be designing your application  based on various versions of the MSXML libraries, so the prior code will  suffice.&lt;/span&gt;&lt;/p&gt; &lt;p class="docText"&gt;&lt;span style="font-size:100%;"&gt;The code then makes one final check for whether the request  object has been properly constructed&lt;span style="font-size:130%;"&gt; (&lt;tt&gt;if(request){...}&lt;/tt&gt;).&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="docText"&gt;&lt;span style="font-size:100%;"&gt;Given three chances, if the &lt;tt&gt;request&lt;/tt&gt; variable is still  &lt;tt&gt;null&lt;/tt&gt; or &lt;tt&gt;undefined&lt;/tt&gt;, your browser is really out of luck when it  comes to using the request object for Ajax!&lt;/span&gt;&lt;/p&gt; &lt;p class="docText"&gt;&lt;span style="font-size:100%;"&gt;Here's an example of an entire compatibility check:&lt;/span&gt;&lt;/p&gt;&lt;pre&gt;&lt;span style="font-size:130%;"&gt;/* Wrapper function for constructing a request object.&lt;br /&gt;Parameters:&lt;br /&gt;reqType: The HTTP request type, such as GET or POST.&lt;br /&gt;url: The URL of the server program.&lt;br /&gt;asynch: Whether to send the request asynchronously or not. */&lt;br /&gt;&lt;br /&gt;function httpRequest(reqType,url,asynch){&lt;br /&gt;//Mozilla-based browsers&lt;br /&gt;if(window.XMLHttpRequest){&lt;br /&gt;    request = new XMLHttpRequest(  );&lt;br /&gt;} else if (window.ActiveXObject){&lt;br /&gt;    request=new ActiveXObject("Msxml2.XMLHTTP");&lt;br /&gt;    if (! request){&lt;br /&gt;        request=new ActiveXObject("Microsoft.XMLHTTP");&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;//the request could still be null if neither ActiveXObject&lt;br /&gt;//initialization succeeded&lt;br /&gt;if(request){&lt;br /&gt;    initReq(reqType,url,asynch);&lt;br /&gt;} else {&lt;br /&gt;    alert("Your browser does not permit the use of all "+&lt;br /&gt;          "of this application's features!");&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;/* Initialize a request object that is already constructed */&lt;br /&gt;function initReq(reqType,url,bool){&lt;br /&gt;/* Specify the function that will handle the HTTP response */&lt;br /&gt;request.onreadystatechange=handleResponse;&lt;br /&gt;request.open(reqType,url,bool);&lt;br /&gt;request.send(null);&lt;br /&gt;}&lt;/span&gt;&lt;/pre&gt;&lt;p class="docText"&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/ynBt/~4/nyBE4OeEDPg" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://purl.org/atom/app#">2009-02-12T18:30:08.131+05:30</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://dotnetfaqs-edu.blogspot.com/2009/02/listview-and-datapager.html</feedburner:origLink></item><item><title>Uploading files</title><link>http://feedproxy.google.com/~r/blogspot/ynBt/~3/FVJgunb3JJk/uploading-files.html</link><category>ASP.NET Articles</category><author>noreply@blogger.com (Tiru)</author><pubDate>Thu, 05 Feb 2009 08:00:44 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-6426652519813936980.post-1688619375073441464</guid><description>&lt;p&gt;While this article is placed in the upload subsection, it might not be the best place for ot. Because it's not a regular "how-to-upload- files-with-ASP.NET" article.&lt;br /&gt;&lt;br /&gt;I might write such an article in the future but this is dealning with a problem you might encounter when using some sort of template-system on your site. I mean basically, all requests goes to a single ASPX page, such as default.aspx and depending on the context (for example sent in by a request variable) you load different user controls (ASCX) files.&lt;br /&gt;&lt;br /&gt;For example:&lt;br /&gt;default.aspx?page=start - might show start page&lt;br /&gt;default.aspx?page=clientupload - might show a page when the client could upload a file to your server&lt;br /&gt;&lt;br /&gt;Now, back to file upload. To upload a file you need to do two things:&lt;br /&gt;1. Throw in a input type=file control &lt;/p&gt;&lt;pre&gt;&lt;code class="xml"&gt;&lt;br /&gt;&lt;br /&gt;&lt;input class="textbox" id="File1" type="file" name="fileUploaded1" runat="server"&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt; 2. Set your forms enctype to multipart/form-data &lt;pre&gt;&lt;span style="font-size:+1;color:#0000ff;"&gt;&lt;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt;&lt;strong&gt;form&lt;/strong&gt;&lt;/span&gt; enctype&lt;span style="font-size:+1;color:#0000ff;"&gt;=&lt;/span&gt;&lt;span style="color:#800080;"&gt;"multipart/form-data"&lt;/span&gt; runat&lt;span style="font-size:+1;color:#0000ff;"&gt;=&lt;/span&gt;&lt;span style="color:#800080;"&gt;"server"&lt;/span&gt;&lt;span style="font-size:+1;color:#0000ff;"&gt;&gt;&lt;/span&gt;&lt;span class="cch1"&gt;&lt;span style="color:#808080;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;Now what's the problem? Well some people might argue that it's no problem at all but the fact is that since you only have one single default.aspx file the form:s type will be always be multipart/form-data - even for the "start"-page. I won't get into that discussion but simple show you how to fix it&lt;br /&gt;&lt;br /&gt;Lets say that page=start loads the ucStart.ascx user control. And page=ucClientUpload loads ucClientUpload.ascx&lt;br /&gt;&lt;br /&gt;First remove the enctype="multipart/form-data" from the default.aspx form and open up ucClientUpload.ascx&lt;br /&gt;&lt;br /&gt;What we are gonna do is from within ucClientUpload.ascx change the form enctype attribute:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;code class="csharp"&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="keyword"&gt;protected&lt;/span&gt; &lt;span class="keyword"&gt;void&lt;/span&gt; EnsureEncType() &lt;br /&gt;{ &lt;br /&gt;    System.Web.UI.Control oParent = Parent; &lt;br /&gt;    &lt;span class="keyword"&gt;while&lt;/span&gt;( oParent != &lt;span class="keyword"&gt;null&lt;/span&gt; &amp;amp;&amp;amp; oParent.GetType() != &lt;span class="keyword"&gt;typeof&lt;/span&gt;( System.Web.UI.HtmlControls.HtmlForm ) &amp;amp;&amp;amp; oParent.GetType().FullName != &lt;span class="string"&gt;"System.Web.UI.Page"&lt;/span&gt; ) &lt;br /&gt;    { &lt;br /&gt;        oParent = oParent.Parent; &lt;br /&gt;    } &lt;br /&gt;    System.Web.UI.HtmlControls.HtmlForm oForm = oParent &lt;span class="keyword"&gt;as&lt;/span&gt; System.Web.UI.HtmlControls.HtmlForm; &lt;br /&gt;    &lt;span class="keyword"&gt;if&lt;/span&gt; ( oForm != &lt;span class="keyword"&gt;null&lt;/span&gt; ) &lt;br /&gt;    oForm.Enctype = &lt;span class="string"&gt;"multipart/form-data"&lt;/span&gt;; &lt;br /&gt;} &lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;And then just call EnsureEncType() from your Page_Load function. There you have it. Forms enctype set from within a usercontrol.&lt;br /&gt;&lt;br /&gt;I'll be honest with you and say I didn't find out this myself, but it has been in my "toolbox" for quite a while and now when writing this article I was trying to look up who did it, but came up with a lot of chinese pages when googling. Anyway, just saying that so you understand that I don't take any credit for the solution, just trying to spread it.&lt;img src="http://feeds.feedburner.com/~r/blogspot/ynBt/~4/FVJgunb3JJk" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://purl.org/atom/app#">2009-02-05T21:30:44.311+05:30</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://dotnetfaqs-edu.blogspot.com/2009/02/uploading-files.html</feedburner:origLink></item><item><title>Creating a demo version of your ASP.NET application</title><link>http://feedproxy.google.com/~r/blogspot/ynBt/~3/F0a2M_uMOVc/creating-demo-version-of-your-aspnet.html</link><category>ASP.NET Articles</category><author>noreply@blogger.com (Tiru)</author><pubDate>Thu, 05 Feb 2009 07:59:43 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-6426652519813936980.post-7618401634006541437</guid><description>&lt;p&gt;&lt;span style="font-size:100%;"&gt;&lt;span class="ArticleText"&gt; &lt;p&gt;Setting up a live demo on your website is often important for your business - people want to see how the application looks and get a feeling of it and not all people are willing to download a trial version and go through a (painful?) install process just to get the first look.&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;However, the problem is that you need to strip down the demo version a little bit. You don't want visitors to be able to change login password etc (after that noone would have access to the demo) or change information in your underlying database.&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;Here's how I have solved it for my demosites for AdMentor and KBMentor.&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;In short : I compile the application with an extra flag defined (DEMOVERSION) and in my code I insert some extra conditional code to behave differently when that flag DEMOVERSION is defined.&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;First step is to create a custom project context&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;&lt;img alt="" src="http://www.aspcode.net/UploadDir/guielements/demoversion2.png" width="486" height="317" /&gt;&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;Then we add the conditional variable (called DEMOVERSION):&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;&lt;img alt="" src="http://www.aspcode.net/UploadDir/guielements/demoversion3.png" width="646" height="445" /&gt;&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;Now we can insert some conditional code.We do that by using the #if directive in our code. &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;/span&gt;&lt;/span&gt; &lt;/p&gt;&lt;pre&gt;&lt;span style="font-size:100%;"&gt;&lt;span class="cch1"&gt;&lt;span style="color:#808080;"&gt;#if (DEMOVERSION)&lt;br /&gt;here we can add code which only will be compiled in the special demoversion&lt;br /&gt;#endif&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt; &lt;pre&gt;&lt;span style="font-size:100%;"&gt;&lt;span class="cch1"&gt;&lt;span style="color:#808080;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt; &lt;p&gt;&lt;span style="font-size:100%;"&gt;I want to throw up a JavaScript when the user tries something not allowed - for example when trying to change password: &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:100%;"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:100%;"&gt;&lt;img alt="" src="http://www.aspcode.net/UploadDir/guielements/demoversion4.png" width="616" height="330" /&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:100%;"&gt;So, this is done by adding a JavaScript alert box to the onclick event:&lt;br /&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:100%;"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:100%;"&gt; &lt;/span&gt;&lt;/p&gt; &lt;pre&gt;&lt;span style="font-size:100%;"&gt;&lt;span class="cch1"&gt;&lt;span style="color:#808080;"&gt;private void Page_Load(object sender, System.EventArgs e)&lt;br /&gt;{&lt;br /&gt; EnsureEncType();&lt;br /&gt; EnsureChildControls();&lt;br /&gt; if ( !IsPostBack )&lt;br /&gt; {&lt;br /&gt;&lt;br /&gt;#if (DEMOVERSION)&lt;br /&gt; btnUpdate.Attributes.Add("onclick", "alert('Not possible in demo version'); return false;");&lt;br /&gt; btnDelete.Attributes["onclick"] =  "alert('Not possible in demo version'); return false;";&lt;br /&gt;#endif&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;span style="font-size:100%;"&gt; Now, this is done in Page_Load and while this example is pretty easy to understand you might have a more finegrained structure of how to enable/disbale controls, for example based on current user rights, and/or after a lot of postbacks a certain button might be enabled etc. The easiest way to override such code without needing to make the original code much more complex is to leave it at is and make your changes in OnPreRender: &lt;/span&gt;&lt;pre&gt;&lt;span style="font-size:100%;"&gt;&lt;span class="cch1"&gt;&lt;span style="color:#808080;"&gt;protected override void OnPreRender(EventArgs e)&lt;br /&gt;{&lt;br /&gt;#if (DEMOVERSION)&lt;br /&gt;btnDelete.Enabled = false;&lt;br /&gt;btnDoUpload.Enabled = false;&lt;br /&gt;btnOK.Enabled = false;&lt;br /&gt;#endif&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;span style="font-size:100%;"&gt;Here it doesn't matter what code has been executed and checked against all different kind of state - we just disable the buttons regardless of which. Now, the last thing to do. Not all people have JavaScript enabled - so those people must also be stopped. Here we need to add some serverside code in the actual handler functions: &lt;/span&gt;&lt;pre&gt;&lt;span style="font-size:100%;"&gt;&lt;span class="cch1"&gt;&lt;span style="color:#808080;"&gt;private void btnOK_Click(object sender, System.EventArgs e)&lt;br /&gt;{&lt;br /&gt;#if (DEMOVERSION)&lt;br /&gt; return;&lt;br /&gt;#endif&lt;br /&gt;&lt;br /&gt;..regular code to save etc&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/ynBt/~4/F0a2M_uMOVc" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://purl.org/atom/app#">2009-02-05T21:29:43.879+05:30</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://dotnetfaqs-edu.blogspot.com/2009/02/creating-demo-version-of-your-aspnet.html</feedburner:origLink></item><item><title>Screenscraping with HttpWebRequest</title><link>http://feedproxy.google.com/~r/blogspot/ynBt/~3/uLGcoADyxu8/screenscraping-with-httpwebrequest.html</link><category>ASP.NET Articles</category><author>noreply@blogger.com (Tiru)</author><pubDate>Thu, 05 Feb 2009 07:58:38 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-6426652519813936980.post-8494671487313863399</guid><description>While I bet you all know how to (from your own webpage) read another webpage, even located on another site/server, so while I will show you the code for it, I also want to show you a very practical use of it.&lt;br /&gt;&lt;br /&gt;Background&lt;br /&gt;&lt;br /&gt;As you might have seen I have created a new layout for this site, ASPCode.net. I am using the beta version of KBMentor but that's not what I want to talk about here. However, for reasons I won't get into, I wanted to create the site in directory aspcode.net/articles/ and therefore I naturally created a vdir (own application) in the articles drectory and thereaftter installed my KBMentor CMS.&lt;br /&gt;&lt;br /&gt;Problem&lt;br /&gt;&lt;br /&gt;One of the functions of KBMentor is to produce a Google SiteMap out of all the articles and pages. So I wanted to test it out - but ran into a big problem. The page to submit to Google SItemap is http://www.aspcode.net/articles/googl...map.ashx - but it wouldn't let me - simply because it is not located in the root of my domain. Moving the ashx page to the root wouldn't help at all, simply because another application is installed in that location.&lt;br /&gt;&lt;br /&gt;Solution&lt;br /&gt;&lt;br /&gt;Now to the solution. I did add a new ashx page in the root domain - and what is does is simply "screenscrape" the ashx file in the articles directory.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;  public void ProcessRequest (HttpContext context)&lt;br /&gt;  {  &lt;br /&gt;   //Screenscrape&lt;br /&gt;   CookieContainer CC = new CookieContainer();&lt;br /&gt;&lt;br /&gt;   HttpWebRequest Req = (HttpWebRequest) WebRequest.Create("http://www.aspcode.net/articles/googlesitemap.ashx");&lt;br /&gt;   Req.CookieContainer = CC;&lt;br /&gt;&lt;br /&gt;   WebResponse webResponse = Req.GetResponse();&lt;br /&gt;   string sTxt = new System.IO.StreamReader(webResponse.GetResponseStream(),&lt;br /&gt;    System.Text.Encoding.Default).ReadToEnd();&lt;br /&gt;   webResponse.Close();&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;   context.Response.ContentType = "text/xml";&lt;br /&gt;   context.Response.ContentEncoding = System.Text.Encoding.UTF8;&lt;br /&gt;   context.Response.Write( sTxt);&lt;br /&gt;&lt;br /&gt;   //&lt;br /&gt;   // TODO: Add constructor logic here&lt;br /&gt;   //&lt;br /&gt;  }&lt;img src="http://feeds.feedburner.com/~r/blogspot/ynBt/~4/uLGcoADyxu8" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://purl.org/atom/app#">2009-02-05T21:28:38.771+05:30</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://dotnetfaqs-edu.blogspot.com/2009/02/screenscraping-with-httpwebrequest.html</feedburner:origLink></item><item><title>ASP.NET 301 redirect</title><link>http://feedproxy.google.com/~r/blogspot/ynBt/~3/oCYGQrcc1ko/aspnet-301-redirect.html</link><category>ASP.NET Articles</category><author>noreply@blogger.com (Tiru)</author><pubDate>Thu, 05 Feb 2009 07:57:47 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-6426652519813936980.post-5538149831470557090</guid><description>When moving your pages from one place to another it is very tempting to handle old inlinks by creating a simple Response.Redirect( sNewPage, true );&lt;br /&gt;&lt;br /&gt;This sure will work, but this type of redirect is a 302 and is meant for temporary relocations of pages. But your pages are permanently moved and therefore you should use a 301 Moved Permanently status code. This should preserve your search engine rankings for that particular page.&lt;br /&gt;&lt;br /&gt;To solve it you could install some sort of redirect filter(ISAPI dll). I was looking into those type of solutions and found IISMods URL Rewrite Filter for IIS.&lt;br /&gt;&lt;br /&gt;Such a solution is very flexible and since it is a IIS filter it is possible to rewrite URL:s for all kind of filetypes, not only for aspx pages but say images (ex http://www.hello.com/*.gif could be transferred to http://www.hello.com/test/*gif ).&lt;br /&gt;&lt;br /&gt;It is however not possible for everyone to install a ISAPI filter on their website, therefore I here present a solution on how you can achieve 301 redirects with pure ASP.NET code instead.&lt;br /&gt;&lt;br /&gt; In your old page you can write code such as&lt;br /&gt;&lt;br /&gt;private void Page_Load(object sender, System.EventArgs e)&lt;br /&gt;{&lt;br /&gt; Response.Status = "301 Moved Permanently";&lt;br /&gt; Response.AddHeader("Location","http://www.aspcode.net/newpage");&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;For me who wanted to redirect all calls to http://kbmentor.aspcode.net/whatever/it/could/be/foo.aspx to http://www.aspcode.net/articles/whatever/it/could/be/foo.aspx took and didn't have to think about pictures, cause they were "base" linked with the application took the idea one step further.&lt;br /&gt;&lt;br /&gt;I created a new web application to install on kbmentor.aspcode.net. Basically it only contains a global.asax which handles Application_BeginRequest like this:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;  protected void Application_BeginRequest(Object sender, EventArgs e)&lt;br /&gt;  {&lt;br /&gt;   string sOldPath = HttpContext.Current.Request.Path.ToLower();&lt;br /&gt;   &lt;br /&gt;&lt;br /&gt;   string sPage = "http://www.aspcode.net/articles/" + sOldPath;&lt;br /&gt;   Response.Clear();&lt;br /&gt;   Response.Status = "301 Moved Permanently";&lt;br /&gt;   Response.AddHeader("Location",sPage);&lt;br /&gt;   Response.End();&lt;br /&gt;  }&lt;img src="http://feeds.feedburner.com/~r/blogspot/ynBt/~4/oCYGQrcc1ko" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://purl.org/atom/app#">2009-02-05T21:27:47.353+05:30</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://dotnetfaqs-edu.blogspot.com/2009/02/aspnet-301-redirect.html</feedburner:origLink></item><item><title>ASP.NET - caching control</title><link>http://feedproxy.google.com/~r/blogspot/ynBt/~3/jSd1Z94Xqrc/aspnet-caching-control.html</link><category>ASP.NET Articles</category><author>noreply@blogger.com (Tiru)</author><pubDate>Thu, 05 Feb 2009 07:53:33 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-6426652519813936980.post-2953654160706347612</guid><description>The ASP.NET cache is simply fantastic, but there are some shortcomings. While it is so easy to create a cache item dependent on, say for example a XML file (meaning the cache item will expire when the file xxx.xml is changed) it is not so common for such scenarios in my opinion. Also, now in .NET 2.0 you can create SqlCacheDependencys, meaning an cached item will be expired (and therefore a fresh read fromthe database will be executed) when something in the database is changed (could be set on query level actually).&lt;br /&gt;&lt;br /&gt;However, to me such solutions are so much overkill, lots of overhead and also (for SqlCacheDependency ) you tie your solution pretty much to SQL 2005.&lt;br /&gt;Most often you just want to cache some data in your application, example&lt;br /&gt;&lt;br /&gt;string sTxt = "";&lt;br /&gt;if ( context.Cache["RSSFEED123"] == null )&lt;br /&gt;{&lt;br /&gt; sTxt = BuildXmlString(context);&lt;br /&gt; context.Cache.Insert( "RSSFEED123", sTxt, ..some depencency object... );&lt;br /&gt;}&lt;br /&gt;else&lt;br /&gt; sTxt = context.Cache["RSSFEED123"].ToString();&lt;br /&gt;&lt;br /&gt;work with txt...&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;My point is that most often YOU have the control of knowing when the Cache item should expire. In 99.99% of my cases it should trigger when an administrator enters a new/changes an existing article or whatever in the admin GUI.&lt;br /&gt;So, my solution (here I show it with no cachedependency at all, living for the lifetime of the whole application) but you can of course use it in conjunction with a cachedependency.&lt;br /&gt;&lt;br /&gt;Code using it:&lt;br /&gt;&lt;br /&gt;string sTxt = "";&lt;br /&gt;if ( context.Cache["RSSFEED123"] == null )&lt;br /&gt;{&lt;br /&gt; sTxt = BuildXmlString(context);&lt;br /&gt; context.Cache.Insert( "RSSFEED123", sTxt );&lt;br /&gt;}&lt;br /&gt;else&lt;br /&gt; sTxt = context.Cache["RSSFEED123"].ToString();&lt;br /&gt;&lt;br /&gt;Admin GUI:&lt;br /&gt;&lt;br /&gt;private void btnUpdate_Click(object sender, System.EventArgs e)&lt;br /&gt;{&lt;br /&gt; //Save to database, then call global static function&lt;br /&gt; HelpClasses.Context.InvalidateAllCache();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;HelpClasses.Context:&lt;br /&gt;&lt;br /&gt;public static void InvalidateAllCache()&lt;br /&gt;{&lt;br /&gt; if ( System.Web.HttpContext.Current.Cache["RSSFEED123"] != null )&lt;br /&gt;  System.Web.HttpContext.Current.Cache.Remove("RSSFEED123");&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;So inessence, when the administrator clicks the Save button we go to HelpClasses.Context.InvalidateAllCache() and it simply removes the item(s) from the cache.&lt;br /&gt;&lt;br /&gt;I know I could maybe create a specialized cache dependency class derived from CacheDependency - but then the problem is that the GUI needs to communicate with it. I always take the easy way out, cause in the end it is all about delivering a working solution for the customer - not creating the most .NETed solution possible :)&lt;img src="http://feeds.feedburner.com/~r/blogspot/ynBt/~4/jSd1Z94Xqrc" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://purl.org/atom/app#">2009-02-05T21:23:33.810+05:30</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://dotnetfaqs-edu.blogspot.com/2009/02/aspnet-caching-control.html</feedburner:origLink></item><item><title>List of Request.ServerVariables</title><link>http://feedproxy.google.com/~r/blogspot/ynBt/~3/4WZs5mpidwY/list-of-requestservervariables.html</link><category>ASP.NET Articles</category><author>noreply@blogger.com (Tiru)</author><pubDate>Thu, 05 Feb 2009 07:49:18 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-6426652519813936980.post-4170709839851624947</guid><description>I'm publishing this list for my own sake actually, never seem to remember which variable gives you what. Sourcecode and description behind the scenes to generate this table is available in Related articles.&lt;br /&gt;&lt;span class="ArticleText"&gt;&lt;br /&gt;&lt;table id="GridView1" style="border-collapse: collapse;" rules="all" border="1" cellspacing="0"&gt;     &lt;tbody&gt;         &lt;tr&gt;             &lt;th scope="col"&gt;&lt;br /&gt;&lt;/th&gt;             &lt;th scope="col"&gt;&lt;br /&gt;&lt;/th&gt;         &lt;/tr&gt;         &lt;tr&gt;             &lt;td&gt;&lt;span id="GridView1_ctl02_lblName"&gt;ALL_HTTP&lt;/span&gt; &lt;/td&gt;             &lt;td&gt;&lt;span id="GridView1_ctl02_lblValue"&gt;HTTP_CONNECTION:Keep-Alive HTTP_ACCEPT:*/* HTTP_ACCEPT_ENCODING:gzip, deflate HTTP_ACCEPT_LANGUAGE:sv HTTP_HOST:localhost:1229 HTTP_USER_AGENT:Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; InfoPath.1) &lt;/span&gt;&lt;/td&gt;         &lt;/tr&gt;         &lt;tr&gt;             &lt;td&gt;&lt;span id="GridView1_ctl03_lblName"&gt;ALL_RAW&lt;/span&gt; &lt;/td&gt;             &lt;td&gt;&lt;span id="GridView1_ctl03_lblValue"&gt;Connection: Keep-Alive Accept: */* Accept-Encoding: gzip, deflate Accept-Language: sv Host: localhost:1229 User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; InfoPath.1) &lt;/span&gt;&lt;/td&gt;         &lt;/tr&gt;         &lt;tr&gt;             &lt;td&gt;&lt;span id="GridView1_ctl04_lblName"&gt;APPL_MD_PATH&lt;/span&gt; &lt;/td&gt;             &lt;td&gt;&lt;span id="GridView1_ctl04_lblValue"&gt;&lt;/span&gt;&lt;br /&gt;&lt;/td&gt;         &lt;/tr&gt;         &lt;tr&gt;             &lt;td&gt;&lt;span id="GridView1_ctl05_lblName"&gt;APPL_PHYSICAL_PATH&lt;/span&gt; &lt;/td&gt;             &lt;td&gt;&lt;span id="GridView1_ctl05_lblValue"&gt;D:\code\web\demos\membership\&lt;/span&gt; &lt;/td&gt;         &lt;/tr&gt;         &lt;tr&gt;             &lt;td&gt;&lt;span id="GridView1_ctl06_lblName"&gt;AUTH_TYPE&lt;/span&gt; &lt;/td&gt;             &lt;td&gt;&lt;span id="GridView1_ctl06_lblValue"&gt;NTLM&lt;/span&gt; &lt;/td&gt;         &lt;/tr&gt;         &lt;tr&gt;             &lt;td&gt;&lt;span id="GridView1_ctl07_lblName"&gt;AUTH_USER&lt;/span&gt; &lt;/td&gt;             &lt;td&gt;&lt;span id="GridView1_ctl07_lblValue"&gt;SYSTEMEN-D9AE02\Stefan Holmberg&lt;/span&gt; &lt;/td&gt;         &lt;/tr&gt;         &lt;tr&gt;             &lt;td&gt;&lt;span id="GridView1_ctl08_lblName"&gt;AUTH_PASSWORD&lt;/span&gt; &lt;/td&gt;             &lt;td&gt;&lt;span id="GridView1_ctl08_lblValue"&gt;&lt;/span&gt;&lt;br /&gt;&lt;/td&gt;         &lt;/tr&gt;         &lt;tr&gt;             &lt;td&gt;&lt;span id="GridView1_ctl09_lblName"&gt;LOGON_USER&lt;/span&gt; &lt;/td&gt;             &lt;td&gt;&lt;span id="GridView1_ctl09_lblValue"&gt;SYSTEMEN-D9AE02\Stefan Holmberg&lt;/span&gt; &lt;/td&gt;         &lt;/tr&gt;         &lt;tr&gt;             &lt;td&gt;&lt;span id="GridView1_ctl10_lblName"&gt;REMOTE_USER&lt;/span&gt; &lt;/td&gt;             &lt;td&gt;&lt;span id="GridView1_ctl10_lblValue"&gt;SYSTEMEN-D9AE02\Stefan Holmberg&lt;/span&gt; &lt;/td&gt;         &lt;/tr&gt;         &lt;tr&gt;             &lt;td&gt;&lt;span id="GridView1_ctl11_lblName"&gt;CERT_COOKIE&lt;/span&gt; &lt;/td&gt;             &lt;td&gt;&lt;span id="GridView1_ctl11_lblValue"&gt;&lt;/span&gt;&lt;br /&gt;&lt;/td&gt;         &lt;/tr&gt;         &lt;tr&gt;             &lt;td&gt;&lt;span id="GridView1_ctl12_lblName"&gt;CERT_FLAGS&lt;/span&gt; &lt;/td&gt;             &lt;td&gt;&lt;span id="GridView1_ctl12_lblValue"&gt;&lt;/span&gt;&lt;br /&gt;&lt;/td&gt;         &lt;/tr&gt;         &lt;tr&gt;             &lt;td&gt;&lt;span id="GridView1_ctl13_lblName"&gt;CERT_ISSUER&lt;/span&gt; &lt;/td&gt;             &lt;td&gt;&lt;span id="GridView1_ctl13_lblValue"&gt;&lt;/span&gt;&lt;br /&gt;&lt;/td&gt;         &lt;/tr&gt;         &lt;tr&gt;             &lt;td&gt;&lt;span id="GridView1_ctl14_lblName"&gt;CERT_KEYSIZE&lt;/span&gt; &lt;/td&gt;             &lt;td&gt;&lt;span id="GridView1_ctl14_lblValue"&gt;&lt;/span&gt;&lt;br /&gt;&lt;/td&gt;         &lt;/tr&gt;         &lt;tr&gt;             &lt;td&gt;&lt;span id="GridView1_ctl15_lblName"&gt;CERT_SECRETKEYSIZE&lt;/span&gt; &lt;/td&gt;             &lt;td&gt;&lt;span id="GridView1_ctl15_lblValue"&gt;&lt;/span&gt;&lt;br /&gt;&lt;/td&gt;         &lt;/tr&gt;         &lt;tr&gt;             &lt;td&gt;&lt;span id="GridView1_ctl16_lblName"&gt;CERT_SERIALNUMBER&lt;/span&gt; &lt;/td&gt;             &lt;td&gt;&lt;span id="GridView1_ctl16_lblValue"&gt;&lt;/span&gt;&lt;br /&gt;&lt;/td&gt;         &lt;/tr&gt;         &lt;tr&gt;             &lt;td&gt;&lt;span id="GridView1_ctl17_lblName"&gt;CERT_SERVER_ISSUER&lt;/span&gt; &lt;/td&gt;             &lt;td&gt;&lt;span id="GridView1_ctl17_lblValue"&gt;&lt;/span&gt;&lt;br /&gt;&lt;/td&gt;         &lt;/tr&gt;         &lt;tr&gt;             &lt;td&gt;&lt;span id="GridView1_ctl18_lblName"&gt;CERT_SERVER_SUBJECT&lt;/span&gt; &lt;/td&gt;             &lt;td&gt;&lt;span id="GridView1_ctl18_lblValue"&gt;&lt;/span&gt;&lt;br /&gt;&lt;/td&gt;         &lt;/tr&gt;         &lt;tr&gt;             &lt;td&gt;&lt;span id="GridView1_ctl19_lblName"&gt;CERT_SUBJECT&lt;/span&gt; &lt;/td&gt;             &lt;td&gt;&lt;span id="GridView1_ctl19_lblValue"&gt;&lt;/span&gt;&lt;br /&gt;&lt;/td&gt;         &lt;/tr&gt;         &lt;tr&gt;             &lt;td&gt;&lt;span id="GridView1_ctl20_lblName"&gt;CONTENT_LENGTH&lt;/span&gt; &lt;/td&gt;             &lt;td&gt;&lt;span id="GridView1_ctl20_lblValue"&gt;0&lt;/span&gt; &lt;/td&gt;         &lt;/tr&gt;         &lt;tr&gt;             &lt;td&gt;&lt;span id="GridView1_ctl21_lblName"&gt;CONTENT_TYPE&lt;/span&gt; &lt;/td&gt;             &lt;td&gt;&lt;span id="GridView1_ctl21_lblValue"&gt;&lt;/span&gt;&lt;br /&gt;&lt;/td&gt;         &lt;/tr&gt;         &lt;tr&gt;             &lt;td&gt;&lt;span id="GridView1_ctl22_lblName"&gt;GATEWAY_INTERFACE&lt;/span&gt; &lt;/td&gt;             &lt;td&gt;&lt;span id="GridView1_ctl22_lblValue"&gt;&lt;/span&gt;&lt;br /&gt;&lt;/td&gt;         &lt;/tr&gt;         &lt;tr&gt;             &lt;td&gt;&lt;span id="GridView1_ctl23_lblName"&gt;HTTPS&lt;/span&gt; &lt;/td&gt;             &lt;td&gt;&lt;span id="GridView1_ctl23_lblValue"&gt;&lt;/span&gt;&lt;br /&gt;&lt;/td&gt;         &lt;/tr&gt;         &lt;tr&gt;             &lt;td&gt;&lt;span id="GridView1_ctl24_lblName"&gt;HTTPS_KEYSIZE&lt;/span&gt; &lt;/td&gt;             &lt;td&gt;&lt;span id="GridView1_ctl24_lblValue"&gt;&lt;/span&gt;&lt;br /&gt;&lt;/td&gt;         &lt;/tr&gt;         &lt;tr&gt;             &lt;td&gt;&lt;span id="GridView1_ctl25_lblName"&gt;HTTPS_SECRETKEYSIZE&lt;/span&gt; &lt;/td&gt;             &lt;td&gt;&lt;span id="GridView1_ctl25_lblValue"&gt;&lt;/span&gt;&lt;br /&gt;&lt;/td&gt;         &lt;/tr&gt;         &lt;tr&gt;             &lt;td&gt;&lt;span id="GridView1_ctl26_lblName"&gt;HTTPS_SERVER_ISSUER&lt;/span&gt; &lt;/td&gt;             &lt;td&gt;&lt;span id="GridView1_ctl26_lblValue"&gt;&lt;/span&gt;&lt;br /&gt;&lt;/td&gt;         &lt;/tr&gt;         &lt;tr&gt;             &lt;td&gt;&lt;span id="GridView1_ctl27_lblName"&gt;HTTPS_SERVER_SUBJECT&lt;/span&gt; &lt;/td&gt;             &lt;td&gt;&lt;span id="GridView1_ctl27_lblValue"&gt;&lt;/span&gt;&lt;br /&gt;&lt;/td&gt;         &lt;/tr&gt;         &lt;tr&gt;             &lt;td&gt;&lt;span id="GridView1_ctl28_lblName"&gt;INSTANCE_ID&lt;/span&gt; &lt;/td&gt;             &lt;td&gt;&lt;span id="GridView1_ctl28_lblValue"&gt;&lt;/span&gt;&lt;br /&gt;&lt;/td&gt;         &lt;/tr&gt;         &lt;tr&gt;             &lt;td&gt;&lt;span id="GridView1_ctl29_lblName"&gt;INSTANCE_META_PATH&lt;/span&gt; &lt;/td&gt;             &lt;td&gt;&lt;span id="GridView1_ctl29_lblValue"&gt;&lt;/span&gt;&lt;br /&gt;&lt;/td&gt;         &lt;/tr&gt;         &lt;tr&gt;             &lt;td&gt;&lt;span id="GridView1_ctl30_lblName"&gt;LOCAL_ADDR&lt;/span&gt; &lt;/td&gt;             &lt;td&gt;&lt;span id="GridView1_ctl30_lblValue"&gt;127.0.0.1&lt;/span&gt; &lt;/td&gt;         &lt;/tr&gt;         &lt;tr&gt;             &lt;td&gt;&lt;span id="GridView1_ctl31_lblName"&gt;PATH_INFO&lt;/span&gt; &lt;/td&gt;             &lt;td&gt;&lt;span id="GridView1_ctl31_lblValue"&gt;/membership/servervariables.aspx&lt;/span&gt; &lt;/td&gt;         &lt;/tr&gt;         &lt;tr&gt;             &lt;td&gt;&lt;span id="GridView1_ctl32_lblName"&gt;PATH_TRANSLATED&lt;/span&gt; &lt;/td&gt;             &lt;td&gt;&lt;span id="GridView1_ctl32_lblValue"&gt;D:\code\web\demos\membership\servervariables.aspx&lt;/span&gt; &lt;/td&gt;         &lt;/tr&gt;         &lt;tr&gt;             &lt;td&gt;&lt;span id="GridView1_ctl33_lblName"&gt;QUERY_STRING&lt;/span&gt; &lt;/td&gt;             &lt;td&gt;&lt;span id="GridView1_ctl33_lblValue"&gt;&lt;/span&gt;&lt;br /&gt;&lt;/td&gt;         &lt;/tr&gt;         &lt;tr&gt;             &lt;td&gt;&lt;span id="GridView1_ctl34_lblName"&gt;REMOTE_ADDR&lt;/span&gt; &lt;/td&gt;             &lt;td&gt;&lt;span id="GridView1_ctl34_lblValue"&gt;127.0.0.1&lt;/span&gt; &lt;/td&gt;         &lt;/tr&gt;         &lt;tr&gt;             &lt;td&gt;&lt;span id="GridView1_ctl35_lblName"&gt;REMOTE_HOST&lt;/span&gt; &lt;/td&gt;             &lt;td&gt;&lt;span id="GridView1_ctl35_lblValue"&gt;127.0.0.1&lt;/span&gt; &lt;/td&gt;         &lt;/tr&gt;         &lt;tr&gt;             &lt;td&gt;&lt;span id="GridView1_ctl36_lblName"&gt;REMOTE_PORT&lt;/span&gt; &lt;/td&gt;             &lt;td&gt;&lt;span id="GridView1_ctl36_lblValue"&gt;&lt;/span&gt;&lt;br /&gt;&lt;/td&gt;         &lt;/tr&gt;         &lt;tr&gt;             &lt;td&gt;&lt;span id="GridView1_ctl37_lblName"&gt;REQUEST_METHOD&lt;/span&gt; &lt;/td&gt;             &lt;td&gt;&lt;span id="GridView1_ctl37_lblValue"&gt;GET&lt;/span&gt; &lt;/td&gt;         &lt;/tr&gt;         &lt;tr&gt;             &lt;td&gt;&lt;span id="GridView1_ctl38_lblName"&gt;SCRIPT_NAME&lt;/span&gt; &lt;/td&gt;             &lt;td&gt;&lt;span id="GridView1_ctl38_lblValue"&gt;/membership/servervariables.aspx&lt;/span&gt; &lt;/td&gt;         &lt;/tr&gt;         &lt;tr&gt;             &lt;td&gt;&lt;span id="GridView1_ctl39_lblName"&gt;SERVER_NAME&lt;/span&gt; &lt;/td&gt;             &lt;td&gt;&lt;span id="GridView1_ctl39_lblValue"&gt;localhost&lt;/span&gt; &lt;/td&gt;         &lt;/tr&gt;         &lt;tr&gt;             &lt;td&gt;&lt;span id="GridView1_ctl40_lblName"&gt;SERVER_PORT&lt;/span&gt; &lt;/td&gt;             &lt;td&gt;&lt;span id="GridView1_ctl40_lblValue"&gt;1229&lt;/span&gt; &lt;/td&gt;         &lt;/tr&gt;         &lt;tr&gt;             &lt;td&gt;&lt;span id="GridView1_ctl41_lblName"&gt;SERVER_PORT_SECURE&lt;/span&gt; &lt;/td&gt;             &lt;td&gt;&lt;span id="GridView1_ctl41_lblValue"&gt;0&lt;/span&gt; &lt;/td&gt;         &lt;/tr&gt;         &lt;tr&gt;             &lt;td&gt;&lt;span id="GridView1_ctl42_lblName"&gt;SERVER_PROTOCOL&lt;/span&gt; &lt;/td&gt;             &lt;td&gt;&lt;span id="GridView1_ctl42_lblValue"&gt;HTTP/1.1&lt;/span&gt; &lt;/td&gt;         &lt;/tr&gt;         &lt;tr&gt;             &lt;td&gt;&lt;span id="GridView1_ctl43_lblName"&gt;SERVER_SOFTWARE&lt;/span&gt; &lt;/td&gt;             &lt;td&gt;&lt;span id="GridView1_ctl43_lblValue"&gt;&lt;/span&gt;&lt;br /&gt;&lt;/td&gt;         &lt;/tr&gt;         &lt;tr&gt;             &lt;td&gt;&lt;span id="GridView1_ctl44_lblName"&gt;URL&lt;/span&gt; &lt;/td&gt;             &lt;td&gt;&lt;span id="GridView1_ctl44_lblValue"&gt;/membership/servervariables.aspx&lt;/span&gt; &lt;/td&gt;         &lt;/tr&gt;         &lt;tr&gt;             &lt;td&gt;&lt;span id="GridView1_ctl45_lblName"&gt;HTTP_CONNECTION&lt;/span&gt; &lt;/td&gt;             &lt;td&gt;&lt;span id="GridView1_ctl45_lblValue"&gt;Keep-Alive&lt;/span&gt; &lt;/td&gt;         &lt;/tr&gt;         &lt;tr&gt;             &lt;td&gt;&lt;span id="GridView1_ctl46_lblName"&gt;HTTP_ACCEPT&lt;/span&gt; &lt;/td&gt;             &lt;td&gt;&lt;span id="GridView1_ctl46_lblValue"&gt;*/*&lt;/span&gt; &lt;/td&gt;         &lt;/tr&gt;         &lt;tr&gt;             &lt;td&gt;&lt;span id="GridView1_ctl47_lblName"&gt;HTTP_ACCEPT_ENCODING&lt;/span&gt; &lt;/td&gt;             &lt;td&gt;&lt;span id="GridView1_ctl47_lblValue"&gt;gzip, deflate&lt;/span&gt; &lt;/td&gt;         &lt;/tr&gt;         &lt;tr&gt;             &lt;td&gt;&lt;span id="GridView1_ctl48_lblName"&gt;HTTP_ACCEPT_LANGUAGE&lt;/span&gt; &lt;/td&gt;             &lt;td&gt;&lt;span id="GridView1_ctl48_lblValue"&gt;sv&lt;/span&gt; &lt;/td&gt;         &lt;/tr&gt;         &lt;tr&gt;             &lt;td&gt;&lt;span id="GridView1_ctl49_lblName"&gt;HTTP_HOST&lt;/span&gt; &lt;/td&gt;             &lt;td&gt;&lt;span id="GridView1_ctl49_lblValue"&gt;localhost:1229&lt;/span&gt; &lt;/td&gt;         &lt;/tr&gt;         &lt;tr&gt;             &lt;td&gt;&lt;span id="GridView1_ctl50_lblName"&gt;HTTP_USER_AGENT&lt;/span&gt; &lt;/td&gt;             &lt;td&gt;&lt;span id="GridView1_ctl50_lblValue"&gt;Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; InfoPath.1)&lt;/span&gt; &lt;/td&gt;         &lt;/tr&gt;     &lt;/tbody&gt; &lt;/table&gt; &lt;/span&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/ynBt/~4/4WZs5mpidwY" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://purl.org/atom/app#">2009-02-05T21:19:18.498+05:30</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://dotnetfaqs-edu.blogspot.com/2009/02/list-of-requestservervariables.html</feedburner:origLink></item><item><title>Last second HTML changes in your ASP.NET page</title><link>http://feedproxy.google.com/~r/blogspot/ynBt/~3/tcgwPYbvDvM/last-second-html-changes-in-your-aspnet.html</link><category>ASP.NET Articles</category><author>noreply@blogger.com (Tiru)</author><pubDate>Thu, 05 Feb 2009 07:46:45 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-6426652519813936980.post-6493665054292572952</guid><description>&lt;p&gt;&lt;span class="ArticleText"&gt;&lt;span class="ArticleText"&gt;&lt;span class="ArticleText"&gt;&lt;span class="ArticleText"&gt; &lt;p&gt;While this solution might seems a little odd (or more correctly the problem might seem very odd) but this technique has sure solved a lot of problems for me.&lt;/p&gt; &lt;p&gt;What I'm gonna show you is a was to manipulate the resulting HTML and ASP.NET page has generated just before it's sent to the browser. &lt;/p&gt; &lt;p&gt;Now you might ask, isn't that what ASP Server controls are made for? To generate the HTML for you?  Because there are certain times when the HTML or JavaScript it generates are not right and you might even not (if using a third party control) be able to modify the underlying control generating the code.&lt;/p&gt; &lt;p&gt;For example I've had problems with some thirdparty components where I was unable to get it to render the correct paths for including images etc (it simply couldn't point to the specific location I had them stored).&lt;/p&gt; &lt;p&gt;So, the plan is to somehow intercept the rendering, make my modifications to the HTML generated and then just pass my modified copy on to the browser.&lt;br /&gt;&lt;/p&gt; &lt;p&gt;One other example (which I actually have used in some projects) is to create some sort of "template replacer", where others can create their own templates and also write some special tags that your application is supposed to replace with some meaningful - for example&lt;br /&gt;$currentarticle_name might be replaced with&lt;br /&gt;the name of the current article (the one the user is browsing)&lt;/p&gt; &lt;p&gt;Thats the type of example I am gonna show you, consider this layout:&lt;/p&gt; &lt;p&gt;&lt;img alt="" src="http://www.aspcode.net/articles/UploadDir/guielements/write1.png" width="239" border="1" height="99" /&gt;&lt;/p&gt; &lt;p&gt;Now, we are supposed to replace the $CURRENT_DATETIME text with current date and time.&lt;/p&gt; &lt;p&gt;I.e we want this result when running:&lt;/p&gt; &lt;p&gt;&lt;br /&gt;&lt;img alt="" src="http://www.aspcode.net/articles/UploadDir/guielements/write2.png" width="239" border="1" height="99" /&gt;&lt;/p&gt; &lt;p&gt;So first the code - all the magic happens in Render:&lt;br /&gt;&lt;/p&gt; &lt;pre&gt;&lt;code class="csharp"&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="keyword"&gt;protected&lt;/span&gt; &lt;span class="keyword"&gt;override&lt;/span&gt; &lt;span class="keyword"&gt;void&lt;/span&gt; Render(HtmlTextWriter writer)&lt;br /&gt;{&lt;br /&gt;    &lt;span class="keyword"&gt;using&lt;/span&gt;(System.IO.MemoryStream msOur = &lt;span class="keyword"&gt;new&lt;/span&gt; System.IO.MemoryStream())&lt;br /&gt;    {&lt;br /&gt;        &lt;span class="keyword"&gt;using&lt;/span&gt;(System.IO.StreamWriter swOur = &lt;span class="keyword"&gt;new&lt;/span&gt; System.IO.StreamWriter(msOur))&lt;br /&gt;        {&lt;br /&gt;            HtmlTextWriter ourWriter = &lt;span class="keyword"&gt;new&lt;/span&gt; HtmlTextWriter(swOur);&lt;br /&gt;            &lt;span class="keyword"&gt;base&lt;/span&gt;.Render(ourWriter);&lt;br /&gt;            ourWriter.Flush();&lt;br /&gt;            msOur.Position = &lt;span class="number"&gt;0&lt;/span&gt;;&lt;br /&gt;            &lt;span class="keyword"&gt;using&lt;/span&gt;(System.IO.StreamReader oReader = &lt;span class="keyword"&gt;new&lt;/span&gt; System.IO.StreamReader(msOur))&lt;br /&gt;            {&lt;br /&gt;                &lt;span class="keyword"&gt;string&lt;/span&gt; sTxt = oReader.ReadToEnd();&lt;br /&gt;                sTxt = sTxt.Replace(&lt;span class="string"&gt;"$CURRENT_DATETIME"&lt;/span&gt;, DateTime.Now.ToString());&lt;br /&gt;                Response.Write(sTxt);&lt;br /&gt;                oReader.Close();&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;What are we doing? Our overridden &lt;strong&gt;Render&lt;/strong&gt; method gets called (not the Page.Render - which would render it to the browser). We create a new HtmlTextWriter ourWriter - which we send to the base.Render (i.e Page.Render()). However, ourWriter is connected to the streamwriter swOur - which in turn is connected to the memorystream msOur (instead of the outputstream of the response object). This way, ASP.NET does handle all the rendering the way it usually does - but the resulting HTML ends up in the memorystream msOur. &lt;/p&gt; &lt;p&gt;We then set the reading position of msOur to 0 - which means we can read from it from the beginning.And now we read everything from it (using the streamreader object) to our sTxt variable. &lt;/p&gt; &lt;p&gt;And now we have all the rendered HTML in sTxt - we can just replace the fabricated template tag $CURRENT_DATETIME with the current time. &lt;/p&gt; &lt;p&gt;And finally send it to the browser by Response.Write.&lt;/p&gt; &lt;p&gt; While there aren't much code for you to copy to get it going in your own project I have included a download zip file containing the solution and code files.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/ynBt/~4/tcgwPYbvDvM" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://purl.org/atom/app#">2009-02-05T21:16:45.277+05:30</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://dotnetfaqs-edu.blogspot.com/2009/02/last-second-html-changes-in-your-aspnet.html</feedburner:origLink></item><item><title>Get current page name</title><link>http://feedproxy.google.com/~r/blogspot/ynBt/~3/CgYkcWTAXsc/aspnet-search-terms-to-database-and.html</link><category>ASP.NET Articles</category><author>noreply@blogger.com (Tiru)</author><pubDate>Thu, 05 Feb 2009 07:44:39 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-6426652519813936980.post-4161057138134087155</guid><description>This function can be used to retrieve the current page:s name, i.e default.aspx, hello.aspx or whatever.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;public string GetCurrentPageName()&lt;br /&gt;{&lt;br /&gt;   string sPath = System.Web.HttpContext.Current.Request.Url.AbsolutePath;&lt;br /&gt;   System.IO.FileInfo oInfo = new System.IO.FileInfo(sPath);&lt;br /&gt;   string sRet = oInfo.Name;&lt;br /&gt;   return sRet;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;By going through System.Web.HttpContext.Current object we are able to have this function in a generic dll or class - and not in each and every page needing to call it.&lt;img src="http://feeds.feedburner.com/~r/blogspot/ynBt/~4/CgYkcWTAXsc" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://purl.org/atom/app#">2009-02-05T21:14:39.956+05:30</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://dotnetfaqs-edu.blogspot.com/2009/02/aspnet-search-terms-to-database-and.html</feedburner:origLink></item><item><title>ASP.NET, MySQL and paging</title><link>http://feedproxy.google.com/~r/blogspot/ynBt/~3/U_FslzqR61I/aspnet-mysql-and-paging.html</link><category>ASP.NET Articles</category><author>noreply@blogger.com (Tiru)</author><pubDate>Thu, 05 Feb 2009 07:24:47 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-6426652519813936980.post-8052589951070137199</guid><description>&lt;span style="font-size:100%;"&gt;In this article we will create a simple one page ASP.NET web application, implementing paging using the cool MySQL feature LIMIT and SQL_CALC_FOUND_ROWS.&lt;br /&gt;&lt;br /&gt;One of the coolest things about MySQL is some of its non standard features. It might sound like a weird thing to say, but being a web developer I just love the simplicity and performance MySQL gives me when it comes to paging. Cause in the typical web app you need paging.&lt;br /&gt;&lt;br /&gt;The two problems a developer faces in such a paged web application&lt;br /&gt;&lt;br /&gt;1. Two questions.&lt;br /&gt;&lt;br /&gt;It's pretty neat to present a list of links to all pages available to the user, instead of just a next/prev link. Typically that means two questions.&lt;br /&gt;&lt;br /&gt;select count(*) from bla bla ALL WHERE CONDIITIONS&lt;br /&gt;&lt;br /&gt;select * from bla bla ALL WHERE CONDIITIONS&lt;br /&gt;&lt;br /&gt;2. Just retrieving the rows for current page from the database.&lt;br /&gt;&lt;br /&gt;It a waste memory to read 100000 records into a dataset and the use a pagedatasource. It's of course better to let the database engine do the filtering and having it just return the actual records to be displayed on the current page.&lt;br /&gt;&lt;br /&gt;And also - you probably need to show the total number of pages available.&lt;br /&gt;&lt;br /&gt;However when using the LIMIT clause in MySQL you solve the problem number two. As for number one - since we still need to get the total number of records, there is a feature for that as well, SQL_CALC_FOUND_ROWS.&lt;br /&gt;&lt;br /&gt;So in short here's the code for reading the data:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;      public DataTable GetData&lt;br /&gt;      {&lt;br /&gt;          get&lt;br /&gt;          {&lt;br /&gt;              //Where to start???&lt;br /&gt;              long lStart = 0;&lt;br /&gt;              if (Request["p"] != null &amp;amp;&amp;amp; Request["p"].Length &gt; 0)&lt;br /&gt;              {&lt;br /&gt;                  lCurrentPage = Convert.ToInt32(Request["p"]);&lt;br /&gt;              }&lt;br /&gt;              if ( lCurrentPage &lt; 1 )&lt;br /&gt;                  lCurrentPage = 1;&lt;br /&gt;              lStart = (lCurrentPage * lPageSize) - lPageSize;&lt;br /&gt;&lt;br /&gt;              string sSQL = "select SQL_CALC_FOUND_ROWS table_schema, table_name from information_schema.tables ";&lt;br /&gt;              sSQL += " order by table_schema, table_name ";&lt;br /&gt;              sSQL += "limit " + lStart.ToString() + "," + lPageSize.ToString() + ";";&lt;br /&gt;              sSQL += "select found_rows();";&lt;br /&gt;              DataSet ds = MySql.Data.MySqlClient.MySqlHelper.ExecuteDataset(System.Configuration.ConfigurationManager.AppSettings["ConnectionString"],&lt;br /&gt;                  sSQL);&lt;br /&gt;              m_Data = ds.Tables[0];&lt;br /&gt;              lTotalCount = Convert.ToInt32(ds.Tables[1].Rows[0][0]);&lt;br /&gt;              return m_Data;&lt;br /&gt;          }&lt;br /&gt;      }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;We add the SQL_CALC_FOUND_ROWS select modifier before the column list. This will tell MySQL to calculate the TOTAL number of rows and make it available in a special variable - which we get with select found_rows(). As you can see we do send both the queries in one command top the server and get them back in a dataset with the result in one table and the count in the second. That's so cool.&lt;br /&gt;&lt;br /&gt;The rest of the code is just a matter of some math to calculate the current page (`query params ?p=12 etc) and of course rendering (the example uses a simple repeater)&lt;br /&gt;&lt;/span&gt;&lt;p&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;img src="http://www.aspcode.net/sites/ASPCode/images/mysqlf1.png" /&gt;&lt;br /&gt;&lt;/span&gt; &lt;/p&gt; &lt;p&gt;&lt;span style="font-size:100%;"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:100%;"&gt;&lt;img src="http://www.aspcode.net/sites/ASPCode/images/mysqlf0.png" /&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/ynBt/~4/U_FslzqR61I" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://purl.org/atom/app#">2009-02-05T20:54:47.949+05:30</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://dotnetfaqs-edu.blogspot.com/2009/02/aspnet-mysql-and-paging.html</feedburner:origLink></item><item><title>Getting started with ADO.NET Entity Framework in .NET 3.5</title><link>http://feedproxy.google.com/~r/blogspot/ynBt/~3/w_Uj4wt7a3M/getting-started-with-adonet-entity_532.html</link><category>ado.net</category><author>noreply@blogger.com (Tiru)</author><pubDate>Sat, 31 Jan 2009 01:47:54 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-6426652519813936980.post-4556350136259270775</guid><description>&lt;p&gt;&lt;span style="font-size:100%;"&gt;ADO.NET Entity Framework is an object-relationship management (ORM) tool like Hibernate in java or N Hibernate for .net. ADO.NET Entity Framework is included with .NET Framework 3.5 Service Pack 1 and Visual Studio 2008 Service Pack 1. Please make sure you have and Visual Studio 2008 Service Pack 1 installed in your system. For more information about ADO.NET Entity Framework you can refer to Microsoft site. &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:100%;"&gt;One practical is worth more than a thousand words. So let us start with creating a very simple example.&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:100%;"&gt;&lt;strong&gt;Step 1: Create a database table.&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:100%;"&gt;Create a database in SQL Server 2005 and name it as Payroll.&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:100%;"&gt;On the payroll database create an Employee table as follows. &lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Verdana','sans-serif';"&gt;USE&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt; [Payroll]&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;GO&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Verdana','sans-serif';"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Verdana','sans-serif';"&gt;SET&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt; &lt;span style="color: blue;"&gt;ANSI_NULLS&lt;/span&gt; &lt;span style="color: blue;"&gt;ON&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;GO&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Verdana','sans-serif';"&gt;SET&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt; &lt;span style="color: blue;"&gt;QUOTED_IDENTIFIER&lt;/span&gt; &lt;span style="color: blue;"&gt;ON&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;GO&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Verdana','sans-serif';"&gt;CREATE&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt; &lt;span style="color: blue;"&gt;TABLE&lt;/span&gt; [dbo]&lt;span style="color: gray;"&gt;.&lt;/span&gt;[Employee]&lt;span style="color: gray;"&gt;(&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;          &lt;/span&gt;[EmployeeID] [int] &lt;span style="color: blue;"&gt;IDENTITY&lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;1&lt;span style="color: gray;"&gt;,&lt;/span&gt;1&lt;span style="color: gray;"&gt;)&lt;/span&gt; &lt;span style="color: gray;"&gt;NOT&lt;/span&gt; &lt;span style="color: gray;"&gt;NULL,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;          &lt;/span&gt;[Name] [nvarchar]&lt;span style="color: gray;"&gt;(&lt;/span&gt;50&lt;span style="color: gray;"&gt;)&lt;/span&gt; &lt;span style="color: gray;"&gt;NOT&lt;/span&gt; &lt;span style="color: gray;"&gt;NULL,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;          &lt;/span&gt;[Title] [nvarchar]&lt;span style="color: gray;"&gt;(&lt;/span&gt;50&lt;span style="color: gray;"&gt;)&lt;/span&gt; &lt;span style="color: gray;"&gt;NOT&lt;/span&gt; &lt;span style="color: gray;"&gt;NULL,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;          &lt;/span&gt;[BirthDate] [datetime] &lt;span style="color: gray;"&gt;NOT&lt;/span&gt; &lt;span style="color: gray;"&gt;NULL,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;          &lt;/span&gt;[MaritalStatus] [nchar]&lt;span style="color: gray;"&gt;(&lt;/span&gt;1&lt;span style="color: gray;"&gt;)&lt;/span&gt; &lt;span style="color: gray;"&gt;NOT&lt;/span&gt; &lt;span style="color: gray;"&gt;NULL,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;          &lt;/span&gt;[Gender] [nchar]&lt;span style="color: gray;"&gt;(&lt;/span&gt;1&lt;span style="color: gray;"&gt;)&lt;/span&gt; &lt;span style="color: gray;"&gt;NOT&lt;/span&gt; &lt;span style="color: gray;"&gt;NULL,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;          &lt;/span&gt;[HireDate] [datetime] &lt;span style="color: gray;"&gt;NOT&lt;/span&gt; &lt;span style="color: gray;"&gt;NULL,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;span style="color: blue;"&gt;CONSTRAINT&lt;/span&gt; [PK_Employee] &lt;span style="color: blue;"&gt;PRIMARY&lt;/span&gt; &lt;span style="color: blue;"&gt;KEY&lt;/span&gt; &lt;span style="color: blue;"&gt;CLUSTERED&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; color: gray; font-family: 'Verdana','sans-serif';"&gt;(&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;          &lt;/span&gt;[EmployeeID] &lt;span style="color: blue;"&gt;ASC&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; color: gray; font-family: 'Verdana','sans-serif';"&gt;)&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Verdana','sans-serif';"&gt;WITH&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt; &lt;span style="color: gray;"&gt;(&lt;/span&gt;&lt;span style="color: blue;"&gt;PAD_INDEX&lt;/span&gt;&lt;span style=""&gt;  &lt;/span&gt;&lt;span style="color: gray;"&gt;=&lt;/span&gt; &lt;span style="color: blue;"&gt;OFF&lt;/span&gt;&lt;span style="color: gray;"&gt;,&lt;/span&gt; &lt;span style="color: blue;"&gt;STATISTICS_NORECOMPUTE&lt;/span&gt;&lt;span style=""&gt;  &lt;/span&gt;&lt;span style="color: gray;"&gt;=&lt;/span&gt; &lt;span style="color: blue;"&gt;OFF&lt;/span&gt;&lt;span style="color: gray;"&gt;,&lt;/span&gt; &lt;span style="color: blue;"&gt;IGNORE_DUP_KEY&lt;/span&gt; &lt;span style="color: gray;"&gt;=&lt;/span&gt; &lt;span style="color: blue;"&gt;OFF&lt;/span&gt;&lt;span style="color: gray;"&gt;,&lt;/span&gt; &lt;span style="color: blue;"&gt;ALLOW_ROW_LOCKS&lt;/span&gt;&lt;span style=""&gt;  &lt;/span&gt;&lt;span style="color: gray;"&gt;=&lt;/span&gt; &lt;span style="color: blue;"&gt;ON&lt;/span&gt;&lt;span style="color: gray;"&gt;,&lt;/span&gt; &lt;span style="color: blue;"&gt;ALLOW_PAGE_LOCKS&lt;/span&gt;&lt;span style=""&gt;  &lt;/span&gt;&lt;span style="color: gray;"&gt;=&lt;/span&gt; &lt;span style="color: blue;"&gt;ON&lt;/span&gt;&lt;span style="color: gray;"&gt;)&lt;/span&gt; &lt;span style="color: blue;"&gt;ON&lt;/span&gt; [PRIMARY]&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; color: gray; font-family: 'Verdana','sans-serif';"&gt;)&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt; &lt;span style="color: blue;"&gt;ON&lt;/span&gt; [PRIMARY]&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:100%;"&gt;&lt;strong&gt;Step 2: Data Layer&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:100%;"&gt;In the visual studio 2008 Make a new Blank solution and name it as Payroll. In the solution add a new class library project. Name it as Payroll.Entities as shown in following image.&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:100%;"&gt;&lt;img alt="" src="http://www.c-sharpcorner.com/UploadFile/ankithakur/Getting_started_with_ADO_NET_Entity_Framework09302008085544AM/Images/ADOEF1.gif" align="baseline" border="0" hspace="0" /&gt; &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:100%;"&gt;Remove the class1.cs from project. Add a new item to project a select. ADO.NET Entity data Model.&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:100%;"&gt;&lt;img alt="" src="http://www.c-sharpcorner.com/UploadFile/ankithakur/Getting_started_with_ADO_NET_Entity_Framework09302008085544AM/Images/ADOEF2.gif" align="baseline" border="0" hspace="0" /&gt; &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:100%;"&gt;Rename it as Payroll.edmx. Click on add. Select generate from the database and click on next choose database connection and the given textbox for connection string rename it with PayrollDAO&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:100%;"&gt;&lt;img alt="" src="http://www.c-sharpcorner.com/UploadFile/ankithakur/Getting_started_with_ADO_NET_Entity_Framework09302008085544AM/Images/ADOEF3.gif" align="baseline" border="0" hspace="0" /&gt; &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:100%;"&gt;From the next screen select the employee table and click on finish. Compile the project. Now data layer is ready for you.&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:100%;"&gt;&lt;strong&gt;Step 3: Business/Service Layer&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:100%;"&gt;In the solution Payroll add a new class library project. Name it as Payroll.Service. Rename the class1.cs as EmployeeService.cs. Make the reference to System.Data.Entity. and also add the refrence to Payroll.Entities project we have created. Now add two methods GetEmployee and AddEmployee. Your class should look like this&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Verdana','sans-serif';"&gt;using&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt; System;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Verdana','sans-serif';"&gt;using&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt; System.Collections.Generic;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Verdana','sans-serif';"&gt;using&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt; System.Linq;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Verdana','sans-serif';"&gt;using&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt; System.Text;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Verdana','sans-serif';"&gt;using&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt; Payroll.Entities;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Verdana','sans-serif';"&gt;using&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt; System.Data.Objects;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Verdana','sans-serif';"&gt;using&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt; System.Data.Objects.DataClasses;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Verdana','sans-serif';"&gt;namespace&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt; Payroll.Service&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;    &lt;/span&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;class&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;EmployeeService&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;    &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;List&lt;/span&gt;&lt;&lt;span style="color: rgb(43, 145, 175);"&gt;Employee&lt;/span&gt;&gt; GetEmployee()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;        &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;            &lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;PayrollDAO&lt;/span&gt; payrollDAO = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;PayrollDAO&lt;/span&gt;();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;            &lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;ObjectQuery&lt;/span&gt;&lt;&lt;span style="color: rgb(43, 145, 175);"&gt;Employee&lt;/span&gt;&gt; employeeQuery = payrollDAO.Employee;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;            &lt;/span&gt;&lt;span style="color: blue;"&gt;return&lt;/span&gt; employeeQuery.ToList();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;        &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;string&lt;/span&gt; AddEmpoyee(Payroll.Entities.&lt;span style="color: rgb(43, 145, 175);"&gt;Employee&lt;/span&gt; e1)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;        &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;            &lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;PayrollDAO&lt;/span&gt; payrollDAO = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;PayrollDAO&lt;/span&gt;();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;            &lt;/span&gt;payrollDAO.AddToEmployee(e1);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;            &lt;/span&gt;payrollDAO.SaveChanges();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;            &lt;/span&gt;&lt;span style="color: blue;"&gt;return&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;"SUCCESS"&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;        &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;    &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:100%;"&gt;Compile the project. Service layer is ready for you.&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:100%;"&gt;&lt;strong&gt;Step 4: Presentation Layer&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:100%;"&gt;Add a new web site with name "WebApp" to the payroll solution and set it as startup project. In the default.aspx add a gridview and button as shown in following figure&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:100%;"&gt;&lt;img alt="" src="http://www.c-sharpcorner.com/UploadFile/ankithakur/Getting_started_with_ADO_NET_Entity_Framework09302008085544AM/Images/ADOEF4.gif" align="baseline" border="0" hspace="0" /&gt; &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:100%;"&gt;Set button text to Add Employee. Make the reference to System.Data.Entity and also add the refrence to Payroll.Service project we have created in step 3.&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:100%;"&gt;Add the code on page load and buttion1_click, Default.aspx.cs should look like this&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Verdana','sans-serif';"&gt;using&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt; System;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Verdana','sans-serif';"&gt;using&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt; System.Collections.Generic;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Verdana','sans-serif';"&gt;using&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt; System.Linq;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Verdana','sans-serif';"&gt;using&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt; System.Web;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Verdana','sans-serif';"&gt;using&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt; System.Web.UI;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Verdana','sans-serif';"&gt;using&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt; System.Web.UI.WebControls;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Verdana','sans-serif';"&gt;using&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt; Payroll.Service;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Verdana','sans-serif';"&gt;public&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt; &lt;span style="color: blue;"&gt;partial&lt;/span&gt; &lt;span style="color: blue;"&gt;class&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;_Default&lt;/span&gt; : System.Web.UI.&lt;span style="color: rgb(43, 145, 175);"&gt;Page&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;    &lt;/span&gt;&lt;span style="color: blue;"&gt;protected&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; Page_Load(&lt;span style="color: blue;"&gt;object&lt;/span&gt; sender, &lt;span style="color: rgb(43, 145, 175);"&gt;EventArgs&lt;/span&gt; e)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;    &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;EmployeeService&lt;/span&gt;&lt;span style=""&gt;  &lt;/span&gt;es= &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;EmployeeService&lt;/span&gt;();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;        &lt;/span&gt;GridView1.DataSource = es.GetEmployee();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;        &lt;/span&gt;GridView1.DataBind();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;    &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;    &lt;/span&gt;&lt;span style="color: blue;"&gt;protected&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; Button1_Click(&lt;span style="color: blue;"&gt;object&lt;/span&gt; sender, &lt;span style="color: rgb(43, 145, 175);"&gt;EventArgs&lt;/span&gt; e)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;    &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;EmployeeService&lt;/span&gt; es = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;EmployeeService&lt;/span&gt;();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;DateTime&lt;/span&gt; dt = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;DateTime&lt;/span&gt;(2008, 12, 12);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt 0.5in;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt; &lt;/span&gt;Payroll.Entities.&lt;span style="color: rgb(43, 145, 175);"&gt;Employee&lt;/span&gt; e1 =&lt;span style=""&gt;     &lt;/span&gt;Payroll.Entities.&lt;span style="color: rgb(43, 145, 175);"&gt;Employee&lt;/span&gt;.CreateEmployee(0, &lt;span style="color: rgb(163, 21, 21);"&gt;"Anand"&lt;/span&gt;, &lt;span style="color: rgb(163, 21, 21);"&gt;"Thakur"&lt;/span&gt;, dt, &lt;span style="color: rgb(163, 21, 21);"&gt;"M"&lt;/span&gt;, &lt;span style="color: rgb(163, 21, 21);"&gt;"M"&lt;/span&gt;, dt);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;        &lt;/span&gt;es.AddEmpoyee(e1);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;    &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:100%;"&gt;Copy the connectionStrings from App.config of Data Layer(Payroll.Entities) project and paste in web.config of web application&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Verdana','sans-serif';"&gt;&lt;&lt;/span&gt;&lt;span style="font-size: 10pt; color: rgb(163, 21, 21); font-family: 'Verdana','sans-serif';"&gt;connectionStrings&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Verdana','sans-serif';"&gt;&gt;
&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;          &lt;/span&gt;&lt;&lt;/span&gt;&lt;span style="font-size: 10pt; color: rgb(163, 21, 21); font-family: 'Verdana','sans-serif';"&gt;add&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Verdana','sans-serif';"&gt; &lt;/span&gt;&lt;span style="font-size: 10pt; color: red; font-family: 'Verdana','sans-serif';"&gt;name&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Verdana','sans-serif';"&gt;=&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;"&lt;span style="color: blue;"&gt;PayrollDAO&lt;/span&gt;"&lt;span style="color: blue;"&gt; &lt;/span&gt;&lt;span style="color: red;"&gt;connectionString&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;metadata=res://*/Payroll.csdl|res://*/Payroll.ssdl|res://*/Payroll.msl;provider=System.Data.SqlClient;provider connection string=&lt;/span&gt;&lt;span style="color: red;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: blue;"&gt;Data Source=ATHAKUR;Initial Catalog=Payroll;Integrated Security=True;MultipleActiveResultSets=True&lt;/span&gt;&lt;span style="color: red;"&gt;&amp;quot;&lt;/span&gt;"&lt;span style="color: blue;"&gt; &lt;/span&gt;&lt;span style="color: red;"&gt;providerName&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;System.Data.EntityClient&lt;/span&gt;"&lt;span style="color: blue;"&gt; /&gt;
&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Verdana','sans-serif';"&gt;&lt;/&lt;/span&gt;&lt;span style="font-size: 10pt; color: rgb(163, 21, 21); font-family: 'Verdana','sans-serif';"&gt;connectionStrings&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Verdana','sans-serif';"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Verdana','sans-serif';"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;Now build and run the web application.&lt;/span&gt;&lt;/p&gt; &lt;p&gt; &lt;/p&gt;&lt;p&gt;&lt;span style="font-size:100%;"&gt;&lt;img alt="" src="http://www.c-sharpcorner.com/UploadFile/ankithakur/Getting_started_with_ADO_NET_Entity_Framework09302008085544AM/Images/ADOEF5.gif" align="baseline" border="0" hspace="0" /&gt; &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:100%;"&gt;Click on add employee, new employee should be added to database.&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:100%;"&gt;&lt;strong&gt;Conclusion: &lt;/strong&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:100%;"&gt;This is a very basic example with single table. In the next part, I will try to include more tables with CRUD operations.&lt;/span&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/ynBt/~4/w_Uj4wt7a3M" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://purl.org/atom/app#">2009-01-31T15:17:54.253+05:30</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://dotnetfaqs-edu.blogspot.com/2009/01/getting-started-with-adonet-entity_532.html</feedburner:origLink></item><item><title>Getting started with ADO.NET Entity Framework in .NET 3.5 - Part II</title><link>http://feedproxy.google.com/~r/blogspot/ynBt/~3/0WgIRkLqgaw/getting-started-with-adonet-entity_31.html</link><category>ado.net</category><author>noreply@blogger.com (Tiru)</author><pubDate>Sat, 31 Jan 2009 01:46:52 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-6426652519813936980.post-5377113011171491903</guid><description>&lt;p&gt;&lt;span style="font-size:100%;"&gt;In my last article "Getting started with ADO.NET Entity Framework in .NET 3.5", we have done select and add operations, now let us extend with update and delete operations.&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:100%;"&gt;Now I have added there textboxes fro employee ID, name and title as follows. (you can find it with attached project)&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:100%;"&gt;&lt;img alt="" src="http://www.c-sharpcorner.com/UploadFile/ankithakur/ADOEF210032008083247AM/Images/ADOEF2image.gif" align="baseline" border="0" hspace="0" /&gt; &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:100%;"&gt;&lt;strong&gt;Update:&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:100%;"&gt;There is no change in Data layer&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:100%;"&gt;In the business layer add the UpdateEmployee method&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Verdana','sans-serif';"&gt;public&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt; &lt;span style="color: blue;"&gt;string&lt;/span&gt; UpdateEmployee(Payroll.Entities.&lt;span style="color: rgb(43, 145, 175);"&gt;Employee&lt;/span&gt; e1)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;        &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;            &lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;PayrollDAO&lt;/span&gt; payrollDAO = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;PayrollDAO&lt;/span&gt;();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;            &lt;/span&gt;&lt;span style="color: blue;"&gt;try&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;            &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;                &lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;Employee&lt;/span&gt; e2 = &lt;span style="color: blue;"&gt;null&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;     &lt;/span&gt;&lt;span style=""&gt;           &lt;/span&gt;e2 = (&lt;span style="color: blue;"&gt;from&lt;/span&gt; emp &lt;span style="color: blue;"&gt;in&lt;/span&gt; payrollDAO.Employee&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;                               &lt;/span&gt;&lt;span style="color: blue;"&gt;where&lt;/span&gt; emp.EmployeeID == e1.EmployeeID&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;                               &lt;/span&gt;&lt;span style="color: blue;"&gt;select&lt;/span&gt; emp).First();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;                &lt;/span&gt;e2.Name = e1.Name;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;                &lt;/span&gt;e2.Title = e1.Title;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;              &lt;/span&gt;&lt;span style=""&gt;  &lt;/span&gt;payrollDAO.SaveChanges();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;            &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;            &lt;/span&gt;&lt;span style="color: blue;"&gt;catch&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;            &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;                &lt;/span&gt;&lt;span style="color: blue;"&gt;return&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;"ERROR"&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;            &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;            &lt;/span&gt;&lt;span style="color: blue;"&gt;return&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;"SUCCESS"&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;        &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt; &lt;/p&gt;&lt;p&gt;&lt;span style="font-size:100%;"&gt;In the Presentation layer, add the following code in update button click&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Verdana','sans-serif';"&gt;protected&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; Button2_Click(&lt;span style="color: blue;"&gt;object&lt;/span&gt; sender, &lt;span style="color: rgb(43, 145, 175);"&gt;EventArgs&lt;/span&gt; e)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;    &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;EmployeeService&lt;/span&gt; es = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;EmployeeService&lt;/span&gt;();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;DateTime&lt;/span&gt; dt = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;DateTime&lt;/span&gt;(2008, 12, 12);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;        &lt;/span&gt;Payroll.Entities.&lt;span style="color: rgb(43, 145, 175);"&gt;Employee&lt;/span&gt; e1 = Payroll.Entities.&lt;span style="color: rgb(43, 145, 175);"&gt;Employee&lt;/span&gt;.CreateEmployee(&lt;span style="color: rgb(43, 145, 175);"&gt;Convert&lt;/span&gt;.ToInt32(empID.Text), empName.Text, empTitle.Text, dt, &lt;span style="color: rgb(163, 21, 21);"&gt;"M"&lt;/span&gt;, &lt;span style="color: rgb(163, 21, 21);"&gt;"M"&lt;/span&gt;, dt);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;        &lt;/span&gt;Result.Text = es.UpdateEmployee(e1);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;        &lt;/span&gt;GridView1.DataSource = es.GetEmployee();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;        &lt;/span&gt;GridView1.DataBind();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;    &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt; &lt;/p&gt;&lt;p&gt;&lt;span style="font-size:100%;"&gt;&lt;strong&gt;Delete:&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:100%;"&gt;There is no change in Data layer&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:100%;"&gt;In the business layer add the DeleteEmployee method&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Verdana','sans-serif';"&gt;public&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt; &lt;span style="color: blue;"&gt;string&lt;/span&gt; DeleteEmployee(Payroll.Entities.&lt;span style="color: rgb(43, 145, 175);"&gt;Employee&lt;/span&gt; e1)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;        &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;            &lt;/span&gt;&lt;span style="color: blue;"&gt;try&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;            &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;                &lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;PayrollDAO&lt;/span&gt; payrollDAO = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;PayrollDAO&lt;/span&gt;();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;                &lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;Employee&lt;/span&gt; e2 = (&lt;span style="color: blue;"&gt;from&lt;/span&gt; emp &lt;span style="color: blue;"&gt;in&lt;/span&gt; payrollDAO.Employee&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;                  &lt;/span&gt;&lt;span style=""&gt;             &lt;/span&gt;&lt;span style="color: blue;"&gt;where&lt;/span&gt; emp.EmployeeID == e1.EmployeeID&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;                               &lt;/span&gt;&lt;span style="color: blue;"&gt;select&lt;/span&gt; emp).First();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;                &lt;/span&gt;payrollDAO.DeleteObject(e2);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;                &lt;/span&gt;payrollDAO.SaveChanges();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;            &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;            &lt;/span&gt;&lt;span style="color: blue;"&gt;catch&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;            &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;                &lt;/span&gt;&lt;span style="color: blue;"&gt;return&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;"ERROR"&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;            &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;            &lt;/span&gt;&lt;span style="color: blue;"&gt;return&lt;/span&gt; &lt;span style="color: rgb(163, 21, 21);"&gt;"SUCCESS"&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;        &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt; &lt;/p&gt;&lt;p&gt;&lt;span style="font-size:100%;"&gt;In the Presentation layer, add the following code in delete button click&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Verdana','sans-serif';"&gt;protected&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; Button3_Click(&lt;span style="color: blue;"&gt;object&lt;/span&gt; sender, &lt;span style="color: rgb(43, 145, 175);"&gt;EventArgs&lt;/span&gt; e)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;    &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;EmployeeService&lt;/span&gt; es = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;EmployeeService&lt;/span&gt;();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;DateTime&lt;/span&gt; dt = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;DateTime&lt;/span&gt;(2008, 12, 12);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;        &lt;/span&gt;Payroll.Entities.&lt;span style="color: rgb(43, 145, 175);"&gt;Employee&lt;/span&gt; e1 = Payroll.Entities.&lt;span style="color: rgb(43, 145, 175);"&gt;Employee&lt;/span&gt;.CreateEmployee(&lt;span style="color: rgb(43, 145, 175);"&gt;Convert&lt;/span&gt;.ToInt32(empID.Text), &lt;span style="color: rgb(163, 21, 21);"&gt;""&lt;/span&gt;, &lt;span style="color: rgb(163, 21, 21);"&gt;""&lt;/span&gt;, dt, &lt;span style="color: rgb(163, 21, 21);"&gt;"M"&lt;/span&gt;, &lt;span style="color: rgb(163, 21, 21);"&gt;"M"&lt;/span&gt;, dt);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;        &lt;/span&gt;Result.Text = es.DeleteEmployee(e1);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;        &lt;/span&gt;GridView1.DataSource = es.GetEmployee();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;        &lt;/span&gt;GridView1.DataBind();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: 'Verdana','sans-serif';"&gt;&lt;span style=""&gt;    &lt;/span&gt;}&lt;/span&gt;&lt;span style="font-family: 'Verdana','sans-serif';"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt; &lt;/p&gt;&lt;p&gt;&lt;span style="font-size:100%;"&gt;Now our CRUD operations are over, in next article we will try to include more tables with relationships.&lt;/span&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/ynBt/~4/0WgIRkLqgaw" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://purl.org/atom/app#">2009-01-31T15:16:52.543+05:30</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://dotnetfaqs-edu.blogspot.com/2009/01/getting-started-with-adonet-entity_31.html</feedburner:origLink></item><item><title>Getting started with ADO.NET Entity Framework in .NET 3.5 - Part III</title><link>http://feedproxy.google.com/~r/blogspot/ynBt/~3/eC_WDlzf4YU/getting-started-with-adonet-entity.html</link><category>ado.net</category><author>noreply@blogger.com (Tiru)</author><pubDate>Sat, 31 Jan 2009 01:45:49 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-6426652519813936980.post-5316427917482644338</guid><description>&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:Verdana;"&gt;Now in the example given in last tutorial update the GetEmployee method as follows&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: Verdana;"&gt;public&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt; &lt;span style="color: blue;"&gt;static&lt;/span&gt; &lt;/span&gt;&lt;span style="font-size: 10pt; color: rgb(43, 145, 175); font-family: Verdana;"&gt;List&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;&lt;&lt;span style="color: rgb(43, 145, 175);"&gt;Employee&lt;/span&gt;&gt; GetEmployee()&lt;br /&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: Verdana;"&gt;int&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt; skipValue = 50;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: Verdana;"&gt;int&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt; limitValue = 25;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size: 10pt; color: rgb(43, 145, 175); font-family: Verdana;"&gt;PayrollDAO&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt; payrollDAO = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;PayrollDAO&lt;/span&gt; ();&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size: 10pt; color: rgb(43, 145, 175); font-family: Verdana;"&gt;ObjectQuery&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;&lt;&lt;span style="color: rgb(43, 145, 175);"&gt;Employee&lt;/span&gt;&gt; employeeQuery = payrollDAO.Employee&lt;br /&gt;.Where(&lt;span style="color: maroon;"&gt;"it.Name = @eName"&lt;/span&gt;, &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;/span&gt;&lt;span style="font-size: 10pt; color: rgb(43, 145, 175); font-family: Verdana;"&gt;ObjectParameter&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt; (&lt;span style="color: maroon;"&gt;"eName"&lt;/span&gt;, &lt;span style="color: maroon;"&gt;"aaa"&lt;/span&gt;))&lt;br /&gt;.Where(&lt;span style="color: maroon;"&gt;"it.EmployeeID &gt; @EmpID1 "&lt;/span&gt;, &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;/span&gt;&lt;span style="font-size: 10pt; color: rgb(43, 145, 175); font-family: Verdana;"&gt;ObjectParameter&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;(&lt;span style="color: maroon;"&gt;"EmpID1"&lt;/span&gt;, 20083))&lt;br /&gt;.Where(&lt;span style="color: maroon;"&gt;"it.EmployeeID &lt; @EmpID2 "&lt;/span&gt;, &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;/span&gt;&lt;span style="font-size: 10pt; color: rgb(43, 145, 175); font-family: Verdana;"&gt;ObjectParameter&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;(&lt;span style="color: maroon;"&gt;"EmpID2"&lt;/span&gt;, 20099))&lt;br /&gt;.Skip(&lt;span style="color: maroon;"&gt;"it.Name"&lt;/span&gt;, &lt;span style="color: maroon;"&gt;"@skip"&lt;/span&gt;, &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;/span&gt;&lt;span style="font-size: 10pt; color: rgb(43, 145, 175); font-family: Verdana;"&gt;ObjectParameter&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;(&lt;span style="color: maroon;"&gt;"skip"&lt;/span&gt;, skipValue))&lt;br /&gt;.Top(&lt;span style="color: maroon;"&gt;"@limit"&lt;/span&gt;, &lt;span style="color: blue;"&gt;new&lt;/span&gt; ObjectParameter(&lt;span style="color: maroon;"&gt;"limit"&lt;/span&gt;, limitValue));&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: Verdana;"&gt;return&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt; employeeQuery.ToList();&lt;br /&gt;}&lt;/span&gt;&lt;/span&gt; &lt;p&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:Verdana;"&gt;&lt;b&gt;Conditional Query&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;As you can see from the code WHERE condition&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;.Where(&lt;span style="color: maroon;"&gt;"it.Name = @eName"&lt;/span&gt;, &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;/span&gt;&lt;span style="font-size: 10pt; color: rgb(43, 145, 175); font-family: Verdana;"&gt;ObjectParameter&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;(&lt;span style="color: maroon;"&gt;"eName"&lt;/span&gt;, &lt;span style="color: maroon;"&gt;"aaa"&lt;/span&gt;))&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:Verdana;"&gt;Select the name whose value equal to eName parameter and next is the parameter passed in case it is 'aaa'. Please note that "it" is the default name given by Entity Framework. This will select all the employees with name 'aaa'.&lt;br /&gt;&lt;br /&gt;You can add as much as WHERE conditions as you can see in the above example.&lt;br /&gt;&lt;br /&gt;More information http://msdn.microsoft.com/en-us/library/bb896238.aspx&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:Verdana;"&gt;&lt;b&gt;Paging&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Paging in Entity framework is done by SKIP and TOP.&lt;br /&gt;&lt;br /&gt;SKIP tells that from where the data should be picked up and TOP tells how many rows to be selected&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: Verdana;"&gt;int&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt; skipValue = 50;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: Verdana;"&gt;int&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt; limitValue = 25;&lt;br /&gt;.Skip(&lt;span style="color: maroon;"&gt;"it.Name"&lt;/span&gt;, &lt;span style="color: maroon;"&gt;"@skip"&lt;/span&gt;, &lt;span style="color: blue;"&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 10pt; color: rgb(43, 145, 175); font-family: Verdana;"&gt; ObjectParameter&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;(&lt;span style="color: maroon;"&gt;"skip"&lt;/span&gt;, skipValue))&lt;br /&gt;.Top(&lt;span style="color: maroon;"&gt;"@limit"&lt;/span&gt;, &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;/span&gt;&lt;span style="font-size: 10pt; color: rgb(43, 145, 175); font-family: Verdana;"&gt;ObjectParameter&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;(&lt;span style="color: maroon;"&gt;"limit"&lt;/span&gt;, limitValue));&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:Verdana;"&gt;In this example it will skip first 50 rows, then starting from 51st row; it will show up to 75th row .You can also explore LIMIT method for paging&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/ynBt/~4/eC_WDlzf4YU" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://purl.org/atom/app#">2009-01-31T15:15:49.447+05:30</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://dotnetfaqs-edu.blogspot.com/2009/01/getting-started-with-adonet-entity.html</feedburner:origLink></item><item><title>Data binding techniques using Visual Studio.NET and JDeveloper</title><link>http://feedproxy.google.com/~r/blogspot/ynBt/~3/9YuS8fGL3jU/data-binding-techniques-using-visual.html</link><category>ado.net</category><author>noreply@blogger.com (Tiru)</author><pubDate>Sat, 31 Jan 2009 01:44:34 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-6426652519813936980.post-1348225655777520929</guid><description>&lt;p&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:Verdana;"&gt;&lt;b&gt;Introduction&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;Today data binding techniques are very easy to apply using IDE such as Microsoft Visual Studio.NET and Oralce JDeveloper. In this article, I will show how to develop a client/server enterprise application by applying the Model-View-Controller (MVC) design pattern and using development tools such as Microsoft Visual.NET and Oracle JDeveloper.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Data binding in Visual Studio.NET&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;In this section, we're going to build a two-tier enterprise application using Visual Studio.NET and the underlying data binding framework. The first step is to start the Visual Studio.NET, and then create a connection to the underlying database using Data Connection tree in the Server Explorer. Go to the Server Explorer window, right-click on the Data Connections node and choose Add Connection from the context menu. In the Add Connection dialog, enter the information to connect to the AdventureWorks database shipped with the installation of Microsoft SQL Server 2005 (see Figure 1).&lt;br /&gt;&lt;br /&gt;&lt;img alt="" src="http://www.c-sharpcorner.com/UploadFile/john_charles/DatabindingtechniquesusingVisualStudioNETandJDeveloper12082008120229PM/Images/Databindingtech1.gif" align="baseline" border="0" hspace="0" /&gt;&lt;br /&gt;&lt;br /&gt;Figure 1&lt;br /&gt;&lt;br /&gt;Now let's create a solution and two projects: one as class library to package the business logic layer's components (see Figure 2) and the other as Windows Application (see Figure 3) to package the presentation layer's components.&lt;br /&gt;&lt;br /&gt;&lt;img alt="" src="http://www.c-sharpcorner.com/UploadFile/john_charles/DatabindingtechniquesusingVisualStudioNETandJDeveloper12082008120229PM/Images/Databindingtech2.gif" align="baseline" border="0" hspace="0" /&gt;&lt;br /&gt;&lt;br /&gt;Figure 2&lt;br /&gt;&lt;br /&gt;&lt;img alt="" src="http://www.c-sharpcorner.com/UploadFile/john_charles/DatabindingtechniquesusingVisualStudioNETandJDeveloper12082008120229PM/Images/Databindingtech3.gif" align="baseline" border="0" hspace="0" /&gt;&lt;br /&gt;&lt;br /&gt;Figure 3&lt;br /&gt;&lt;br /&gt;Now we're going to create the business components for the business logic module. As illustrative, we're going to use the Production.Product and Production.ProductModel tables in the AdventureWorks. For this purpose, we're going to create the business entities using Dataset object model. In the Solution Explorer window, right-click on the BusinessLogicCompPkg project, select Add | New Item from the context menu and select Dataset item from the Add New Item dialog box (see Figure 4).&lt;br /&gt;&lt;br /&gt;&lt;img alt="" src="http://www.c-sharpcorner.com/UploadFile/john_charles/DatabindingtechniquesusingVisualStudioNETandJDeveloper12082008120229PM/Images/Databindingtech4.gif" align="baseline" border="0" hspace="0" /&gt;&lt;br /&gt;&lt;br /&gt;Figure 4&lt;br /&gt;&lt;br /&gt;Once the DataSet designer is open, you can define business entities by right-clicking on the DataSet designer and selecting Add | TableAdapter option from the context menu. When the Table Adapter Configuration Wizard appears, in the Step 1, you choose the created data connection (see Figure 5). Click on Next button.&lt;br /&gt;&lt;br /&gt;&lt;img alt="" src="http://www.c-sharpcorner.com/UploadFile/john_charles/DatabindingtechniquesusingVisualStudioNETandJDeveloper12082008120229PM/Images/Databindingtech5.gif" align="baseline" border="0" hspace="0" /&gt;&lt;br /&gt;&lt;br /&gt;Figure 5&lt;br /&gt;&lt;br /&gt;In the Step 2, you specify how to store the connection string in the configuration file. Click on Next button. In the Step 3, you can specify the access method to the database. In this case, we're going to write SQL statements (see Figure 6).&lt;br /&gt;&lt;br /&gt;&lt;img alt="" src="http://www.c-sharpcorner.com/UploadFile/john_charles/DatabindingtechniquesusingVisualStudioNETandJDeveloper12082008120229PM/Images/Databindingtech6.gif" align="baseline" border="0" hspace="0" /&gt;&lt;br /&gt;&lt;br /&gt;Figure 6&lt;br /&gt;&lt;br /&gt;In the Step 4, you must write the underlying SQL SELECT statement (see Figure 7). Click on the Next button.&lt;br /&gt;&lt;br /&gt;&lt;img alt="" src="http://www.c-sharpcorner.com/UploadFile/john_charles/DatabindingtechniquesusingVisualStudioNETandJDeveloper12082008120229PM/Images/Databindingtech7.gif" align="baseline" border="0" hspace="0" /&gt;&lt;br /&gt;&lt;br /&gt;Figure 7&lt;br /&gt;&lt;br /&gt;The final step is for choose the methods associated to the Data Adapter in order to interact with the data source (see Figure 8).&lt;br /&gt;&lt;br /&gt;&lt;img alt="" src="http://www.c-sharpcorner.com/UploadFile/john_charles/DatabindingtechniquesusingVisualStudioNETandJDeveloper12082008120229PM/Images/Databindingtech8.gif" align="baseline" border="0" hspace="0" /&gt;&lt;br /&gt;&lt;br /&gt;Figure 8&lt;br /&gt;&lt;br /&gt;Repeat this step in order to create the ProductModel entity. After that, the data set resembles as in Figure 9.&lt;br /&gt;&lt;br /&gt;&lt;img alt="" src="http://www.c-sharpcorner.com/UploadFile/john_charles/DatabindingtechniquesusingVisualStudioNETandJDeveloper12082008120229PM/Images/Databindingtech9.gif" align="baseline" border="0" hspace="0" /&gt;&lt;br /&gt;&lt;br /&gt;Figure 9&lt;br /&gt;&lt;br /&gt;Finally, compile this project and we're read to use these business components. Now let's move on to the presentation project. Let's add a MenuStrip control from the Toolbox onto the main form. In the menu, create a sub-menu named Entities with two inner child menus named Product and Product Model. Finally, let's add an event handler for the Click event for the Product and Product sub-menu (see Figure 10).&lt;br /&gt;&lt;br /&gt;&lt;img alt="" src="http://www.c-sharpcorner.com/UploadFile/john_charles/DatabindingtechniquesusingVisualStudioNETandJDeveloper12082008120229PM/Images/Databindingtech10.gif" align="baseline" border="0" hspace="0" /&gt;&lt;br /&gt;&lt;br /&gt;Figure 10&lt;br /&gt;&lt;br /&gt;Now let's add two child forms to display data of the Product and ProductModel entities and a reference to the BusinessLogicCompPkg assembly in order to invoke its objects (see Figure 11).&lt;br /&gt;&lt;br /&gt;&lt;img alt="" src="http://www.c-sharpcorner.com/UploadFile/john_charles/DatabindingtechniquesusingVisualStudioNETandJDeveloper12082008120229PM/Images/Databindingtech11.gif" align="baseline" border="0" hspace="0" /&gt;&lt;br /&gt;&lt;br /&gt;Figure 11&lt;br /&gt;&lt;br /&gt;Now let's work on the ProductForm. Go to the Data Sources window and click on Add New Data Source icon in order to open the Data Source Configuration Wizard. In the first step, we choose to consume the data from the objects (the business entities created before). Click on Next button. In the Step 2, choose the data objects to bind to the GUI application, in this case the ProductDS object (see Figure 12).&lt;br /&gt;&lt;br /&gt;&lt;img alt="" src="http://www.c-sharpcorner.com/UploadFile/john_charles/DatabindingtechniquesusingVisualStudioNETandJDeveloper12082008120229PM/Images/Databindingtech12.gif" align="baseline" border="0" hspace="0" /&gt;&lt;br /&gt;&lt;br /&gt;Figure 12&lt;br /&gt;&lt;br /&gt;Now you can see the Product and ProductModel entities in the Data Sources window. The next step in the application is to configure the Product to be displayed in details mode (see Figure 13) and the.&lt;br /&gt;&lt;br /&gt;&lt;img alt="" src="http://www.c-sharpcorner.com/UploadFile/john_charles/DatabindingtechniquesusingVisualStudioNETandJDeveloper12082008120229PM/Images/Databindingtech13.gif" align="baseline" border="0" hspace="0" /&gt;&lt;br /&gt;&lt;br /&gt;Figure 13&lt;br /&gt;&lt;br /&gt;You must configure the ProductModelID attribute as a combo box (Figure 14).&lt;br /&gt;&lt;br /&gt;&lt;img alt="" src="http://www.c-sharpcorner.com/UploadFile/john_charles/DatabindingtechniquesusingVisualStudioNETandJDeveloper12082008120229PM/Images/Databindingtech14.gif" align="baseline" border="0" hspace="0" /&gt;&lt;br /&gt;&lt;br /&gt;Figure 14&lt;br /&gt;&lt;br /&gt;Drag and drop the ProductModel node from the Data Sources window onto the ProductModelID attribute.&lt;br /&gt;&lt;br /&gt;Now we need to add the business logic using C# to fill the data set and update the data source from the changes from the data set (see Listing 1)&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: Verdana;"&gt;using&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt; System;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: Verdana;"&gt;using&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt; System.Collections.Generic;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: Verdana;"&gt;using&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt; System.ComponentModel;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: Verdana;"&gt;using&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt; System.Data;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: Verdana;"&gt;using&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt; System.Drawing;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: Verdana;"&gt;using&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt; System.Text;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: Verdana;"&gt;using&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt; System.Windows.Forms;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: Verdana;"&gt;using&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt; BusinessLogicCompPkg;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: Verdana;"&gt;using&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt; BusinessLogicCompPkg.ProductsDSTableAdapters;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; color: blue; font-family: Verdana;"&gt;namespace&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt; AppGUI&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;partial&lt;/span&gt; &lt;span style="color: blue;"&gt;class&lt;/span&gt; &lt;span style="color: teal;"&gt;ProductForm&lt;/span&gt; : &lt;span style="color: teal;"&gt;Form&lt;br /&gt;&lt;/span&gt;    {&lt;br /&gt;        &lt;span style="color: blue;"&gt;public&lt;/span&gt; ProductForm()&lt;br /&gt;        {&lt;br /&gt;            InitializeComponent();&lt;br /&gt;        }&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;        &lt;span style="color: blue;"&gt;private&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; ProductForm_Load(&lt;span style="color: blue;"&gt;object&lt;/span&gt; sender, &lt;span style="color: teal;"&gt;EventArgs&lt;/span&gt; e)&lt;br /&gt;        {&lt;br /&gt;            ProductTableAdapter taProduct = &lt;span style="color: blue;"&gt;new&lt;/span&gt; ProductTableAdapter();&lt;br /&gt;            taProduct.Fill(productsDS.Product);&lt;br /&gt;&lt;br /&gt;            ProductModelTableAdapter taProductModel = &lt;span style="color: blue;"&gt;new&lt;/span&gt; ProductModelTableAdapter();&lt;br /&gt;            taProductModel.Fill(productsDS.ProductModel);&lt;br /&gt;        }&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;        &lt;span style="color: blue;"&gt;private&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; productBindingNavigatorSaveItem_Click(&lt;span style="color: blue;"&gt;object&lt;/span&gt; sender, &lt;span style="color: teal;"&gt;EventArgs&lt;/span&gt; e)&lt;br /&gt;        {&lt;br /&gt;            &lt;span style="color: blue;"&gt;this&lt;/span&gt;.Validate();&lt;br /&gt;            &lt;span style="color: blue;"&gt;this&lt;/span&gt;.productBindingSource.EndEdit();&lt;br /&gt;&lt;br /&gt;            ProductTableAdapter taProduct = &lt;span style="color: blue;"&gt;new&lt;/span&gt; ProductTableAdapter();&lt;br /&gt;            taProduct.Update(productsDS.Product);&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:Verdana;"&gt;&lt;br /&gt;Listing 1&lt;br /&gt;&lt;br /&gt;Now let's go to the ProductModelForm form how to create a master/detail oriented form. Let's configure the ProductModel node as Details (see Figure 15).&lt;br /&gt;&lt;br /&gt;&lt;img alt="" src="http://www.c-sharpcorner.com/UploadFile/john_charles/DatabindingtechniquesusingVisualStudioNETandJDeveloper12082008120229PM/Images/Databindingtech15.gif" align="baseline" border="0" hspace="0" /&gt;&lt;br /&gt;&lt;br /&gt;Figure 15&lt;br /&gt;&lt;br /&gt;Then drag and drop the ProductModel onto the ProductModelForm. Then, drag and drop the Product node inside the ProductModel node onto the ProductModelForm. Now we need to add the business logic to fill and update the Product and ProductModel (see Listing 2).&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: Verdana;"&gt;using&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt; System;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: Verdana;"&gt;using&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt; System.Collections.Generic;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: Verdana;"&gt;using&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt; System.ComponentModel;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: Verdana;"&gt;using&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt; System.Data;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: Verdana;"&gt;using&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt; System.Drawing;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: Verdana;"&gt;using&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt; System.Text;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: Verdana;"&gt;using&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt; System.Windows.Forms;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: Verdana;"&gt;using&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt; BusinessLogicCompPkg;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: Verdana;"&gt;using&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt; BusinessLogicCompPkg.ProductsDSTableAdapters;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; color: blue; font-family: Verdana;"&gt;namespace&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt; AppGUI&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;partial&lt;/span&gt; &lt;span style="color: blue;"&gt;class&lt;/span&gt; &lt;span style="color: teal;"&gt;ProductModelForm&lt;/span&gt; : &lt;span style="color: teal;"&gt;Form&lt;br /&gt;&lt;/span&gt;    {&lt;br /&gt;        &lt;span style="color: blue;"&gt;public&lt;/span&gt; ProductModelForm()&lt;br /&gt;        {&lt;br /&gt;            InitializeComponent();&lt;br /&gt;        }&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;        &lt;span style="color: blue;"&gt;private&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; ProductModelForm_Load(&lt;span style="color: blue;"&gt;object&lt;/span&gt; sender, &lt;span style="color: teal;"&gt;EventArgs&lt;/span&gt; e)&lt;br /&gt;        {&lt;br /&gt;            ProductTableAdapter taProduct = &lt;span style="color: blue;"&gt;new&lt;/span&gt; ProductTableAdapter();&lt;br /&gt;            taProduct.Fill(productsDS.Product);&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;            ProductModelTableAdapter taProductModel = &lt;span style="color: blue;"&gt;new&lt;/span&gt; ProductModelTableAdapter();&lt;br /&gt;            taProductModel.Fill(productsDS.ProductModel);&lt;br /&gt;        }&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;        &lt;span style="color: blue;"&gt;private&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; productModelBindingNavigatorSaveItem_Click(&lt;span style="color: blue;"&gt;object&lt;/span&gt; sender, &lt;span style="color: teal;"&gt;EventArgs&lt;/span&gt; e)&lt;br /&gt;        {&lt;br /&gt;            &lt;span style="color: blue;"&gt;this&lt;/span&gt;.Validate();&lt;br /&gt;            &lt;span style="color: blue;"&gt;this&lt;/span&gt;.productModelBindingSource.EndEdit();&lt;br /&gt;            &lt;span style="color: blue;"&gt;this&lt;/span&gt;.productBindingSource.EndEdit();&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;            ProductTableAdapter taProduct = &lt;span style="color: blue;"&gt;new&lt;/span&gt; ProductTableAdapter();&lt;br /&gt;            taProduct.Update(productsDS.Product);&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;            ProductModelTableAdapter taProductModel = &lt;span style="color: blue;"&gt;new&lt;/span&gt; ProductModelTableAdapter();&lt;br /&gt;            taProductModel.Update(productsDS.ProductModel);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:Verdana;"&gt;&lt;br /&gt;Listing 2&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Data binding in JDeveloper&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;In this section, we're going to build a two-tier enterprise application using ADF Business Components as the business layer containing the business logic, validations and business rules and ADF Swing as the presentation layer for gathering and displaying information.&lt;br /&gt;The first step is to start the JDeveloper, and then create a connection to the default ORCL database (shipped with Oracle database installation) using JDBC as the main API to access the relational data source from your application. Go to the Connections Navigator window, right-click on the Database node and choose New Database Connection from the context menu. The Create Database Connection Wizard appears then; click on Next button and in the Step 1 set a name for the connection (see Figure 16). Then click on the Next button.&lt;br /&gt;&lt;br /&gt;&lt;img alt="" src="http://www.c-sharpcorner.com/UploadFile/john_charles/DatabindingtechniquesusingVisualStudioNETandJDeveloper12082008120229PM/Images/Databindingtech16.gif" align="baseline" border="0" hspace="0" /&gt;&lt;br /&gt;&lt;br /&gt;Figure 16&lt;br /&gt;&lt;br /&gt;In the Step 2, you must enter the authentication information (see Figure 17). Click on Next button.&lt;br /&gt;&lt;br /&gt;&lt;img alt="" src="http://www.c-sharpcorner.com/UploadFile/john_charles/DatabindingtechniquesusingVisualStudioNETandJDeveloper12082008120229PM/Images/Databindingtech17.gif" align="baseline" border="0" hspace="0" /&gt;&lt;br /&gt;&lt;br /&gt;Figure 17&lt;br /&gt;&lt;br /&gt;In the Step 3, you must specify the connection details (see Figure 18). Click on Next button.&lt;br /&gt;&lt;br /&gt;&lt;img alt="" src="http://www.c-sharpcorner.com/UploadFile/john_charles/DatabindingtechniquesusingVisualStudioNETandJDeveloper12082008120229PM/Images/Databindingtech18.gif" align="baseline" border="0" hspace="0" /&gt;&lt;br /&gt;&lt;br /&gt;Figure 18&lt;br /&gt;&lt;br /&gt;And finally, you test the created connection.&lt;br /&gt;&lt;br /&gt;Now let's create the application by going to the Applications Navigator, right-click on the Applications node and select New Application from the context menu. In the Create Application dialog box, enter the name for the application, the working directory and the application package prefix (see Figure 19).&lt;br /&gt;&lt;br /&gt;&lt;img alt="" src="http://www.c-sharpcorner.com/UploadFile/john_charles/DatabindingtechniquesusingVisualStudioNETandJDeveloper12082008120229PM/Images/Databindingtech19.gif" align="baseline" border="0" hspace="0" /&gt;&lt;br /&gt;&lt;br /&gt;Figure 19&lt;br /&gt;&lt;br /&gt;Then, create a project for the business logic components (see Figure 20).&lt;br /&gt;&lt;br /&gt;&lt;img alt="" src="http://www.c-sharpcorner.com/UploadFile/john_charles/DatabindingtechniquesusingVisualStudioNETandJDeveloper12082008120229PM/Images/Databindingtech20.gif" align="baseline" border="0" hspace="0" /&gt;&lt;br /&gt;&lt;br /&gt;Figure 20&lt;br /&gt;&lt;br /&gt;Now we're going to create the business components for the business logic module. As illustrative, we're going to use the SCOTT schema shipped with the default installation of Oracle. For this purpose, we're going to create the business entities using ADF Business Components based on tables. In the Application Navigator window, right-click on the business_logic project and select New from the context menu and select Business Components from Tables from the New Gallery dialog box (see Figure 21). Click on OK button.&lt;br /&gt;&lt;br /&gt;&lt;img alt="" src="http://www.c-sharpcorner.com/UploadFile/john_charles/DatabindingtechniquesusingVisualStudioNETandJDeveloper12082008120229PM/Images/Databindingtech21.gif" align="baseline" border="0" hspace="0" /&gt;&lt;br /&gt;&lt;br /&gt;Figure 21&lt;br /&gt;&lt;br /&gt;Then, a window appears where you have to select the connection to the database and click on OK button and then the Create Business Components Wizard appears. Click on Next button; and in the Step 1, you must select a list of tables for which you want to create entity objects. You can also change the name of the business entities by clicking on Selected list and typing the new name in the Entity Name field (see Figure 22). Click on the Next button.&lt;br /&gt;&lt;br /&gt;&lt;img alt="" src="http://www.c-sharpcorner.com/UploadFile/john_charles/DatabindingtechniquesusingVisualStudioNETandJDeveloper12082008120229PM/Images/Databindingtech22.gif" align="baseline" border="0" hspace="0" /&gt;&lt;br /&gt;&lt;br /&gt;Figure 22&lt;br /&gt;&lt;br /&gt;In the Step 2, you can create the views associated to the entities created in the Step 1. Select all the entities and change the name of the views as well as to add them to a new package (see Figure 23). Click on the Next button.&lt;br /&gt;&lt;br /&gt;&lt;img alt="" src="http://www.c-sharpcorner.com/UploadFile/john_charles/DatabindingtechniquesusingVisualStudioNETandJDeveloper12082008120229PM/Images/Databindingtech23.gif" align="baseline" border="0" hspace="0" /&gt;&lt;br /&gt;&lt;br /&gt;Figure 23&lt;br /&gt;&lt;br /&gt;In the Step 3, you can create read-only business entities. In our example, we don't need to create this kind of view. Then click on the Next button. In the Step 4, you set the name for the application module (see Figure 24). The application module bundles together the components and enables transaction support as well as other important data-centric services. Click on the Next button.&lt;br /&gt;&lt;br /&gt;&lt;img alt="" src="http://www.c-sharpcorner.com/UploadFile/john_charles/DatabindingtechniquesusingVisualStudioNETandJDeveloper12082008120229PM/Images/Databindingtech24.gif" align="baseline" border="0" hspace="0" /&gt;&lt;br /&gt;&lt;br /&gt;Figure 24&lt;br /&gt;&lt;br /&gt;In the Step 5, you can specify the diagram of the components and their relationships (see Figure 25).&lt;br /&gt;&lt;br /&gt;&lt;img alt="" src="http://www.c-sharpcorner.com/UploadFile/john_charles/DatabindingtechniquesusingVisualStudioNETandJDeveloper12082008120229PM/Images/Databindingtech25.gif" align="baseline" border="0" hspace="0" /&gt;&lt;br /&gt;&lt;br /&gt;Figure 25&lt;br /&gt;&lt;br /&gt;Click on the Next button, and you can see the result of the Wizard, and finally click on the Finish button.&lt;br /&gt;&lt;br /&gt;Before you create to the presentation layer, let's implement several business logic, format and validation code according to our business requirements. Go to the Applications Navigator and double-click on the Department entity and the Entity Object Editor window appears. Go to the Attributes node to select the attributes to be customized then go the Control Hits tab which enables to specify its format for the graphical presentation of the entity.&lt;br /&gt;&lt;br /&gt;For the Deptno attribute, we have (see Figure 26).&lt;br /&gt;&lt;br /&gt;&lt;img alt="" src="http://www.c-sharpcorner.com/UploadFile/john_charles/DatabindingtechniquesusingVisualStudioNETandJDeveloper12082008120229PM/Images/Databindingtech26.gif" align="baseline" border="0" hspace="0" /&gt;&lt;br /&gt;&lt;br /&gt;Figure 26&lt;br /&gt;&lt;br /&gt;And for the Dnam attribute, we have (see Figure 27).&lt;br /&gt;&lt;br /&gt;&lt;img alt="" src="http://www.c-sharpcorner.com/UploadFile/john_charles/DatabindingtechniquesusingVisualStudioNETandJDeveloper12082008120229PM/Images/Databindingtech27.gif" align="baseline" border="0" hspace="0" /&gt;&lt;br /&gt;&lt;br /&gt;Figure 27&lt;br /&gt;&lt;br /&gt;Finally, for the Loc attribute, we have. We can go on using the same approach for the rest of the attributes of the Employee entity (see Figure 28).&lt;br /&gt;&lt;br /&gt;&lt;img alt="" src="http://www.c-sharpcorner.com/UploadFile/john_charles/DatabindingtechniquesusingVisualStudioNETandJDeveloper12082008120229PM/Images/Databindingtech28.gif" align="baseline" border="0" hspace="0" /&gt;&lt;br /&gt;&lt;br /&gt;Figure 28&lt;br /&gt;&lt;br /&gt;Now let's develop the Presentation Layer components. Go to the Application Navigator and add a new project named client_presentation (see Figure 29).&lt;br /&gt;&lt;br /&gt;&lt;img alt="" src="http://www.c-sharpcorner.com/UploadFile/john_charles/DatabindingtechniquesusingVisualStudioNETandJDeveloper12082008120229PM/Images/Databindingtech29.gif" align="baseline" border="0" hspace="0" /&gt;&lt;br /&gt;&lt;br /&gt;Figure 29&lt;br /&gt;&lt;br /&gt;The right-click on the project and select New from the context menu, go to the Client Tier/ ADF Swing node and select Empty Form as the main form (see Figure 30).&lt;br /&gt;&lt;br /&gt;&lt;img alt="" src="http://www.c-sharpcorner.com/UploadFile/john_charles/DatabindingtechniquesusingVisualStudioNETandJDeveloper12082008120229PM/Images/Databindingtech30.gif" align="baseline" border="0" hspace="0" /&gt;&lt;br /&gt;&lt;br /&gt;Figure 30&lt;br /&gt;&lt;br /&gt;Disable the Generate a menu bar checkbox (because we're going to create a customized menu bar) and set a name for the main form in the Wizard such as MainForm (see Figure 31).&lt;br /&gt;&lt;br /&gt;&lt;img alt="" src="http://www.c-sharpcorner.com/UploadFile/john_charles/DatabindingtechniquesusingVisualStudioNETandJDeveloper12082008120229PM/Images/Databindingtech31.gif" align="baseline" border="0" hspace="0" /&gt;&lt;br /&gt;&lt;br /&gt;Figure 31&lt;br /&gt;&lt;br /&gt;Now let's design the main menu of the application by drag and drop JMenuBar from Components Palette to the form. Then, create a sub-menu named Entities with inner child menus named Employee and Department. Finally, let's add an event handler for the actionPerformed event for the Employee and Department sub-menus (see Figure 32).&lt;br /&gt;&lt;br /&gt;&lt;img alt="" src="http://www.c-sharpcorner.com/UploadFile/john_charles/DatabindingtechniquesusingVisualStudioNETandJDeveloper12082008120229PM/Images/Databindingtech32.gif" align="baseline" border="0" hspace="0" /&gt;&lt;br /&gt;&lt;br /&gt;Figure 32&lt;br /&gt;&lt;br /&gt;Now it's time to add the child forms by right-clicking on the project and selecting New from the context menu (see Figure 33 and Figure 34).&lt;br /&gt;&lt;br /&gt;&lt;img alt="" src="http://www.c-sharpcorner.com/UploadFile/john_charles/DatabindingtechniquesusingVisualStudioNETandJDeveloper12082008120229PM/Images/Databindingtech33.gif" align="baseline" border="0" hspace="0" /&gt;&lt;br /&gt;&lt;br /&gt;Figure 33&lt;br /&gt;&lt;br /&gt;&lt;img alt="" src="http://www.c-sharpcorner.com/UploadFile/john_charles/DatabindingtechniquesusingVisualStudioNETandJDeveloper12082008120229PM/Images/Databindingtech34.gif" align="baseline" border="0" hspace="0" /&gt;&lt;br /&gt;&lt;br /&gt;Figure 34&lt;br /&gt;&lt;br /&gt;Let's work on the EmployeeForm. First of all, select the navigation bar (this is generic for each table) and delete it. Now, go to the Data Control palette, and drag and drop the EmployeeVO1 onto the form, and from the Context Menu select Add Child | Navigation Bar. The go to the Data Control palette and drag and drop the Empno attribute from the EmployeeVO1 node onto the form, and from the Context Menu select Child | Text Field. Repeat this step for each attribute of the EmployeeVO1 node.&lt;br /&gt;&lt;br /&gt;Now let's add a label for each text field to describe it. Go to the Component Palette, select the ADF Swing Controls library, and drag and drop a JULabel onto the form in front of the Empno textfield. Right-click on the JULabel and select Create Binding | Label For from the context menu in order to bind this control to metadata defined on the Business Component Entity Object. When the Attribute Binding Editor window is open, then go to the EmployeeVO1, and choose the Empno attribute (see Figure 35).&lt;br /&gt;&lt;br /&gt;&lt;img alt="" src="http://www.c-sharpcorner.com/UploadFile/john_charles/DatabindingtechniquesusingVisualStudioNETandJDeveloper12082008120229PM/Images/Databindingtech35.gif" align="baseline" border="0" hspace="0" /&gt;&lt;br /&gt;&lt;br /&gt;Figure 35&lt;br /&gt;&lt;br /&gt;Now let's repeat this step for each attribute of the EmployeeVO1 node. It's remarkable to say that in the case of the Depno attribute, actually we don't want to display the department number, instead we want to display the department name using a combo box control which allows to select a from a list of department name. Drag and drop the Deptno attribute on EmployeeVO1 from the Data Control Palette onto the form and then choose Add Child | Combo box. If you run the application, you can see a list of department number.&lt;br /&gt;&lt;br /&gt;In order to bind the department number to department name, you need to set up the underlying binding. Go to the Applications Navigator window, and navigate to the EmployeeFormPageDef.xml and then go to the Structure window, and double-click on the EmployeeVO1Deptno node and the List Binding Editor appears. Select the Dynamic List option, then click on Addâ�?�¦ button and inside the Add Data Source window, select the DepartmentVO1 node (see Figure 36).&lt;br /&gt;&lt;br /&gt;&lt;img alt="" src="http://www.c-sharpcorner.com/UploadFile/john_charles/DatabindingtechniquesusingVisualStudioNETandJDeveloper12082008120229PM/Images/Databindingtech36.gif" align="baseline" border="0" hspace="0" /&gt;&lt;br /&gt;&lt;br /&gt;Figure 36&lt;br /&gt;&lt;br /&gt;Next, you have to map the attributes from the Base Data Source and the List Data Source. Finally, set the Display Attribute to Dept to DName (see Figure 37).&lt;br /&gt;&lt;br /&gt;&lt;img alt="" src="http://www.c-sharpcorner.com/UploadFile/john_charles/DatabindingtechniquesusingVisualStudioNETandJDeveloper12082008120229PM/Images/Databindingtech37.gif" align="baseline" border="0" hspace="0" /&gt;&lt;br /&gt;&lt;br /&gt;Figure 37&lt;br /&gt;&lt;br /&gt;When you run this application which resembles as shown in Figure 38.&lt;br /&gt;&lt;br /&gt;&lt;img alt="" src="http://www.c-sharpcorner.com/UploadFile/john_charles/DatabindingtechniquesusingVisualStudioNETandJDeveloper12082008120229PM/Images/Databindingtech38.gif" align="baseline" border="0" hspace="0" /&gt;&lt;br /&gt;&lt;br /&gt;Figure 38&lt;br /&gt;&lt;br /&gt;The last part of this solution is to show how to create a master/detail oriented form. The first step is to create a form to display department data along with the associated employees using the master/detail concepts related to data binding. This approach is similar to the previous data binding tasks, the only difference is that you will base the binding on the DepartmentVO1 and its inside view EmployeeVO2 (see Figure 39).&lt;br /&gt;&lt;br /&gt;&lt;img alt="" src="http://www.c-sharpcorner.com/UploadFile/john_charles/DatabindingtechniquesusingVisualStudioNETandJDeveloper12082008120229PM/Images/Databindingtech39.gif" align="baseline" border="0" hspace="0" /&gt;&lt;br /&gt;&lt;br /&gt;Figure 39&lt;br /&gt;&lt;br /&gt;After the form is created, we drag and drop the DepartmentVO1 onto the form and select Add Edit Form from the context menu (see Figure 40).&lt;br /&gt;&lt;br /&gt;&lt;img alt="" src="http://www.c-sharpcorner.com/UploadFile/john_charles/DatabindingtechniquesusingVisualStudioNETandJDeveloper12082008120229PM/Images/Databindingtech40.gif" align="baseline" border="0" hspace="0" /&gt;&lt;br /&gt;&lt;br /&gt;Figure 40&lt;br /&gt;&lt;br /&gt;Then, in order to add a child entity in this case the employees associated to their department (the parent), drag and drop the EmployeeVO2 inside the DepartmentVO1 node onto the form and select Add Child | Table from the context menu. In order to navigate inside the table as well, we need to drag and drop the EmployeeVO2 inside the DepartmentVO1 node onto the form and select Add Child | Navigation Bar. Now let's test the application and see how it resembles as shown in Figure 41.&lt;br /&gt;&lt;br /&gt;&lt;img alt="" src="http://www.c-sharpcorner.com/UploadFile/john_charles/DatabindingtechniquesusingVisualStudioNETandJDeveloper12082008120229PM/Images/Databindingtech41.gif" align="baseline" border="0" hspace="0" /&gt;&lt;br /&gt;&lt;br /&gt;Figure 41&lt;br /&gt;&lt;br /&gt;As you can see the last column of the table (showing the department number) is displaying a number and not the department name. We can solve this problem like we did before. Right-click on the Table control and select ADFm Binding Properties and then the Table Binding Editor appears. Then go to the Attribute Properties tab and select the Deptno and map it to a combo box. Finally, click on the configuration button, and the Editor Properties appears (see Figure 42).&lt;br /&gt;&lt;br /&gt;&lt;img alt="" src="http://www.c-sharpcorner.com/UploadFile/john_charles/DatabindingtechniquesusingVisualStudioNETandJDeveloper12082008120229PM/Images/Databindingtech42.gif" align="baseline" border="0" hspace="0" /&gt;&lt;br /&gt;&lt;br /&gt;Figure 42&lt;br /&gt;&lt;br /&gt;By clicking on Create button, the List Binding Editor window appears, and we can configure the same way as we did in the employee form (see Figure 43).&lt;br /&gt;&lt;br /&gt;&lt;img alt="" src="http://www.c-sharpcorner.com/UploadFile/john_charles/DatabindingtechniquesusingVisualStudioNETandJDeveloper12082008120229PM/Images/Databindingtech43.gif" align="baseline" border="0" hspace="0" /&gt;&lt;br /&gt;&lt;br /&gt;Figure 43&lt;br /&gt;&lt;br /&gt;The final step is to deploy the solution to the production environment using a Java Archive file (JAR). To create JAR in JDeveloper, you have to go to the client_presentation project, right-click over it and choose New from the context menu. In the New Gallery window, go to the Deployment Profiles node and select JAR file (see Figure 44).&lt;br /&gt;&lt;br /&gt;&lt;img alt="" src="http://www.c-sharpcorner.com/UploadFile/john_charles/DatabindingtechniquesusingVisualStudioNETandJDeveloper12082008120229PM/Images/Databindingtech44.gif" align="baseline" border="0" hspace="0" /&gt;&lt;br /&gt;&lt;br /&gt;Figure 44&lt;br /&gt;&lt;br /&gt;Then a new profile with the specified name is created on the project and you have to edit it to customize your deployment. In order to create the JAR file from this customized deployment, you go to the project, right-click on the deploy extension file inside the Resources folder and select Deploy to JAR file option (see Figure 45).&lt;br /&gt;&lt;br /&gt;&lt;img alt="" src="http://www.c-sharpcorner.com/UploadFile/john_charles/DatabindingtechniquesusingVisualStudioNETandJDeveloper12082008120229PM/Images/Databindingtech45.gif" align="baseline" border="0" hspace="0" /&gt;&lt;br /&gt;&lt;br /&gt;Figure 45&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Conclusion&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;In this article, I explain how to create data binding oriented applications using Microsoft Visual Studio.NET and Oracle JDeveloper. You can compare both solutions and apply this techniques to your own business scenario.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/ynBt/~4/9YuS8fGL3jU" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://purl.org/atom/app#">2009-01-31T15:14:34.561+05:30</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://dotnetfaqs-edu.blogspot.com/2009/01/data-binding-techniques-using-visual.html</feedburner:origLink></item><item><title>Add an autonumber column in a DataGridView</title><link>http://feedproxy.google.com/~r/blogspot/ynBt/~3/cDp2bsQCR5w/add-autonumber-column-in-datagridview.html</link><category>ado.net</category><author>noreply@blogger.com (Tiru)</author><pubDate>Sat, 31 Jan 2009 01:43:00 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-6426652519813936980.post-6230824631195146548</guid><description>&lt;span style="font-size:100%;"&gt;How to add an autonumber column in a DataGridView control that is populated with a DataTable in simple steps ?&lt;/span&gt; &lt;p dir="ltr" style="margin-right: 0px;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;&lt;img alt="an autonumber column in a DataGridView" src="http://www.c-sharpcorner.com/UploadFile/santowebster/AutonumberingDatatable12102008090717AM/Images/AutonumberingDataTableSampleForm.png" align="baseline" border="0" hspace="0" /&gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style="font-size:100%;"&gt; &lt;/span&gt;&lt;p&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:courier new,courier,mono;"&gt;Figure.1&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:100%;"&gt;The first column in Figure.1 displays sequential row numbers. I have achieved this output by using the following function.&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:courier new,courier,mono;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;private&lt;/span&gt; &lt;span style="color: rgb(0, 128, 128);"&gt;DataTable&lt;/span&gt; AutoNumberedTable(&lt;span style="color: rgb(0, 128, 128);"&gt;DataTable&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new,courier,mono;"&gt; SourceTable)&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:courier new,courier,mono;"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;blockquote dir="ltr" style="margin-right: 0px;"&gt; &lt;p&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:courier new,courier,mono;"&gt;&lt;span style="color: rgb(0, 128, 128);"&gt;DataTable&lt;/span&gt; ResultTable = &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; &lt;span style="color: rgb(0, 128, 128);"&gt;DataTable&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new,courier,mono;"&gt;();&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:courier new,courier,mono;"&gt;&lt;span style="color: rgb(0, 128, 128);"&gt;DataColumn&lt;/span&gt; AutoNumberColumn = &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; &lt;span style="color: rgb(0, 128, 128);"&gt;DataColumn&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new,courier,mono;"&gt;();&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:courier new,courier,mono;"&gt;AutoNumberColumn.ColumnName=&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);font-family:courier new,courier,mono;" &gt;"S.No."&lt;/span&gt;&lt;span style="font-family:courier new,courier,mono;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:courier new,courier,mono;"&gt;AutoNumberColumn.DataType = &lt;/span&gt;&lt;span style="font-family:courier new,courier,mono;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;typeof&lt;/span&gt;(&lt;span style="color: rgb(0, 0, 255);"&gt;int&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new,courier,mono;"&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:courier new,courier,mono;"&gt;AutoNumberColumn.AutoIncrement = &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);font-family:courier new,courier,mono;" &gt;true&lt;/span&gt;&lt;span style="font-family:courier new,courier,mono;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:courier new,courier,mono;"&gt;AutoNumberColumn.AutoIncrementSeed = 1;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:courier new,courier,mono;"&gt;AutoNumberColumn.AutoIncrementStep = 1;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:courier new,courier,mono;"&gt;ResultTable.Columns.Add(AutoNumberColumn);&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:courier new,courier,mono;"&gt;ResultTable.Merge(SourceTable);&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(0, 0, 255);font-family:courier new,courier,mono;" &gt;return&lt;/span&gt;&lt;span style="font-family:courier new,courier,mono;"&gt; ResultTable;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:courier new,courier,mono;"&gt;}&lt;/span&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style="font-size:100%;"&gt;&lt;strong&gt;&lt;/strong&gt;&lt;span style=";font-family:Times New Roman;" &gt; &lt;/span&gt;&lt;/span&gt;&lt;p&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:Times New Roman;" &gt;&lt;span style=";font-family:Verdana,Arial,Helvetica,sans-serif;" &gt;Refer &lt;span style="font-family:courier new,courier,mono;"&gt;http://msdn.microsoft.com/en-us/library/yctw654b.aspx&lt;/span&gt; on &lt;/span&gt;&lt;span style=";font-family:Verdana,Arial,Helvetica,sans-serif;" &gt;How to: Create an Autonumber DataColumn&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:Times New Roman;" &gt;&lt;span style="font-family:times new roman,times,serif;"&gt;&lt;strong&gt;Explanation&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:Times New Roman;" &gt;&lt;span style=";font-family:Verdana,Arial,Helvetica,sans-serif;" &gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;p&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:Times New Roman;" &gt;&lt;span style=";font-family:Verdana,Arial,Helvetica,sans-serif;" &gt;The function receives a DataTable as parameter. It create a Data Table, &lt;b&gt;ResultTable&lt;/b&gt;. Then add a Data Column,&lt;b&gt;AutoNumberColumn &lt;/b&gt;with auto incrementing behaviour. Then the &lt;b&gt;SourceTable &lt;/b&gt;is merged with the &lt;b&gt;ResultTable&lt;/b&gt;. The Merge method will add the rows of the source table to the destimation table one by one. Consequently, autonumber column values are generated as sequential row numbers&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:Times New Roman;" &gt;&lt;b&gt;&lt;span style="font-family:times new roman;"&gt; &lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;p&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:Times New Roman;" &gt;&lt;b&gt;&lt;span style="font-family:times new roman;"&gt;&lt;span style="font-family:times new roman,times,serif;"&gt;Implementation&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style="font-size:100%;"&gt;&lt;span style=";font-family:Times New Roman;" &gt;&lt;span style=";font-family:Verdana,Arial,Helvetica,sans-serif;" &gt; &lt;p&gt;In a few minutes, we will create a Windows Forms Application to test the case. Create a Windows Form and add a DataGridView. Write the following code in the Load event of the form.&lt;/p&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;p&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&lt;span style="font-family:courier new,courier,mono;"&gt;private&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new,courier,mono;"&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;void&lt;/span&gt; Form1_Load(&lt;span style="color: rgb(0, 0, 255);"&gt;object&lt;/span&gt; sender, &lt;span style="color: rgb(0, 128, 128);"&gt;EventArgs&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new,courier,mono;"&gt; e)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-family:courier new,courier,mono;"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;dir&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;p&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&lt;span style="font-family:courier new,courier,mono;"&gt;using&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new,courier,mono;"&gt;(&lt;span style="color: rgb(0, 128, 128);"&gt;SqlConnection&lt;/span&gt; Connection=&lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; &lt;span style="color: rgb(0, 128, 128);"&gt;SqlConnection&lt;/span&gt;(&lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new,courier,mono;"&gt;.ConnectionString))&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-family:courier new,courier,mono;"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;dir&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;p&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&lt;span style="font-family:courier new,courier,mono;"&gt;using&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new,courier,mono;"&gt; (&lt;span style="color: rgb(0, 128, 128);"&gt;SqlCommand&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new,courier,mono;"&gt; Command= Connection.CreateCommand())&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-family:courier new,courier,mono;"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;dir&gt; &lt;p&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-family:courier new,courier,mono;"&gt;Command.CommandText = &lt;/span&gt;&lt;span style="font-family:courier new,courier,mono;"&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;"SELECT * FROM [myTable]"&lt;/span&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;&lt;span style="color: rgb(0, 128, 128);"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;p&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;&lt;span style="color: rgb(0, 128, 128);"&gt;&lt;span style="font-family:courier new,courier,mono;"&gt;SqlDataAdapter &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new,courier,mono;"&gt;dataAdapter=&lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; &lt;span style="color: rgb(0, 128, 128);"&gt;SqlDataAdapter&lt;/span&gt;(Command);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;&lt;span style="color: rgb(0, 128, 128);"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;p&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;&lt;span style="color: rgb(0, 128, 128);"&gt;&lt;span style="font-family:courier new,courier,mono;"&gt;DataTable&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new,courier,mono;"&gt; dataTable = &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; &lt;span style="color: rgb(0, 128, 128);"&gt;DataTable&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new,courier,mono;"&gt;();&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-family:courier new,courier,mono;"&gt;dataAdapter.Fill(dataTable);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;p&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&lt;span style="font-family:courier new,courier,mono;"&gt;this&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new,courier,mono;"&gt;.dataGridView1.DataSource = AutoNumberedTable(dataTable);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/dir&gt; &lt;p&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-family:courier new,courier,mono;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/dir&gt; &lt;p&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-family:courier new,courier,mono;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/dir&gt; &lt;p&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-family:courier new,courier,mono;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&lt;span style=";font-family:'Verdana','sans-serif';" &gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;o:p&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;Then add the &lt;b&gt;ConnectionString &lt;/b&gt;property given below and &lt;b&gt;AutoNumberedTable &lt;/b&gt;function given above in the body of the form. Run the program. See what happens!&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&lt;span style="font-family:courier new,courier,mono;"&gt;private&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new,courier,mono;"&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new,courier,mono;"&gt; ConnectionString&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-family:courier new,courier,mono;"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;dir&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;&lt;span style="color: rgb(0, 0, 255);font-family:courier new,courier,mono;" &gt; &lt;p&gt;get&lt;/p&gt;&lt;/span&gt; &lt;/span&gt;&lt;/span&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-family:courier new,courier,mono;"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;dir&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;&lt;span style="color: rgb(0, 128, 128);"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;&lt;span style="color: rgb(0, 128, 128);"&gt;&lt;span style="font-family:courier new,courier,mono;"&gt;SqlConnectionStringBuilder&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new,courier,mono;"&gt; ConnectionBuilder = &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; &lt;span style="color: rgb(0, 128, 128);"&gt;SqlConnectionStringBuilder&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new,courier,mono;"&gt;();&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-family:courier new,courier,mono;"&gt;ConnectionBuilder.DataSource = &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);font-family:courier new,courier,mono;" &gt;"myDataSource"&lt;/span&gt;&lt;span style="font-family:courier new,courier,mono;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-family:courier new,courier,mono;"&gt;ConnectionBuilder.InitialCatalog = &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);font-family:courier new,courier,mono;" &gt;"myDatabase"&lt;/span&gt;&lt;span style="font-family:courier new,courier,mono;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-family:courier new,courier,mono;"&gt;ConnectionBuilder.UserID = &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);font-family:courier new,courier,mono;" &gt;"myUserID"&lt;/span&gt;&lt;span style="font-family:courier new,courier,mono;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-family:courier new,courier,mono;"&gt;ConnectionBuilder.Password = &lt;/span&gt;&lt;span style="font-family:courier new,courier,mono;"&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;"myPassword"&lt;/span&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&lt;span style="font-family:courier new,courier,mono;"&gt;return&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new,courier,mono;"&gt; ConnectionBuilder.ToString();&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/dir&gt; &lt;p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-family:courier new,courier,mono;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/dir&gt; &lt;p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-family:courier new,courier,mono;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;&lt;span style="color: rgb(0, 128, 128);"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;&lt;span style="color: rgb(0, 128, 128);"&gt;SqlConnectionStringBuilder&lt;/span&gt; provides a simple way to create and manage the contents of connection strings. &lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;Refer &lt;span style="font-family:courier new,courier,mono;"&gt;http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnectionstringbuilder(VS.80).aspx&lt;/span&gt;&lt;span style="font-family:courier new,courier,mono;"&gt; &lt;/span&gt;on SqlConnectionStringBuilder Class&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;&lt;span style=";font-family:Times New Roman;" &gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;&lt;span style=";font-family:Times New Roman;" &gt;&lt;strong&gt;Details of Sample Application Seen in Figure.1&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;&lt;span style=";font-family:Times New Roman;" &gt;&lt;b&gt; &lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;&lt;span style=";font-family:Times New Roman;" &gt;&lt;b&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;Database&lt;/span&gt; &lt;/b&gt;: &lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;Pubs&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;&lt;span style=";font-family:Times New Roman;" &gt;&lt;b&gt; &lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;&lt;span style=";font-family:Times New Roman;" &gt;&lt;b&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;Query&lt;/span&gt; &lt;/b&gt;: &lt;span style="font-family:courier new,courier,mono;"&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;"&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;SELECT au_fname + ' ' + au_lname as [Name of Author],City FROM AUTHORS&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;"&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;&lt;span style=";font-family:Times New Roman;" &gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;Add the following namespaces on top.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;dir&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;&lt;span style=";font-family:Times New Roman;" &gt;&lt;span style="color: rgb(0, 0, 255);font-family:courier new;" &gt;&lt;span style="color: rgb(0, 0, 255);"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;&lt;span style=";font-family:Times New Roman;" &gt;&lt;span style="color: rgb(0, 0, 255);font-family:courier new;" &gt;&lt;span style="color: rgb(0, 0, 255);"&gt;using&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; System;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;&lt;span style=";font-family:Times New Roman;" &gt;&lt;span style="color: rgb(0, 0, 255);font-family:courier new;" &gt;&lt;span style="color: rgb(0, 0, 255);"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;&lt;span style=";font-family:Times New Roman;" &gt;&lt;span style="color: rgb(0, 0, 255);font-family:courier new;" &gt;&lt;span style="color: rgb(0, 0, 255);"&gt;using&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; System.Data;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;&lt;span style=";font-family:Times New Roman;" &gt;&lt;span style="color: rgb(0, 0, 255);font-family:courier new;" &gt;&lt;span style="color: rgb(0, 0, 255);"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;&lt;span style=";font-family:Times New Roman;" &gt;&lt;span style="color: rgb(0, 0, 255);font-family:courier new;" &gt;&lt;span style="color: rgb(0, 0, 255);"&gt;using&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; System.Data.SqlClient;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;&lt;span style=";font-family:Times New Roman;" &gt;&lt;span style="color: rgb(0, 0, 255);font-family:courier new;" &gt;&lt;span style="color: rgb(0, 0, 255);"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;&lt;span style=";font-family:Times New Roman;" &gt;&lt;span style="color: rgb(0, 0, 255);font-family:courier new;" &gt;&lt;span style="color: rgb(0, 0, 255);"&gt;using&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; System.Windows.Forms;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/dir&gt; &lt;p style="margin-right: 0px;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;&lt;span style=";font-family:Times New Roman;" &gt;&lt;span style=";font-family:courier new;" &gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;Happy Coding! Happy Dotneting!&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/ynBt/~4/cDp2bsQCR5w" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://purl.org/atom/app#">2009-01-31T15:13:00.432+05:30</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://dotnetfaqs-edu.blogspot.com/2009/01/add-autonumber-column-in-datagridview.html</feedburner:origLink></item><item><title>C# Image Button</title><link>http://feedproxy.google.com/~r/blogspot/ynBt/~3/CebhgZGOotQ/c-image-button.html</link><category>C#.NET Articles</category><author>noreply@blogger.com (Tiru)</author><pubDate>Sat, 31 Jan 2009 01:35:47 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-6426652519813936980.post-3677488834393633967</guid><description>&lt;h2 style="text-align: left;"&gt;&lt;span style="font-weight: bold;font-size:100%;" &gt;.NET Image Button&lt;/span&gt;&lt;/h2&gt;&lt;div style="text-align: left;"&gt;                     &lt;/div&gt;&lt;p style="text-align: left;" class="style16 style21"&gt;Adding a &lt;strong&gt;C# image button &lt;/strong&gt;became incredibly easy with .NET Framework 2.0 and up. An image-button is a way to create a user-friendly .NET user interface.&lt;/p&gt;&lt;p style="text-align: left;" class="style16 style21"&gt;As with many .NET controls, the key is setting the correct Properties.&lt;/p&gt;&lt;div style="text-align: left;"&gt;           &lt;/div&gt;&lt;h2 style="text-align: left;" class="style16 style27"&gt;&lt;span style="font-size:130%;"&gt;&lt;strong&gt;Image Property&lt;/strong&gt;&lt;/span&gt;&lt;/h2&gt;&lt;div style="text-align: left;"&gt;               &lt;/div&gt;&lt;p style="text-align: left;" class="style16 style21"&gt;The first property you want to modify is &lt;span class="style35"&gt;Image&lt;/span&gt;. The image will have to be a resource of the Form. However it is a good idea in most cases to let it be a project resource so the image can accessed anywhere in the project.&lt;/p&gt;&lt;div style="text-align: left;"&gt;               &lt;/div&gt;&lt;h2 style="text-align: left;" class="style16 style27"&gt;&lt;span style="font-size:130%;"&gt;&lt;strong&gt;TextImageRelation&lt;/strong&gt;&lt;/span&gt;&lt;/h2&gt;&lt;div style="text-align: left;"&gt;               &lt;/div&gt;&lt;p style="text-align: left;" class="style16 style21"&gt;This is a great .NET control property: &lt;span class="style35"&gt;TextImageRelation&lt;/span&gt;. It has 5 options and they are pretty self-explanatory. Basically it denotes the order in which text and image of a C# button are rendered. Here is some different looks that can be achieved:&lt;/p&gt;&lt;div style="text-align: left;"&gt;               &lt;/div&gt;&lt;p style="text-align: left;"&gt;&lt;img src="http://www.vcskicks.com/images/image-button.png" alt="C# image button" width="134" border="0" height="111" /&gt;&lt;/p&gt;&lt;div style="text-align: left;"&gt;           &lt;/div&gt;&lt;p style="text-align: left;" class="style16 style21"&gt;It is not a good idea to set TextImageRelation to &lt;span class="style35"&gt;Overlay&lt;/span&gt; if your .NET button has both text and an image since the text won't be readable. However if the button has no text, it looks good:&lt;/p&gt;&lt;div style="text-align: left;"&gt;           &lt;/div&gt;&lt;p style="text-align: left;" class="style16 style21"&gt;&lt;img src="http://www.vcskicks.com/images/image-button2.png" alt="c# image button" width="46" border="0" height="38" /&gt;&lt;/p&gt;&lt;div style="text-align: left;"&gt;           &lt;/div&gt;&lt;p style="text-align: left;" class="style16 style21"&gt;Of course since these are .NET control properties we are talking about, they can updated run-time, opening up a world of possibilites. For example, a series of menu buttons can have the option of displaying text along side each icon or just displaying the icon.&lt;/p&gt;&lt;h2 style="text-align: left;" class="style16 style27"&gt;&lt;span style="font-size:130%;"&gt;&lt;strong&gt;.NET Button&lt;/strong&gt;&lt;/span&gt;&lt;/h2&gt;&lt;div style="text-align: left;"&gt;               &lt;/div&gt;&lt;p style="text-align: left;" class="style16 style21"&gt;So as you can see it does not take too much work to have a great looking .NET image button. Starting from the .NET Framework 2.0 these image buttons are fairly constant with different FlatStyle and versions of Windows.&lt;/p&gt;&lt;div style="text-align: left;"&gt;               &lt;/div&gt;&lt;p style="text-align: left;" class="style16 style21"&gt;However one "problem" is that the button is tied to Windows' version. An image button might look very good in Windows Vista or Windows 7 but might not look as eye-candy in older versions of Windows. For those looking for a more constant look across versions would have to turn to code-generated .NET buttons.&lt;/p&gt;&lt;div style="text-align: left;"&gt;               &lt;/div&gt;&lt;p style="text-align: left;" class="style16 style21"&gt;And finally, in order to get a good-looking &lt;strong&gt;C# image button &lt;/strong&gt;you are going to need good icons. Here is where many programmers considering investing in professional icons.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/ynBt/~4/CebhgZGOotQ" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://purl.org/atom/app#">2009-01-31T15:05:47.313+05:30</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://dotnetfaqs-edu.blogspot.com/2009/01/c-image-button.html</feedburner:origLink></item><item><title>Create Dynamic Image Buttons</title><link>http://feedproxy.google.com/~r/blogspot/ynBt/~3/C9uz7Ik6W_0/create-dynamic-image-buttons.html</link><category>ASP.NET Controls</category><author>noreply@blogger.com (Tiru)</author><pubDate>Mon, 05 Jan 2009 20:28:12 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-6426652519813936980.post-212013020825071512</guid><description>&lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;&lt;img alt="" src="http://www.c-sharpcorner.com/UploadFile/slightly/DynamicImageButtons06072005043554AM/Images/screen_shot.gif" align="baseline" border="0" hspace="0" /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;Introduction&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;"&gt;We've all had that problem - designing our web sites to have a certain look and feel. Unfortunately, not every visitor will view the site the way you intended. This is due to the fact that different operating systems render native browser controls differently. The buttons in OS X have the aqua look while the buttons in Windows 2000 look gray and outdated. &lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;Using the AnyButton&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;"&gt;Until now, to enforce a consistent look, a popular option is using images as buttons. This is a great alternative except that when it comes time to add new buttons or modify existing ones, you better have Photoshop [and the time] handy to get it done. &lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;"&gt;I've created a control called the AnyButton which derives from System.Web.UI.WebControls.ImageButton. This button uses image templates as skins. It will take a .jpg, .gif or .png as a template. It is really easy to use, and best of all, looks just like a real button. &lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;"&gt;The control takes in a single image as a template. The button supports 3 different states - default, hover, and press. Moreover, each button supports 3 different skins - 1 for each state. This allows you to create as many types of buttons as you'd like by subclassing the base Button class. For instance, you could have an XPButton, AquaButton, AmazonComButton, etc. The best part is, you don't have to use Photoshop to create your buttons - if you see a button on a site you like, screen shot it, crop out the middle part and you're pretty much ready to go. &lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;"&gt;Here's an example using the XP button as a skin: &lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;"&gt;This is the default state template that I will assign to the button&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;"&gt;&lt;img alt="" src="http://www.c-sharpcorner.com/UploadFile/slightly/DynamicImageButtons06072005043554AM/Images/default.png" align="baseline" border="0" hspace="0" /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;"&gt;This is the hover state template that I will assign to the button&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;"&gt;&lt;img alt="" src="http://www.c-sharpcorner.com/UploadFile/slightly/DynamicImageButtons06072005043554AM/Images/hover.png" align="baseline" border="0" hspace="0" /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;"&gt;And this is the press state template that I will assign to the button&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;"&gt;&lt;img alt="" src="http://www.c-sharpcorner.com/UploadFile/slightly/DynamicImageButtons06072005043554AM/Images/press.png" align="baseline" border="0" hspace="0" /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;"&gt;As you can see, the red lines dictate how to slice the button. These lines must be the exact RGB color 255, 0, 0 or #FF0000. &lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;"&gt;Each button has a ButtonConfig class as a property. The ButtonConfig class contains all the information about the button templates. Here's an example using all button states, generating a button that resembles the XP Silver button:&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;p&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;"&gt;&lt;span style="color:#808080;"&gt;///&lt;/span&gt;&lt;span style="color:#008000;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;"&gt;&lt;span style="color:#808080;"&gt;&lt;summary&gt;
&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#808080;"&gt;///&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;"&gt;&lt;span style="color:#008000;"&gt; Default button templated to resemble the XP Button
&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#808080;"&gt;///&lt;/span&gt;&lt;span style="color:#008000;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;"&gt;&lt;span style="color:#808080;"&gt;&lt;/summary&gt;
&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;class&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;"&gt; XPButton : AnyButton
&lt;br /&gt;{
&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;"&gt; XPButton()
&lt;br /&gt;{
&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;.EnableHover = &lt;span style="color:#0000ff;"&gt;true&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;"&gt;;
&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;.EnablePress = &lt;span style="color:#0000ff;"&gt;true&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;"&gt;;
&lt;br /&gt;}
&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;"&gt; XPButton(Page page)
&lt;br /&gt;{
&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;"&gt;.Page = page;
&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;.EnableHover = &lt;span style="color:#0000ff;"&gt;true&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;"&gt;;
&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;.EnablePress = &lt;span style="color:#0000ff;"&gt;true&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;"&gt;;
&lt;br /&gt;}
&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;protected&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;override&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;"&gt; OnInit(EventArgs e)
&lt;br /&gt;{
&lt;br /&gt;Initialize();
&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;base&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;"&gt;.OnInit(e);
&lt;br /&gt;}
&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;protected&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;override&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;"&gt; OnLoad(EventArgs e)
&lt;br /&gt;{
&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;base&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;"&gt;.OnLoad(e);
&lt;br /&gt;}
&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;protected&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;"&gt; Initialize()
&lt;br /&gt;{
&lt;br /&gt;Font f = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;"&gt; Font("Tahoma", 8, FontStyle.Regular);
&lt;br /&gt;ButtonConfig buttonConfig = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;"&gt; ButtonConfig();
&lt;br /&gt;buttonConfig.TemplatePath = &lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;"&gt;.AbsResourcesPath + "/default.png";
&lt;br /&gt;buttonConfig.Font = f;
&lt;br /&gt;buttonConfig.VerticalTextOffset = 1;
&lt;br /&gt;buttonConfig.FontColor = Color.Black;
&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;"&gt;.Config = buttonConfig;
&lt;br /&gt;ButtonConfig hoverConfig = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;"&gt; ButtonConfig();
&lt;br /&gt;hoverConfig.TemplatePath = &lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;"&gt;.AbsResourcesPath + "/hover.png";
&lt;br /&gt;hoverConfig.Font = buttonConfig.Font;
&lt;br /&gt;hoverConfig.VerticalTextOffset = buttonConfig.VerticalTextOffset;
&lt;br /&gt;hoverConfig.FontColor = buttonConfig.FontColor;
&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;"&gt;.HoverConfig = hoverConfig;
&lt;br /&gt;ButtonConfig pressConfig = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;"&gt; ButtonConfig();
&lt;br /&gt;pressConfig.TemplatePath = &lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;"&gt;.AbsResourcesPath + "/press.png";
&lt;br /&gt;pressConfig.VerticalTextOffset = buttonConfig.VerticalTextOffset + 1;
&lt;br /&gt;pressConfig.HorizontalTextOffset = buttonConfig.VerticalTextOffset + 1;
&lt;br /&gt;pressConfig.Font = hoverConfig.Font;
&lt;br /&gt;pressConfig.FontColor = buttonConfig.FontColor;
&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;"&gt;.PressConfig = pressConfig;
&lt;br /&gt;}
&lt;br /&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;This example is pretty straight forward. One thing to note is the VerticalTextOffset and HorizontalTextOffset properties being utilized in the press config. To get a true pressed effect, the text should move to the bottom right 1 pixel by 1 pixel. &lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;This XPButton class comes packaged along with the AnyButton assembly. When the buttons are requested, they need to be saved to a directory. The path to this output directory is defined in the web.config file as follows:&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;p&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;"&gt;&lt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;color:#800000;"&gt;appSettings&lt;/span&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;"&gt;&lt;span style="color:#0000ff;"&gt;&gt;
&lt;br /&gt;&lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;add&lt;/span&gt;&lt;span style="color:#ff00ff;"&gt; &lt;/span&gt;&lt;span style="color:#ff0000;"&gt;key&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Oxford.Web.AnyButton.OutputPath"&lt;/span&gt;&lt;span style="color:#ff00ff;"&gt; &lt;/span&gt;&lt;span style="color:#ff0000;"&gt;value&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="~/resources/"&lt;/span&gt;&lt;span style="color:#ff00ff;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;"&gt;&lt;span style="color:#0000ff;"&gt;/&gt;
&lt;br /&gt;&lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;appSettings&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;color:#000000;"&gt;In this example, I'm setting the output path to be the in the /resources folder of my web application root. This setting must exist or a null reference exception will be thrown. The ASPNET user must have read/write access to this directory. &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;color:#000000;"&gt;So far so good, right? Using the control is the easiest part. Have a look:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;&lt;span style="font-size:85%;color:#000000;"&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;p&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="color:#000000;"&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;"&gt;&lt;%@ Register TagPrefix="btn" Namespace="MyNamespace" Assembly="MyAssembly" %&gt;
&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;"&gt;&lt;span style="color:#0000ff;"&gt;&lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;btn:XPButton&lt;/span&gt;&lt;span style="color:#ff00ff;"&gt; &lt;/span&gt;&lt;span style="color:#ff0000;"&gt;Runat&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="server"&lt;/span&gt;&lt;span style="color:#ff00ff;"&gt; &lt;/span&gt;&lt;span style="color:#ff0000;"&gt;Text&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Click Me"/&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;&lt;span style="font-size:85%;color:#000000;"&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;color:#000000;"&gt;The last thing you need to do is add This is the result of the previous call:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;&lt;span style="font-size:85%;color:#000000;"&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;color:#000000;"&gt;&lt;img alt="" src="http://www.c-sharpcorner.com/UploadFile/slightly/DynamicImageButtons06072005043554AM/Images/click_me.png" align="baseline" border="0" hspace="0" /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;&lt;span style="font-size:85%;color:#000000;"&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;color:#000000;"&gt;&lt;img alt="" src="http://www.c-sharpcorner.com/UploadFile/slightly/DynamicImageButtons06072005043554AM/Images/click_me_hover.png" align="baseline" border="0" hspace="0" /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-size:85%;color:#0000ff;"&gt;&lt;span style="font-size:85%;color:#000000;"&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;color:#000000;"&gt;&lt;img alt="" src="http://www.c-sharpcorner.com/UploadFile/slightly/DynamicImageButtons06072005043554AM/Images/click_me_press.png" align="baseline" border="0" hspace="0" /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="color:#000000;"&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;color:#000000;"&gt;As you can see, 3 images where created; 1 for each state. Any subsequent requests for an XPButton with text "Click Me" will now be redirected to the already-generated button image. To clear the cache of images, simply delete the output directory. &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="color:#000000;"&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;color:#000000;"&gt;&lt;strong&gt;Additional Properties:&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;ul&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="color:#000000;"&gt;&lt;li&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;color:#000000;"&gt;AlphaPng
&lt;br /&gt;If you are using png files and you want to enforce transparency, set the AlphaPng setting to true. This is necessary because IE does not support alpha png (right on MS). When AlphaPng is true, a special css filter will be added only to IE users (Firefox, Safari, etc users will not be affected). &lt;/span&gt; &lt;/li&gt;&lt;li&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;color:#000000;"&gt;TextWidth
&lt;br /&gt;Use this property when you want to enforce a certain width regardless of actual width of the text. &lt;/span&gt; &lt;/li&gt;&lt;li&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;color:#000000;"&gt;OnClientClick
&lt;br /&gt;Handy little property that can be set in the markup adding client side function call when the button is pressed. &lt;/span&gt; &lt;/li&gt;&lt;li&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;color:#000000;"&gt;AntiAliasText
&lt;br /&gt;True by default, applies anti-aliasing and ClearType effect. &lt;/span&gt; &lt;/li&gt;&lt;li&gt;&lt;span style="color:#0000ff;"&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;color:#000000;"&gt;CausesPostback
&lt;br /&gt;By default, an ImageButton (from which this control derrives) is a submit button. To disable posting back, set this CausesPostback to false.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/ul&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/ynBt/~4/C9uz7Ik6W_0" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://purl.org/atom/app#">2009-01-06T09:58:12.675+05:30</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://dotnetfaqs-edu.blogspot.com/2009/01/create-dynamic-image-buttons.html</feedburner:origLink></item><item><title>File uploader in C#</title><link>http://feedproxy.google.com/~r/blogspot/ynBt/~3/juBB1vTldCw/file-uploader-in-c.html</link><category>ASP.NET Controls</category><author>noreply@blogger.com (Tiru)</author><pubDate>Mon, 05 Jan 2009 20:25:37 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-6426652519813936980.post-5097455759200011632</guid><description>&lt;p&gt;&lt;span style="font-size:85%;"&gt;This is very basic level small user control, in which we can discuss how to create web user control.&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;To create user controls follow the steps:&lt;/span&gt;&lt;/p&gt; &lt;ol&gt;&lt;span style="font-size:85%;"&gt;&lt;li&gt;Right click on project  &lt;/li&gt;&lt;li&gt;Click on Add  &lt;/li&gt;&lt;li&gt;Select New Item  &lt;/li&gt;&lt;li&gt;Select Web User Control  &lt;/li&gt;&lt;li&gt;Specify some Name&lt;/li&gt;&lt;/span&gt;&lt;/ol&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;I have given name to this file as "uploader.ascx" and kept this file under "userControl" for simplicity purpose.&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;On this page I am having following controls:&lt;/span&gt;&lt;/p&gt; &lt;ol&gt;&lt;span style="font-size:85%;"&gt;&lt;li&gt;&lt;span style="font-size:100%;color:#0000ff;"&gt; &lt;/span&gt;&lt;p&gt;&lt;span style="font-size:100%;color:#0000ff;"&gt;&lt;span style="font-size:85%;"&gt;&lt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:100%;color:#800000;"&gt;INPUT&lt;/span&gt;&lt;span style="font-size:100%;color:#ff00ff;"&gt; &lt;/span&gt;&lt;span style="font-size:100%;color:#ff0000;"&gt;id&lt;/span&gt;&lt;span style="font-size:100%;color:#0000ff;"&gt;="fileUpload"&lt;/span&gt;&lt;span style="font-size:100%;color:#ff00ff;"&gt; &lt;/span&gt;&lt;span style="font-size:100%;color:#ff0000;"&gt;type&lt;/span&gt;&lt;span style="font-size:100%;color:#0000ff;"&gt;="file"&lt;/span&gt;&lt;span style="font-size:100%;color:#ff00ff;"&gt; &lt;/span&gt;&lt;span style="font-size:100%;color:#ff0000;"&gt;Runat&lt;/span&gt;&lt;span style="font-size:100%;color:#0000ff;"&gt;="server"&lt;/span&gt;&lt;span style="font-size:100%;color:#ff00ff;"&gt; &lt;/span&gt;&lt;span style="font-size:100%;color:#ff0000;"&gt;NAME&lt;/span&gt;&lt;span style="font-size:100%;color:#0000ff;"&gt;&lt;span style="font-size:85%;"&gt;="fileUpload"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;/li&gt;&lt;li&gt;&lt;span style="font-size:100%;color:#0000ff;"&gt; &lt;/span&gt;&lt;p&gt;&lt;span style="font-size:100%;color:#0000ff;"&gt;&lt;span style="font-size:85%;"&gt;&lt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:100%;color:#800000;"&gt;asp:label&lt;/span&gt;&lt;span style="font-size:100%;color:#ff00ff;"&gt; &lt;/span&gt;&lt;span style="font-size:100%;color:#ff0000;"&gt;id&lt;/span&gt;&lt;span style="font-size:100%;color:#0000ff;"&gt;="lblMessage"&lt;/span&gt;&lt;span style="font-size:100%;color:#ff00ff;"&gt; &lt;/span&gt;&lt;span style="font-size:100%;color:#ff0000;"&gt;runat&lt;/span&gt;&lt;span style="font-size:100%;color:#0000ff;"&gt;="server"&lt;/span&gt;&lt;span style="font-size:100%;color:#ff00ff;"&gt; &lt;/span&gt;&lt;span style="font-size:100%;color:#ff0000;"&gt;Width&lt;/span&gt;&lt;span style="font-size:100%;color:#0000ff;"&gt;="416px"&lt;/span&gt;&lt;span style="font-size:100%;color:#ff00ff;"&gt; &lt;/span&gt;&lt;span style="font-size:100%;color:#ff0000;"&gt;Font-Size&lt;/span&gt;&lt;span style="font-size:100%;color:#0000ff;"&gt;="10"&lt;/span&gt;&lt;span style="font-size:100%;color:#ff00ff;"&gt; &lt;/span&gt;&lt;span style="font-size:100%;color:#ff0000;"&gt;Font-Name&lt;/span&gt;&lt;span style="font-size:100%;color:#0000ff;"&gt;="verdana"&gt;&lt;/&lt;/span&gt;&lt;span style="font-size:100%;color:#800000;"&gt;asp:label&lt;/span&gt;&lt;span style="font-size:100%;color:#0000ff;"&gt;&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;  &lt;/span&gt;&lt;/p&gt; &lt;/li&gt;&lt;li&gt;&lt;span style="font-size:100%;color:#0000ff;"&gt; &lt;/span&gt;&lt;p&gt;&lt;span style="font-size:100%;color:#0000ff;"&gt;&lt;span style="font-size:85%;"&gt;&lt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:100%;color:#800000;"&gt;asp:button&lt;/span&gt;&lt;span style="font-size:100%;color:#ff00ff;"&gt; &lt;/span&gt;&lt;span style="font-size:100%;color:#ff0000;"&gt;id&lt;/span&gt;&lt;span style="font-size:100%;color:#0000ff;"&gt;="btnSave"&lt;/span&gt;&lt;span style="font-size:100%;color:#ff00ff;"&gt; &lt;/span&gt;&lt;span style="font-size:100%;color:#ff0000;"&gt;runat&lt;/span&gt;&lt;span style="font-size:100%;color:#0000ff;"&gt;="server"&lt;/span&gt;&lt;span style="font-size:100%;color:#ff00ff;"&gt; &lt;/span&gt;&lt;span style="font-size:100%;color:#ff0000;"&gt;Text&lt;/span&gt;&lt;span style="font-size:100%;color:#0000ff;"&gt;="Upload.."&gt;&lt;/&lt;/span&gt;&lt;span style="font-size:100%;color:#800000;"&gt;asp:button&lt;/span&gt;&lt;span style="font-size:100%;color:#0000ff;"&gt;&gt;&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;/span&gt;&lt;/ol&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;At the code behind of above file I am having following function&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; color: blue; font-family: Verdana;"&gt;public&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt; &lt;span style="color: blue;"&gt;string&lt;/span&gt; uploadFile(&lt;span style="color: blue;"&gt;string&lt;/span&gt; fileName,&lt;span style="color: blue;"&gt;string&lt;/span&gt; folderName)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;{ &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;&lt;span style=""&gt;          &lt;/span&gt;&lt;span style="color: blue;"&gt;if&lt;/span&gt;(fileName=="")&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;&lt;span style=""&gt;          &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;&lt;span style=""&gt;          &lt;/span&gt;&lt;span style=""&gt;          &lt;/span&gt;&lt;span style="color: blue;"&gt;return&lt;/span&gt; "Invalid filename supplied";&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;&lt;span style=""&gt;          &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;&lt;span style=""&gt;          &lt;/span&gt;&lt;span style="color: blue;"&gt;if&lt;/span&gt;(fileUpload.PostedFile.ContentLength==0)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;&lt;span style=""&gt;          &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;&lt;span style=""&gt;          &lt;/span&gt;&lt;span style=""&gt;          &lt;/span&gt;&lt;span style="color: blue;"&gt;return&lt;/span&gt; "Invalid file content";&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;&lt;span style=""&gt;          &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;&lt;span style=""&gt;          &lt;/span&gt;&lt;span style=""&gt;          &lt;/span&gt;fileName = System.IO.Path.GetFileName(fileName);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; text-indent: 0.5in;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;&lt;span style=""&gt;          &lt;/span&gt;&lt;span style="color: blue;"&gt;if&lt;/span&gt;(folderName=="")&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;&lt;span style=""&gt;          &lt;/span&gt;&lt;span style=""&gt;          &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; text-indent: 0.5in;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;&lt;span style=""&gt;          &lt;/span&gt;&lt;span style=""&gt;          &lt;/span&gt;&lt;span style="color: blue;"&gt;return&lt;/span&gt; "Path not found";&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;&lt;span style=""&gt;          &lt;/span&gt;&lt;span style=""&gt;          &lt;/span&gt;}&lt;span style=""&gt;   &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;&lt;span style=""&gt;          &lt;/span&gt;&lt;span style=""&gt;          &lt;/span&gt;&lt;span style="color: blue;"&gt;try&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;&lt;span style=""&gt;          &lt;/span&gt;&lt;span style=""&gt;          &lt;/span&gt;{ &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; text-indent: 0.5in;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;&lt;span style=""&gt;          &lt;/span&gt;&lt;span style=""&gt;          &lt;/span&gt;&lt;span style="color: blue;"&gt;if&lt;/span&gt; (fileUpload.PostedFile.ContentLength&lt;=2048000)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;&lt;span style=""&gt;          &lt;/span&gt;&lt;span style=""&gt;          &lt;/span&gt;&lt;span style=""&gt;          &lt;/span&gt;{&lt;span style=""&gt;     &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt 1in; text-indent: 0.5in;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;&lt;span style=""&gt;          &lt;/span&gt;fileUpload.PostedFile.SaveAs(Server.MapPath(folderName)+"\\"+fileName);&lt;span style=""&gt;     &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;&lt;span style=""&gt;                   &lt;/span&gt;&lt;span style=""&gt;          &lt;/span&gt;&lt;span style=""&gt;          &lt;/span&gt;&lt;span style="color: blue;"&gt;return&lt;/span&gt; "File uploaded successfully";&lt;span style=""&gt;     &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;&lt;span style=""&gt;                   &lt;/span&gt;&lt;span style=""&gt;          &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;&lt;span style=""&gt;                   &lt;/span&gt;&lt;span style=""&gt;          &lt;/span&gt;&lt;span style="color: blue;"&gt;else&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; text-indent: 0.5in;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;&lt;span style=""&gt;          &lt;/span&gt;&lt;span style=""&gt;          &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; text-indent: 0.5in;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;&lt;span style=""&gt;          &lt;/span&gt;&lt;span style=""&gt;          &lt;/span&gt;&lt;span style=""&gt;          &lt;/span&gt;&lt;span style="color: blue;"&gt;return&lt;/span&gt; "Unable to upload,file exceeds maximum limit";&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;&lt;span style=""&gt;                   &lt;/span&gt;&lt;span style=""&gt;          &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; text-indent: 0.5in;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;&lt;span style=""&gt;          &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;&lt;span style=""&gt;          &lt;/span&gt;&lt;span style=""&gt;          &lt;/span&gt;&lt;span style="color: blue;"&gt;catch&lt;/span&gt;(UnauthorizedAccessException ex)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;&lt;span style=""&gt;          &lt;/span&gt;&lt;span style=""&gt;          &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt; text-indent: 0.5in;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;&lt;span style=""&gt;          &lt;/span&gt;&lt;span style=""&gt;          &lt;/span&gt;&lt;span style="color: blue;"&gt;return&lt;/span&gt; ex.Message + "Permission to upload file denied";&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;&lt;span style=""&gt;          &lt;/span&gt;&lt;span style=""&gt;          &lt;/span&gt;}&lt;span style=""&gt;   &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: Verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt; &lt;/p&gt;&lt;p&gt;&lt;span style="font-size:85%;"&gt;The above function takes care of following things before uploading file to the folder&lt;/span&gt;&lt;/p&gt; &lt;ol&gt;&lt;span style="font-size:85%;"&gt;&lt;li&gt;Invalid file name supplied.  &lt;/li&gt;&lt;li&gt;If file not exists or content length 0.  &lt;/li&gt;&lt;li&gt;Folder name exists.&lt;/li&gt;&lt;/span&gt;&lt;/ol&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;strong&gt;Error Handling
&lt;br /&gt;&lt;/strong&gt;
&lt;br /&gt;While uploading done with UnauthorizedAccessException and returned with the message&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;On upload button click I am having following code&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: 10pt; color: blue; font-family: Verdana;"&gt;&lt;span style="font-size:85%;"&gt;private&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;&lt;span style="font-size:85%;"&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; btnSave_Click(&lt;span style="color: blue;"&gt;object&lt;/span&gt; sender, System.EventArgs e)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;&lt;span style="font-size:85%;"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;&lt;span style=""&gt;&lt;span style="font-size:85%;"&gt;          &lt;/span&gt;&lt;/span&gt;&lt;span style="color: blue;"&gt;&lt;span style="font-size:85%;"&gt;string&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt; strFilename, strMessage;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;&lt;span style=""&gt;&lt;span style="font-size:85%;"&gt;          &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;strFilename = fileUpload.PostedFile.FileName.ToString();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;&lt;span style=""&gt;&lt;span style="font-size:85%;"&gt;          &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;strMessage = uploadFile(strFilename,ConfigurationSettings.AppSettings["folderPath"]);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;&lt;span style=""&gt;&lt;span style="font-size:85%;"&gt;          &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;lblMessage.Text = strMessage;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;&lt;span style=""&gt;&lt;span style="font-size:85%;"&gt;          &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;lblMessage.ForeColor = Color.Red;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: 10pt; font-family: Verdana;"&gt;&lt;span style="font-size:85%;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: Verdana;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt; &lt;/p&gt;&lt;p&gt;&lt;span style="font-size:85%;"&gt;I have made use of Web.config file, in which I have added attribute as follows under:&lt;/span&gt;&lt;/p&gt; &lt;span style="font-size:85%;"&gt;&lt;span style="color:#0000ff;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color:#0000ff;"&gt;&lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;configuration&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&gt;
&lt;br /&gt;      &lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;appSettings&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&gt;
&lt;br /&gt;         &lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;add&lt;/span&gt;&lt;span style="color:#ff00ff;"&gt; &lt;/span&gt;&lt;span style="color:#ff0000;"&gt;key&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="folderPath"&lt;/span&gt;&lt;span style="color:#ff00ff;"&gt; &lt;/span&gt;&lt;span style="color:#ff0000;"&gt;value&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Images"&gt;&lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;add&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&gt;
&lt;br /&gt;      &lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;appSettings&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;i.e. I have set up path of folder to upload image&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;To access control in project, I have added page called as "uploadTester.aspx" to the project in which I have added following line:&lt;/span&gt;&lt;/p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="background-color: rgb(255, 255, 51);font-size:85%;" &gt; &lt;p&gt;&lt;%@ Register TagPrefix="img" TagName="Uploader" src="userControl/uploader.ascx"%&gt;&lt;/p&gt;&lt;/span&gt; &lt;/span&gt;&lt;p&gt;&lt;span style="font-size:85%;"&gt;Which says that this control is register to this page with specified source.&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;And in HTML code I have added following code inside form tag:&lt;/span&gt;&lt;/p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-size:100%;color:#0000ff;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-size:100%;color:#0000ff;"&gt;&lt;span style="font-size:85%;"&gt;&lt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;img:Uploader&lt;/span&gt;&lt;span style="color:#ff00ff;"&gt; &lt;/span&gt;&lt;span style="color:#ff0000;"&gt;runat&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="server"&lt;/span&gt;&lt;span style="color:#ff00ff;"&gt; &lt;/span&gt;&lt;span style="color:#ff0000;"&gt;id&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;="Uploader1"&gt;&lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;img:Uploader&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;p&gt;&lt;span style="font-size:85%;"&gt;That's all about&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;strong&gt;General:&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;To upload any of the file in respective folder user need to have permission for writing to the folder so please follow the following steps to prevent from the error.&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;Set permission to virtual directory by following steps in IIS&lt;/span&gt;&lt;/p&gt; &lt;ul&gt;&lt;span style="font-size:85%;"&gt;&lt;li&gt;Right Click on virtual directory which you have created for this project. Under directory Tab you will find
&lt;br /&gt;    1)Read
&lt;br /&gt;    2)Log Visits
&lt;br /&gt;    3)Index this resources
&lt;br /&gt;       Are marked as checked (enables) in addition to this make
&lt;br /&gt;    4)Write access enabled or checked  &lt;/li&gt;&lt;li&gt;Click on apply  &lt;/li&gt;&lt;li&gt;Click on ok&lt;/li&gt;&lt;/span&gt;&lt;/ul&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;This will set right permission to entire virtual directory, this way we can minimize error from the front end for permission / access denied.&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;Other way to solve permission denied issue is to go to actual folder "images" by using physical path and follow these steps:&lt;/span&gt;&lt;/p&gt; &lt;ul&gt;&lt;span style="font-size:85%;"&gt;&lt;li&gt;Right click folder  &lt;/li&gt;&lt;li&gt;Sharing Tab  &lt;/li&gt;&lt;li&gt;Enable share this folder radio button  &lt;/li&gt;&lt;li&gt;Click Apply  &lt;/li&gt;&lt;li&gt;Click Ok&lt;/li&gt;&lt;/span&gt;&lt;/ul&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;If u are using this code on 2000 server you should do following:&lt;/span&gt;&lt;/p&gt; &lt;ul&gt;&lt;span style="font-size:85%;"&gt;&lt;li&gt;Right click respective folder  &lt;/li&gt;&lt;li&gt;Go to security tab  &lt;/li&gt;&lt;li&gt;Select Everyone user  &lt;/li&gt;&lt;li&gt;Apply full control  &lt;/li&gt;&lt;li&gt;click on ok&lt;/li&gt;&lt;/span&gt;&lt;/ul&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/ynBt/~4/juBB1vTldCw" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://purl.org/atom/app#">2009-01-06T09:55:37.850+05:30</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://dotnetfaqs-edu.blogspot.com/2009/01/file-uploader-in-c.html</feedburner:origLink></item><item><title>Presenting Child Data along with Parent Row in Data Grid</title><link>http://feedproxy.google.com/~r/blogspot/ynBt/~3/Jd90daC_9jQ/presenting-child-data-along-with-parent.html</link><category>ASP.NET Controls</category><author>noreply@blogger.com (Tiru)</author><pubDate>Mon, 05 Jan 2009 20:23:14 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-6426652519813936980.post-8289993564363389482</guid><description>&lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;&lt;strong&gt;Introduction&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;Data Grid gives a richer UI presentation for the web applications. Most of the time there may be requirement to show one or more child data that belong to the parent row in a column with in the Data Grid. Though this article doesn't explain how to have hierarchal layout in the Data Grid itself. It gives the sample code for defining a Repeater control inside the Template Column and have that Repeater bind to the child data of the parent row.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;&lt;strong&gt;Data Grid HTML Code:&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;asp:datagrid&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;id&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="dataGrid1"&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;runat&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="server"&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;Width&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="792px"&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;OnItemDataBound&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="dataGrid1_ItemDataBound"&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;AutogenerateColumns&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="False"&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;cellpadding&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="0"&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;PagerStyle-Mode&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="NumericPages"&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;PagerStyle-PageButtonCount&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="20"&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;PageSize&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="20"&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;AllowPaging&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="True"&lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;AllowSorting&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="True"&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;OnSortCommand&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="dgAccountBalance_Sort"&gt;&lt;/span&gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;p&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Columns&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;-- First Column With ID as hidden column --&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;asp:BoundColumn&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;DataField&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="ID"&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;Visible&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="False"&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;HeaderText&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="ID"&gt;&lt;br /&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;HeaderStyle&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;Width&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="190px"&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;HorizontalAlign&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Center"&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;HeaderStyle&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&gt;&lt;br /&gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;asp:BoundColumn&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;p&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;-- Second Column defined as Check Box in a Template Column --&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;asp:TemplateColumn&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;HeaderText&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Select"&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;HeaderStyle-Width&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="40px"&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&gt;&lt;br /&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;ItemStyle&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;Width&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="40px"&gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;ItemStyle&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&gt;&lt;br /&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;ItemTemplate&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&gt;&lt;br /&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;input&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;type&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="checkbox"&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;runat&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="server"&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;id&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="chkSelected"&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;checked&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;='&lt;/span&gt;&lt;% # DataBinder.Eval(Container.DataItem, "Selected") %&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;'&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;NAME&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="chkSelected"/&gt;&lt;br /&gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;ItemTemplate&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&gt;&lt;br /&gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;asp:TemplateColumn&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;-- Third Column bound to the Field Description --&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;asp:BoundColumn&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;DataField&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Description"&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;SortExpression&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Description"&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;HeaderText&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Description"&gt;&lt;br /&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;HeaderStyle&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;HorizontalAlign&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Center"&gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;HeaderStyle&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&gt;&lt;br /&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;ItemStyle&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;Wrap&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="True"&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;Width&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="2000px"&gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;ItemStyle&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&gt;&lt;br /&gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;asp:BoundColumn&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;p&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;-- Fourth Column a Numeric column for displaying Currenty with DataFormat --&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;p&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;asp:BoundColumn&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;DataField&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Amount"&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;SortExpression&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Amount"&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;ReadOnly&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="True"&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;HeaderText&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Amount"&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;DataFormatString&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="{0:$#,##0.0000;($#,##0.0000)}"&gt;&lt;br /&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;HeaderStyle&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;HorizontalAlign&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Center"&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;Width&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="70px"&gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;HeaderStyle&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&gt;&lt;br /&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;ItemStyle&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;HorizontalAlign&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Right"&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;Wrap&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="False"&gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;ItemStyle&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&gt;&lt;br /&gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;asp:BoundColumn&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;-- Fifth Column That displays the child record of the row inside a Repeater control --&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;asp:TemplateColumn&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;HeaderText&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Child Data"&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;HeaderStyle-HorizontalAlign&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Center"&gt;&lt;br /&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;ItemStyle&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;HorizontalAlign&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="Left"&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;Wrap&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="True"&gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;ItemStyle&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&gt;&lt;br /&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;ItemTemplate&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&gt;&lt;br /&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;asp:Repeater&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;ID&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="rptChild"&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;OnItemDataBound&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;"rptChild_ItemDataBound"&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;runat&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;"server"&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;DataSource&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;'&lt;/span&gt;&lt;%# ((System.Data.DataRowView)Container.DataItem).Row.GetChildRows("relationParentChild") %&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;'&gt;&lt;br /&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;ItemTemplate&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&gt;&lt;br /&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;asp:LinkButton&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;ID&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="linkChild"&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;Runat&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="server"&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;CommandArgument&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;=&lt;/span&gt;&lt;%# DataBinder.Eval(Container.DataItem, "[\"ChildID\"]")%&gt;&lt;span style="color: rgb(255, 0, 255);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;OnClick&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="linkChild_Click"&gt;&lt;br /&gt;&lt;/span&gt;&lt;%# DataBinder.Eval(Container.DataItem, "[\"ChildFieldNameToDisplay\"]")%&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;asp:LinkButton&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&gt;&lt;br /&gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;ItemTemplate&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&gt;&lt;br /&gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;asp:Repeater&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&gt;&lt;br /&gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;ItemTemplate&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&gt;&lt;br /&gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;asp:TemplateColumn&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&gt;&lt;/span&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;p&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Columns&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;PagerStyle&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;PageButtonCount&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="20"&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;Mode&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="NumericPages"&gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;PagerStyle&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&gt;&lt;br /&gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;asp:datagrid&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;&lt;strong&gt;Code Required in the Code Behind Page:&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;private&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;void&lt;/span&gt; Page_Load(&lt;span style="color: rgb(0, 0, 255);"&gt;object&lt;/span&gt; sender, System.EventArgs e)&lt;br /&gt;{&lt;br /&gt;System.Data.DataSet ds = Get Data Set();&lt;br /&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;// This Data Set should be populated with two tables one for the Parent Row Data&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;// and the second for the child data to be displayed in the repeater control&lt;br /&gt;&lt;/span&gt;ds.Relations.Add("relationParentChild",ds.Tables[0].Columns["ID"],ds.Tables[1].Columns["FKID"]);&lt;br /&gt;DataView dv = ds.Tables[0].DefaultView;&lt;br /&gt;dataGrid1.DataSource = dv;&lt;br /&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;&lt;strong&gt;Code Explanation:&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;Add the data grid control to the page and set it's properties like width,autogeneratecolumns, the events etc, as required. Then define the Bound Column and the DataField Name for those columns. These columns will be just displayed as Text. If some data needs to be presented in special controls like the Check Box as shown in the example have it defined in the Item Template Column. The code also shows how we can set the Data Format String for the column.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;The Repeater should be declared inside the Item Template column in the grid.(inside a Item Template). The data source for the Repeater is set as &lt;strong&gt;&lt;em&gt;((System.Data.DataRowView)Container.DataItem).Row.GetChildRows("relationParentChild")&lt;/em&gt;&lt;/strong&gt; inside the Server Tag. This will get the child rows of the row to which the Data is being Bound&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;In this example we are displaying a link button inside the Repeater and clicking on the link will take to appropriate page as required. This can be changed to as per the need. To access the child table's field this syntax is used &lt;strong&gt;&lt;em&gt;DataBinder.Eval(Container.DataItem, "[\"ColumnNameinChildTable\"]")%&lt;/em&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;CommandArgument attribute used in the example is used to get the querystring to open up the page for the selected child link.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/ynBt/~4/Jd90daC_9jQ" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://purl.org/atom/app#">2009-01-06T09:53:14.380+05:30</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://dotnetfaqs-edu.blogspot.com/2009/01/presenting-child-data-along-with-parent.html</feedburner:origLink></item><item><title>SOAP, .NET, and COM - An Introduction: Part I</title><link>http://feedproxy.google.com/~r/blogspot/ynBt/~3/G0348ggenE4/soap-net-and-com-introduction-part-i.html</link><category>ASP.NET Controls</category><author>noreply@blogger.com (Tiru)</author><pubDate>Mon, 05 Jan 2009 20:21:11 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-6426652519813936980.post-2786136785387484426</guid><description>SOAP is a protocol specification to invoke methods on servers, services, components and objects. The available procedure of using XML and HTTP as a method invocation mechanism is implied by SOAP. A small number of HTTP headers that facilitate firewall/proxy filtering are authorized by the SOAP specification. The SOAP specification also mandates an XML vocabulary that is used to represent method parameters, return values, and exceptions.&lt;br /&gt;&lt;br /&gt;To exchange structured and typed information between peers in a decentralized, distributed environment using XML, SOAP presents an uncomplicated mechanism. SOAP defines a simple mechanism for expressing application semantics by providing a modular packaging model and encoding mechanisms for encoding data within modules instead of defining any application semantics such as a programming model or implementation specific semantics. This allows SOAP to be used in a large variety of systems ranging from messaging systems to RPC.&lt;br /&gt;&lt;br /&gt;An Overview to SOAP&lt;br /&gt;&lt;br /&gt;SOAP, (the Simple Object Access Protocol), is XML syntax to exchange messages. Moreover, since it is XML, it is independent from both language and platform. In addition, SOAP is a fundamental part of .NET, Microsoft's new development platform, and to understand what SOAP is and how it works it will be important for developers to move towards .NET.&lt;br /&gt;&lt;br /&gt;In SOAP, there are four parts:&lt;br /&gt;&lt;br /&gt;* The SOAP envelope construct: Defines an overall framework to express what is in a message, who should deal with it, and whether it is optional or mandatory.&lt;br /&gt;* The SOAP encoding rules: Defines a serialization mechanism that can be used to exchange instances of application-defined datatypes.&lt;br /&gt;* The SOAP RPC representation: Defines a convention that can be used to represent remote procedure calls and responses.&lt;br /&gt;* The SOAP binding: Defines a convention to exchange SOAP envelopes between peers using an underlying protocol for transport.&lt;br /&gt;&lt;br /&gt;Simply, SOAP is a well-documented wire protocol. Microsoft is getting behind SOAP and in future, probably will offer some type of implementation. However, other vendors can also do the same. For instance, the Perl implementation of SOAP is not tied to COM or Windows in any way, and if a modern version of Perl is available, can be used on any platform where. SOAP does not attach anyone to a particular platform. It provides a practical way to communicate over the Internet that is easy to implement on any platform.&lt;br /&gt;&lt;br /&gt;Functionally, SOAP is very similar to IIOP which the underlying protocol used by most CORBA products. DCOM has additional protocol functionality such as garbage collection, causality that is not present in IIOP or SOAP. However, DCOM's extended functionality generally only needed in server-server communications and is not required in client-server communications. An advantage of both IIOP and DCOM side, SOAP packets be likely to be larger on the wire and can be somewhat more resource intensive to parse/generate.&lt;br /&gt;&lt;br /&gt;A set of conventions for exchanging XML messages defined by the specification, such as rules for encoding data structures, an extensibility mechanism, a binding to the HTTP protocol, and conventions for RPC style invocations. For all SOAP messages that are exchanged between a web service and its client, SOAP defines the outer element. Namespace indicates to an XSLT processor that the XML is in fact a transform, just as the stylesheet element in the XSLT.&lt;br /&gt;&lt;br /&gt;Moreover, the Envelope element in the SOAP namespace indicates to a SOAP processor that the XML is in fact a SOAP message. After that the processor can seek the individual pieces of the message, such as a mandatory Body element that has the actual request and an elective Header element that has extension elements. Below, a framework SOAP message is demonstrated.&lt;br /&gt;&lt;br /&gt;&lt;soap:envelope soap="http://www.w3.org/2001/10/soap-envelope"&gt;&lt;br /&gt;&lt;soap:header&gt;&lt;br /&gt;&lt;-- Headers go here --&gt;&lt;br /&gt;soap:Header&gt;&lt;br /&gt;&lt;soap:body&gt;&lt;br /&gt;&lt;-- Request goes here --&gt;&lt;br /&gt;soap:Body&gt;&lt;br /&gt;soap:Envelope&gt;&lt;br /&gt;&lt;br /&gt;An extensibility mechanism is provided in the Header element in SOAP. This element can have any number of namespace qualified child elements. To the base SOAP protocol, each of these elements is some form of extension. Possibly one element holds data associated with conversation or session management between a client and a server. Another element might contain authentication information or even information pertaining to an ongoing transaction and another may contain locale information. Whatever their content or semantics each header element modifies the SOAP protocol in some way, also they providing extra context for the processing of the body of the message. It will be important to the client that the server honors them for some extensions; authentication is a good example to this.&lt;br /&gt;&lt;br /&gt;SOAP Basics&lt;br /&gt;&lt;br /&gt;At first, SOAP was based on HTTP, in Version 1.0 of the specification. Later on this changed, to allow for a wider variety of transport protocols (such as SMTP), or messaging protocols in the latest revision of the specification, Version 1.1 and Version 1.2. Two major design goals are outlined in the original SOAP specification: 1) Provide a standard object invocation protocol built on Internet standards, using HTTP as the transport and XML for data encoding, and 2) Create an extensible protocol and payload format that can evolve. Simplicity and extensibility are very important goals for SOAP. SOAP completely avoids several additional aspects of distributed object architectures.&lt;br /&gt;&lt;br /&gt;* Distributed garbage collection-orphaned objects&lt;br /&gt;* Pipelined messages or multiple call requests.&lt;br /&gt;* Remote object activation&lt;br /&gt;* Bi-Directional HTTP communications-callbacks&lt;br /&gt;* Objects-by-reference&lt;br /&gt;* Security&lt;br /&gt;&lt;br /&gt;The individual SOAP implementation's architect designs the areas which the specification has not addressed, into a specific implementation. To solve some challenging real world issues that encumber existing distributed protocols and architectures is SOAP's objective. While existing protocols do address the items mentioned, and SOAP does not, SOAP addresses areas in which existing protocols fall short, such as scalability and the capability to share disparate yet interoperable using SOAP architectures.&lt;br /&gt;&lt;br /&gt;SOAP Fundamentals&lt;br /&gt;&lt;br /&gt;Actually, SOAP is based upon its technical worth; it is mainly the mixture of textual information shared via the Internet. SOAP processing is very much aligned with the Internet if you use HTTP as your SOAP transport protocol. SOAP specifies a stateless programming model with this processing. That means, object clients request services from a remote entity, which responds with the pertinent information. Currently, HTTP is a persistent technology and if a business interacts with the Internet in any meaningful fashion, it has to handle HTTP data. At the very least, HTTP processing is well understood and widely put into action. Some aspects of using SOAP, as with any tool, can be seen as advantages. In following list you may find some of the advantages of using SOAP.&lt;br /&gt;&lt;br /&gt;* SOAP is built upon technologies, rather than vendor-specific technologies, and facilitates true distributed interoperability. At least not at this time, the SOAP market is not conquered by single vendor.&lt;br /&gt;* The SOAP specification can ultimately consolidate the various HTTP tunneling protocols (IIOP and RMI to name two) into a single specification. This makes implementations easier and potentially more interoperable. SOAP typically uses HTTP but at least with the 1.2 version of the specification, it does not require its use.&lt;br /&gt;* SOAP will likely work out of the box in a wide range of user locations that enable HTTP port 80 POST access.&lt;br /&gt;* Loosely Coupled distributed applications are encouraged by SOAP.&lt;br /&gt;* Unless significant serialization changes are made to the SOAP specification, changes to the SOAP infrastructures will likely not affect applications using the protocol.&lt;br /&gt;&lt;br /&gt;When you choose remoting architecture, possibly there are many design facets that you need to consider about them. The following list includes some of them.&lt;br /&gt;&lt;br /&gt;1. Scalability&lt;br /&gt;2. Performance&lt;br /&gt;3. Activation&lt;br /&gt;4. State Management&lt;br /&gt;5. Garbage Collection&lt;br /&gt;6. Security&lt;br /&gt;&lt;br /&gt;The wire protocols are not necessarily responsible for any or every design facet of the entire remoting architecture. For instance, not all of them implement security. However, for some or all these design facets, each protocol provides some level of support. Some protocols transmit security information as an integral part of their data packets, whereas others rely upon external systems to assure a secure connection. Beginning with scalability, each of these design issues is discussed to try to apply the same definition to all the wire protocols. SOAP simply is a wire protocol, unlike the other distributed object architectures. To compare SOAP with these other architectures; you need to apply the SOAP protocol as part of a distributed architecture of its own. On the other hand, even as a wire protocol, SOAP offers many advantages.&lt;br /&gt;&lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;img alt="" src="http://www.c-sharpcorner.com/UploadFile/jgodel/SOAPNETCOMIntroductionpartI11162005042800AM/Images/soap2.gif" align="baseline" border="0" hspace="0" /&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;Figure 3.1 - SOAP Architecture&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;&lt;strong&gt;SOAP Messages&lt;br /&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;Since now we have covered SOAP at a high level, let us examine the most important detail of SOAP: the structure of a message. For messages, SOAP primarily uses XML syntax. A SOAP message contains a payload, the application-specific information. Here is an example of a SOAP message as an actual XML document:&lt;br /&gt;&lt;soap:envelope soap="http://schemas.xmlsoap.org/soap/envelope/" encodingstyle="http://schemas.xmlsoap.org/soap/ encoding/"&gt;&lt;br /&gt;&lt;soap:header&gt;&lt;h:from h="http://www.ets- oftware.com/Header"&gt;&lt;soap:body&gt;&lt;w:getmainidentity w="http://www.ets-software.com/Authors/"&gt;&lt;w:nickname&gt;&lt;/w:nickname&gt;&lt;/w:getmainidentity&gt;&lt;/soap:body&gt;&lt;/h:from&gt;&lt;/soap:header&gt;&lt;/soap:envelope&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;soap:Envelope&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;xmlns&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);"&gt;:&lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;soap&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;=http://schemas.xmlsoap.org/soap/envelope/&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;soap&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);"&gt;:&lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;encodingStyle&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="http://schemas.xmlsoap.org/soap/&lt;br /&gt;encoding/"&gt;&lt;br /&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;soap:Header&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&gt;&lt;br /&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;h:from&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;xmlns&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);"&gt;:&lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;h&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="http://www.ets-&lt;br /&gt;oftware.com/Header"&gt;&lt;/span&gt;testuser@mydomain.com&lt;span style="color: rgb(0, 0, 255);"&gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;h:from&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&gt;&lt;br /&gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;soap:Header&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&gt;&lt;br /&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;soap:Body&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&gt;&lt;br /&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;w:GetMainIdentity&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;xmlns&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);"&gt;:&lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;w&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="http://www.ets-software.com/Authors/"&gt;&lt;br /&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;w:nickname&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&gt;&lt;/span&gt;XSLT-Author&lt;span style="color: rgb(0, 0, 255);"&gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;w:nickname&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&gt;&lt;br /&gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;w:GetMainIdentity&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&gt;&lt;br /&gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;soap:Body&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&gt;&lt;br /&gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;soap:Envelope&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;&lt;span style="color: rgb(0, 0, 255);font-size:85%;" &gt;&lt;span style="color: rgb(0, 0, 255);font-size:85%;" &gt;&lt;span style="color: rgb(0, 0, 255);font-size:85%;" &gt;&lt;span style="color: rgb(0, 0, 255);font-size:85%;" &gt;&lt;span style="color: rgb(0, 0, 255);font-size:85%;" &gt;&lt;span style="color: rgb(0, 0, 255);font-size:85%;" &gt;&lt;span style="color: rgb(0, 0, 255);font-size:85%;" &gt;&lt;br /&gt;&lt;img alt="" src="http://www.c-sharpcorner.com/UploadFile/jgodel/SOAPNETCOMIntroductionpartI11162005042800AM/Images/soap1.gif" align="baseline" border="0" hspace="0" /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;Figure 3.2 - SOAP Messages Architecture&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;Let us take a quick look at the XML of the message before we go into the contents of the SOAP message. As you may know, SOAP messages heavily rely on XML Namespaces. All of the elements in this document are prefixed with a namespace, and there is a good reason why the SOAP specification uses namespaces so extensively. All the elements of the message must be scoped in some fashion to avoid conflicts in the names of elements in order for a SOAP message to carry any arbitrary XML payload.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;The namespace prefix soap is used on most of the elements in the above message. In the fallowing example, the prefix is associated with the namespace URI &lt;/span&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;http://schemas.xmlsoap.org/soap/envelope/&lt;/span&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;. It identifies the elements that are part of a standard SOAP message. The choice of soap is not relevant like all namespace prefixes. As in the fallowing, the namespace prefix could have been something else entirely:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 255);font-size:130%;" &gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);font-size:130%;" &gt;trial:Envelope&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);font-size:130%;" &gt; &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);font-size:130%;" &gt;xmlns&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);font-size:130%;" &gt;:&lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);font-size:130%;" &gt;trial&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);font-size:130%;" &gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);font-size:130%;" &gt;=http://schemas.xmlsoap.org/soap/envelope/&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);font-size:130%;" &gt;trial&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);font-size:130%;" &gt;:&lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);font-size:130%;" &gt;encodingStyle&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);font-size:130%;" &gt;="http://schemas.xmlsoap.org/&lt;br /&gt;soap/encoding/"&gt;&lt;br /&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);font-size:130%;" &gt;trial:Header&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);font-size:130%;" &gt;&gt;&lt;br /&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);font-size:130%;" &gt;h:from&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);font-size:130%;" &gt; &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);font-size:130%;" &gt;xmlns&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);font-size:130%;" &gt;:&lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);font-size:130%;" &gt;h&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);font-size:130%;" &gt;="http://www.ets-&lt;br /&gt;software.com/Header"&gt;&lt;/span&gt;&lt;span style="font-size:130%;"&gt;testuser@MyDomain.com&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);font-size:130%;" &gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;h:from&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&gt;&lt;br /&gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;trial:Header&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&gt;&lt;br /&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;trial:Body&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&gt;&lt;br /&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;w:GetMainIdentity&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;xmlns&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);"&gt;:&lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;w&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="http://www.ets-software.com/Authors/"&gt;&lt;br /&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;w:nickname&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&gt;&lt;/span&gt;XSLT-Author&lt;span style="color: rgb(0, 0, 255);"&gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;w:nickname&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&gt;&lt;br /&gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;w:GetMainIdentity&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&gt;&lt;br /&gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;trial:Body&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&gt;&lt;br /&gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;trial:Envelope&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;If the namespace is the default namespace for the document, the namespace prefix could also be eliminated. As shown below, the default namespace is assigned using just the xmlns attribute:&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Envelope&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;xmlns&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;=http://schemas.xmlsoap.org/soap/envelope/&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;encodingStyle&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="http://schemas.xmlsoap.org/soap/encoding/"&gt;&lt;br /&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Header&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&gt;&lt;br /&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;h:from&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;xmlns&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);"&gt;:&lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;h&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="http://www.ets-&lt;br /&gt;software.com/Header"&gt;&lt;/span&gt;testuser@MyDomain.com&lt;span style="color: rgb(0, 0, 255);"&gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;h:from&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&gt;&lt;br /&gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Header&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&gt;&lt;br /&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Body&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&gt;&lt;br /&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;w:GetMainIdentity&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;xmlns&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);"&gt;:&lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;w&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="http://www.ets-software.com/Authors/"&gt;&lt;br /&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;w:nickname&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&gt;&lt;/span&gt;XSLT-Author&lt;span style="color: rgb(0, 0, 255);"&gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;w:nickname&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&gt;&lt;br /&gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;w:GetMainIdentity&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&gt;&lt;br /&gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Body&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&gt;&lt;br /&gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;Envelope&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;All three of these messages are acceptable and equivalent. It is better to use the soap namespace prefix for elements for better readability. All of the elements in the message that are associated with the soap namespace are standard elements of a SOAP message, as are the attributes. Any other elements are related to either message extensions or the message payload.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;A traditional versioning model is not defined in SOAP based on major and minor version numbers. A SOAP message MUST have an Envelope element associated with the "&lt;/span&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;http://schemas.xmlsoap.org/soap/envelope/&lt;/span&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;" namespace. The application MUST treat a message as a version error and discard it if this is received by a SOAP application in which the SOAP Envelope element is associated with a different namespace. However, if the message is received through a request/response protocol such as HTTP, the application MUST respond with a SOAP VersionMismatch faultcode message using the SOAP "&lt;/span&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;http://schemas.xmlsoap.org/soap/envelope/&lt;/span&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;" namespace.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-family:Verdana,Arial,Helvetica,sans-serif;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;soap:Envelope&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;xmlns&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);"&gt;:&lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;soap&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;=http://schemas.xmlsoap.org/soap/envelope/&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;soap&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);"&gt;:&lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;encodingStyle&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="http://schemas.xmlsoap.org/soap/&lt;br /&gt;encoding/"&gt;&lt;br /&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;soap:Header&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&gt;&lt;br /&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;h:from&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;xmlns&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);"&gt;:&lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;h&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="http://www.ets-&lt;br /&gt;software.com/Header"&gt;&lt;/span&gt;testuser@MyDomain.com&lt;span style="color: rgb(0, 0, 255);"&gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;h:from&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&gt;&lt;br /&gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;soap:Header&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&gt;&lt;br /&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;soap:Body&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&gt;&lt;br /&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;w:GetMainIdentity&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;xmlns&lt;/span&gt;&lt;span style="color: rgb(255, 0, 255);"&gt;:&lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;w&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="http://www.ets-software.com/Authors/"&gt;&lt;br /&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;w:nickname&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&gt;&lt;/span&gt;XSLT-Author&lt;span style="color: rgb(0, 0, 255);"&gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;w:nickname&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&gt;&lt;br /&gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;w:GetMainIdentity&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&gt;&lt;br /&gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;soap:Body&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&gt;&lt;br /&gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;soap:Envelope&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/soap:body&gt;&lt;/soap:header&gt;&lt;/soap:envelope&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/ynBt/~4/G0348ggenE4" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://purl.org/atom/app#">2009-01-06T09:51:11.465+05:30</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://dotnetfaqs-edu.blogspot.com/2009/01/soap-net-and-com-introduction-part-i.html</feedburner:origLink></item><item><title>How WebParts on a page communicate with each other</title><link>http://feedproxy.google.com/~r/blogspot/ynBt/~3/LMfqhwe6gDM/how-webparts-on-page-communicate-with.html</link><category>ASP.NET Controls</category><author>noreply@blogger.com (Tiru)</author><pubDate>Mon, 05 Jan 2009 20:13:51 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-6426652519813936980.post-7761341082252777038</guid><description>&lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;b&gt;Introduction:&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;In this tutorial we will describe how to make WebParts on a WebParts Page communicate with each other. So will see how to use &lt;b&gt;ConnectionsZone&lt;/b&gt; and how to enable WebParts to talk to each other by connecting them.&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;b&gt;Assumptions:&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;This tutorial assumes that you know how to work with web forms, creating user controls and connecting to data sources using &lt;b&gt;SqlDataSource&lt;/b&gt; Control. Also you should know how to use &lt;b&gt;WebPartZone&lt;/b&gt; control and to know what are &lt;b&gt;WebParts&lt;/b&gt; and &lt;b&gt;WebParts Pages&lt;/b&gt;. &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;b&gt;How to implement connections between 2 WebParts:&lt;br /&gt;&lt;br /&gt;&lt;/b&gt;The scenario is, we have 2 web parts, one display a drop down list of publishers, and the other display grid view of titles related to a specific publisher. So whenever I change the selection from the drop down list, the grid view should repopulated with the titles related to the selected publisher. This is very simple scenario just to show you how to implement WebParts Connections.&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;b&gt;&lt;u&gt;Preparing the WebParts Page&lt;/u&gt;:&lt;/b&gt;&lt;/span&gt;&lt;/p&gt; &lt;ol&gt;&lt;span style="font-size:85%;"&gt;&lt;li&gt;Create new WebForm, Name it &lt;b&gt;WebPartsConnections.aspx&lt;/b&gt;, Also create 2 user controls, name them as &lt;b&gt;UCPublishers.ascx&lt;/b&gt; &amp;amp; &lt;b&gt;UCTitles.ascx&lt;/b&gt;.&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Open &lt;b&gt;UCPublishers.ascx&lt;/b&gt;, drag and drop &lt;b&gt;SqlDataSource&lt;/b&gt; control -name it &lt;b&gt;sdsPubs&lt;/b&gt;- into it as well as a DropDownList &lt;b&gt;-&lt;/b&gt;name it&lt;b&gt; cmbPubs-&lt;/b&gt; and set its AutoPostBack Property to ture.&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Configure the SqlDataSource to select [pub_id] and [pub_name]&lt;b&gt; &lt;/b&gt;from publishers table in pubs Database sample.&lt;br /&gt;&lt;br /&gt;&lt;img style="border: 1px solid black; width: 581px; height: 135px;" src="http://www.c-sharpcorner.com/UploadFile/mosessaur/webpartscommunication01172006044658AM/Images/UCPublishersCode.JPG" border="0" /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Open &lt;b&gt;UCTitles.ascx&lt;/b&gt;, drage and drop &lt;b&gt;SqlDataSource&lt;/b&gt; control -name it &lt;b&gt;sdsTitles&lt;/b&gt;- into it as well as a &lt;b&gt;GridView&lt;/b&gt; &lt;b&gt;-&lt;/b&gt;name it&lt;b&gt; dvTitles-&lt;/b&gt;. Also drag and drop a &lt;b&gt;HiddenField&lt;/b&gt; Control -name it &lt;b&gt;hfSelectedPublisherID&lt;/b&gt;-&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Configure you SqlDataSource to select [title], [price] and [pubdate] from [titles] table in Pubs sample database, with pub_id as parameter. Configure the parameter to be a control parameter, and its value populated tom the HiddenField Control.&lt;br /&gt;&lt;br /&gt;&lt;img style="border: 1px solid black;" src="http://www.c-sharpcorner.com/UploadFile/mosessaur/webpartscommunication01172006044658AM/Images/UCTitlesCode.JPG" border="0" /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Now Open your &lt;b&gt;WebPartsConnections.aspx&lt;/b&gt;, Insert table with one column and one row.&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Drag and drop &lt;b&gt;WebPartManager&lt;/b&gt; Control into the page-name it &lt;b&gt;wpManager&lt;/b&gt;-&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Drag and drop 2 &lt;b&gt;WebPartZone&lt;/b&gt; controls into the table, name them as &lt;b&gt;wpzTop&lt;/b&gt; &amp;amp; &lt;b&gt;wpzBottom&lt;/b&gt;.&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt; &lt;p dir="ltr"&gt;Drag and drop the &lt;b&gt;UCPublishers.ascx&lt;/b&gt; from the solution explorer into the &lt;b&gt;wpzTop&lt;/b&gt;. Do the same for &lt;b&gt;UCTitles.ascx&lt;/b&gt; but drop it into &lt;b&gt;wpzBottom&lt;/b&gt;. You can configure the Zones to use AutoFormat Professional Style.&lt;br /&gt;&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p dir="ltr"&gt;You can now Test the page. Notice that there is nothing happens when you change the publisher. &lt;/p&gt;&lt;/li&gt;&lt;/span&gt;&lt;/ol&gt;&lt;span style="font-size:85%;"&gt;&lt;u&gt;&lt;b&gt;Building the Connection&lt;/b&gt;&lt;/u&gt;:&lt;br /&gt;&lt;br /&gt;To implement the connection functionality between WebParts, we should create an Interface. This interface would be implemented by both &lt;b&gt;UCPublishers.ascx&lt;/b&gt; as Connection Provider, and &lt;b&gt;UCTitles.ascx &lt;/b&gt;as Connection Consumer. This interface serves as a contract for the communication between the provider and consumer.&lt;br /&gt;We will name our Interface as &lt;b&gt;ISelectedPublisher&lt;/b&gt;:  &lt;/span&gt;&lt;ol&gt;&lt;span style="font-size:85%;"&gt;&lt;li&gt;Right click on App_Code and select New Item. (Create ISelectedPublisher.cs)&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="color:#0000ff;"&gt;public interface&lt;/span&gt; ISelectedPublisher&lt;br /&gt;{&lt;/span&gt;  &lt;blockquote&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="color:#008000;"&gt;//ID of the selected publisher&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;br /&gt;string&lt;/span&gt; SeletedPublisherID{&lt;span style="color:#0000ff;"&gt;get&lt;/span&gt;;}&lt;/span&gt;&lt;/blockquote&gt;&lt;span style="font-family:Courier New;"&gt;}&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Now open your &lt;b&gt;UCPublishers.ascx&lt;/b&gt; in Code-View and implement the ISelectedPublisher as the following&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="color:#0000ff;"&gt;public partial class&lt;/span&gt; UCPublishers : System.Web.UI.&lt;span style="color:#008080;"&gt;UserControl&lt;/span&gt;, &lt;span style="color:#008080;"&gt;&lt;b&gt;ISelectedPublisher&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;{ &lt;/span&gt; &lt;blockquote&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="color:#0000ff;"&gt;#region&lt;/span&gt; ISelectedPublisher Members&lt;br /&gt;&lt;/span&gt; &lt;blockquote&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="color:#008000;"&gt;//Get the Selected Value from the DropDownList that holds Publishers&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&lt;br /&gt;public string&lt;/span&gt; SeletedPublisherID&lt;br /&gt;{&lt;br /&gt;&lt;/span&gt; &lt;blockquote&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="color:#0000ff;"&gt;get&lt;/span&gt; { &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; cmbPubs.SelectedValue; }&lt;/span&gt;&lt;/blockquote&gt;&lt;span style="font-family:Courier New;"&gt;}&lt;/span&gt;&lt;/blockquote&gt;&lt;span style="font-family:Courier New;color:#0000ff;"&gt;#endregion&lt;/span&gt;&lt;/blockquote&gt; &lt;blockquote&gt;&lt;span style="font-family:Courier New;"&gt;[&lt;span style="color:#008080;"&gt;ConnectionProvider&lt;/span&gt;("SelectedPublisher", "SelectedPublisher")]&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#008080;"&gt;ISelectedPublisher&lt;/span&gt; GetSelectedPublisher()&lt;br /&gt;{&lt;br /&gt;&lt;/span&gt; &lt;blockquote&gt;&lt;span style="font-family:Courier New;color:#0000ff;"&gt;return this;&lt;/span&gt;&lt;/blockquote&gt;&lt;span style="font-family:Courier New;"&gt;}&lt;/span&gt;&lt;/blockquote&gt;&lt;span style="font-family:Courier New;"&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;Essentially, we are implementing the &lt;b&gt;ISelectedPublisher&lt;/b&gt; interface and creating a provider connection point by using the &lt;b&gt;ConnectionProvider&lt;/b&gt; attribute. So we implemented the &lt;b&gt;SelectedPublisherID&lt;/b&gt; property to return the selected publisher id from the DropDownList.&lt;br /&gt;&lt;br /&gt;Also we created the &lt;b&gt;GetSelectedPublisher&lt;/b&gt; method. It is marked as &lt;b&gt;ConnectionProvider&lt;/b&gt;, The first parameter to the &lt;b&gt;ConnectionProvider&lt;/b&gt; attribute assigns a friendly name to the provider connection point. The second parameter assigns a unique ID to the provider connection point. Note the returned object is "this", which mean to consider the control instance itself as the connection provider.&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;It is time to implement the Consumer now, so open the Code-View of your &lt;b&gt;UCTitles.ascx&lt;/b&gt; and Consume the connection provided by the Provider:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="color:#0000ff;"&gt;public partial class&lt;/span&gt; UCTitles : System.Web.UI.UserControl&lt;br /&gt;{&lt;/span&gt;  &lt;blockquote&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; &lt;span style="color:#008080;"&gt;ISelectedPublisher&lt;/span&gt; _publisher = &lt;span style="color:#0000ff;"&gt;null&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;[&lt;span style="color:#008080;"&gt;ConnectionConsumer&lt;/span&gt;("SelectedPublisher", "SelectedPublisher")]&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;public void&lt;/span&gt; SetSelectedPublisher(ISelectedPublisher selectedPublisher)&lt;br /&gt;{ &lt;/span&gt; &lt;blockquote&gt;&lt;span style="font-family:Courier New;"&gt;_publisher = selectedPublisher;&lt;/span&gt;&lt;/blockquote&gt;&lt;span style="font-family:Courier New;"&gt;}&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;protected override void&lt;/span&gt; OnPreRender(EventArgs e)&lt;br /&gt;{&lt;/span&gt;  &lt;blockquote&gt;&lt;span style="font-family:Courier New;"&gt;&lt;span style="color:#0000ff;"&gt;base&lt;/span&gt;.OnPreRender(e);&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (_publisher != &lt;span style="color:#0000ff;"&gt;null&lt;/span&gt;)&lt;br /&gt;{&lt;/span&gt;  &lt;blockquote&gt;&lt;span style="font-family:Courier New;"&gt;hfSelectedPublisherID.Value = _publisher.SeletedPublisherID;&lt;/span&gt;&lt;/blockquote&gt;&lt;span style="font-family:Courier New;"&gt;}&lt;/span&gt;&lt;/blockquote&gt;&lt;span style="font-family:Courier New;"&gt;}&lt;/span&gt;&lt;/blockquote&gt;&lt;span style="font-family:Courier New;"&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;Essentially, we are using the &lt;b&gt;ConnectionConsumer&lt;/b&gt; attribute to define a consumer connection point -The &lt;b&gt;SetSelectedPublisher&lt;/b&gt; Method-, and allowing it to act as a receiver of the &lt;b&gt;ISelectedPublisher&lt;/b&gt; interface. The publisher that is received is then appended to the hidden field in the &lt;b&gt;UCTitles.ascx&lt;/b&gt; Control on the PreRender event. The first parameter to the &lt;b&gt;ConnectionConsumer&lt;/b&gt; attribute assigns a friendly name to the consumer connection point. The second parameter assigns a unique ID to the consumer connection point.&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Now Select the &lt;b&gt;WebPartManager&lt;/b&gt; Control in your page -wpManager-&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;From the property window, select ellipses beside the StaticConnections property. Configure it as the following.&lt;br /&gt;&lt;br /&gt;&lt;img style="border: 1px solid black; width: 516px; height: 599px;" src="http://www.c-sharpcorner.com/UploadFile/mosessaur/webpartscommunication01172006044658AM/Images/WebPartManagerConfig.JPG" border="0" /&gt;&lt;br /&gt;&lt;br /&gt;The &lt;b&gt;ConsumerID&lt;/b&gt; is the ID of the Consumer Control, in our case it is the UCTitles Control which has the default ID &lt;b&gt;UCTitles1&lt;/b&gt;.&lt;br /&gt;&lt;br /&gt;The &lt;b&gt;ProviderID&lt;/b&gt; is the ID of the Provider Control, in out case it is the UCPublishers Control which has the dfault ID &lt;b&gt;UCPublishers1&lt;/b&gt;.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;ConsumerConnectionPointID&lt;/b&gt; and &lt;b&gt;ProviderConnectionPointID&lt;/b&gt; are the Attributes parameters mentioned earlier.&lt;br /&gt;&lt;br /&gt;&lt;img style="border: 1px solid black;" src="http://www.c-sharpcorner.com/UploadFile/mosessaur/webpartscommunication01172006044658AM/Images/WebPartManagerCode.JPG" width="459" border="0" height="170" /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Now its time to test your Page. Run it and change the publisher, you will notice that the Titles is changed in the GridView to display the publisher's Titles. &lt;/li&gt;&lt;/span&gt;&lt;/ol&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;b&gt;&lt;u&gt;Working with ConnectionsZone&lt;/u&gt;:&lt;br /&gt;&lt;br /&gt;&lt;/b&gt;Now we will Connect and Disconnect the WebParts Connections on the fly during runtime. To do so we need to use &lt;b&gt;ConnectionsZone&lt;/b&gt;.&lt;/span&gt;&lt;/p&gt; &lt;ol&gt;&lt;span style="font-size:85%;"&gt;&lt;li&gt;Drag and drop &lt;b&gt;ConnectionsZone&lt;/b&gt; Control into your page any place&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Add LinkButton to you page, -name it btnEditConnection- and set the text to "Edit Connection".&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Double click on it to implement its click event handler.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new, courier, mono;"&gt;&lt;span style="color:#0000ff;"&gt;protected void&lt;/span&gt; btnEditConnection_Click(&lt;span style="color:#0000ff;"&gt;object&lt;/span&gt; sender, &lt;span style="color:#006666;"&gt;EventArgs&lt;/span&gt; e)&lt;br /&gt;{ &lt;/span&gt; &lt;blockquote&gt;&lt;span style="font-family:courier new, courier, mono;"&gt;&lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (btnEditConnection.Text == "Edit Connection")&lt;br /&gt;{ &lt;/span&gt; &lt;blockquote&gt;&lt;span style="font-family:courier new, courier, mono;"&gt;wpManager.DisplayMode = &lt;span style="color:#006666;"&gt;WebPartManager&lt;/span&gt;.ConnectDisplayMode;&lt;br /&gt;btnEditConnection.Text = "View Page";&lt;/span&gt;&lt;/blockquote&gt;&lt;span style="font-family:courier new, courier, mono;"&gt;}&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;else&lt;/span&gt;&lt;br /&gt;{ &lt;/span&gt; &lt;blockquote&gt;&lt;span style="font-family:courier new, courier, mono;"&gt;wpManager.DisplayMode = &lt;span style="color:#006666;"&gt;WebPartManager&lt;/span&gt;.BrowseDisplayMode;&lt;br /&gt;btnEditConnection.Text = "Edit Connection";&lt;/span&gt;&lt;/blockquote&gt;&lt;span style="font-family:courier new, courier, mono;"&gt;}&lt;br /&gt;&lt;/span&gt;&lt;/blockquote&gt;&lt;span style="font-family:courier new, courier, mono;"&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt; &lt;/li&gt;&lt;li&gt;Again run your page and click on the button. From the any of the WebParts Menu on the top right corner of the WebPart select Connect. Note that the Connection Zone Appears now. Test your page to see what you can do on the fly with Connection Zone and WebParts&lt;br /&gt;&lt;br /&gt;&lt;img style="border: 1px solid black; width: 507px; height: 576px;" src="http://www.c-sharpcorner.com/UploadFile/mosessaur/webpartscommunication01172006044658AM/Images/ConnectionInAction.JPG" border="0" /&gt;&lt;br /&gt;&lt;br /&gt;&lt;img style="border: 1px solid black;" src="http://www.c-sharpcorner.com/UploadFile/mosessaur/webpartscommunication01172006044658AM/Images/ConnectionZone.JPG" width="422" border="0" height="262" /&gt;&lt;br /&gt;  &lt;/li&gt;&lt;/span&gt;&lt;/ol&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;Now we almost cover most of the basic features of WebParts and WebParts Pages. Hope this WebPart Tutorial series enrich your knowledge about WebParts and WebParts framework in ASP.Net 2.&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/ynBt/~4/LMfqhwe6gDM" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://purl.org/atom/app#">2009-01-06T09:43:51.255+05:30</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://dotnetfaqs-edu.blogspot.com/2009/01/how-webparts-on-page-communicate-with.html</feedburner:origLink></item><item><title>Working with WebParts Page, WebPart Zones &amp; WebParts</title><link>http://feedproxy.google.com/~r/blogspot/ynBt/~3/xY7i08Z1qnY/working-with-webparts-page-webpart.html</link><category>ASP.NET Controls</category><author>noreply@blogger.com (Tiru)</author><pubDate>Mon, 05 Jan 2009 20:12:02 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-6426652519813936980.post-8011841111653170336</guid><description>&lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;b&gt;Introduction:&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;This tutorial considered to be the second part of the first tutorial Creating a Simple WebPart Page and use WebServer controls as WebParts. Here we will see how can we remove and add WebParts during run time, adding personalizable properties to your WebParts and modifying there values also in run time.&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;b&gt;WebPart Zones:&lt;br /&gt;&lt;br /&gt;&lt;/b&gt;There are 4 types of WebPart Zones. Zones is used to host (anchor or dock) WebParts. In the previous tutorial we had a look at &lt;b&gt;WebPartZone&lt;/b&gt;. At this tutorial we will have a look at the other another two WebPart Zones, &lt;b&gt;CatalogZone&lt;/b&gt; &amp;amp; &lt;b&gt;EditorZone&lt;/b&gt;.&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;b&gt;Modification to old project:&lt;br /&gt;&lt;br /&gt;&lt;/b&gt;In&lt;b&gt; &lt;/b&gt;the new project,  have cut the &lt;b&gt;XmlDataSource &lt;/b&gt;control&lt;b&gt; -xdsRSS-&lt;/b&gt; and the &lt;b&gt;DataList&lt;/b&gt; Control &lt;b&gt;-dlstRss-&lt;/b&gt; to a newly created &lt;b&gt;UserControl&lt;/b&gt; named &lt;b&gt;UCtrlRSSReader.ascx.&lt;/b&gt; The same I did for &lt;b&gt;SqlDataSource&lt;/b&gt; control &lt;b&gt;-sdsTitles-&lt;/b&gt; and the &lt;b&gt;GridView&lt;/b&gt; Control &lt;b&gt;-gvTitles-&lt;/b&gt; which were saved on the &lt;b&gt;UserControl&lt;/b&gt; &lt;b&gt;UCtrlTitles.ascx&lt;/b&gt;.&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;b&gt;Working with the CatalogZone:&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;Open the pervious project and apply the following modifications:&lt;/span&gt;&lt;/p&gt; &lt;ol&gt;&lt;span style="font-size:85%;"&gt;&lt;li&gt;Add another column to the table, so the table will contain 4 columns now.&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Drag and drop &lt;b&gt;CatalogZone&lt;/b&gt; Control from control from the Toolbox (under the WebParts tab) into the new column cell, rename it to &lt;b&gt;wpczCatalog&lt;/b&gt; and set its Auto format to Colorful.&lt;br /&gt;&lt;br /&gt;&lt;img style="border: 1px solid black; width: 491px; height: 461px;" src="http://www.c-sharpcorner.com/UploadFile/mosessaur/webpartzones01122006045127AM/Images/CalatogZoneAutoFormat.JPG" border="0" /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Drag and drop &lt;b&gt;PageCatalogPart&lt;/b&gt; Control into the &lt;b&gt;CatalogZone&lt;/b&gt; Control &lt;b&gt;wpczCataog&lt;/b&gt;, rename it &lt;b&gt;wpcPageCatalog.&lt;br /&gt;&lt;br /&gt;&lt;img style="border: 1px solid black;" src="http://www.c-sharpcorner.com/UploadFile/mosessaur/webpartzones01122006045127AM/Images/PageCatalogPart.JPG" width="270" border="0" height="183" /&gt;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Drag and drop &lt;b&gt;DeclarativeCatalogPart&lt;/b&gt; Control into the &lt;b&gt;CatalogZone&lt;/b&gt; Control &lt;b&gt;wpczCataog&lt;/b&gt;, rename it &lt;b&gt;wpcDeclarativeCatalog.&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;From &lt;b&gt;DeclarativeCatalogPart&lt;/b&gt; &lt;b&gt;Tasks&lt;/b&gt; smart tag, Select &lt;b&gt;Edit Template&lt;/b&gt;.&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Then drag and drop &lt;b&gt;UCtrlRSSReader &lt;/b&gt;from your solution explorer into the &lt;b&gt;WebPartsTemplate&lt;/b&gt; area of &lt;b&gt;wpcDeclarativeCatalog&lt;/b&gt; control, and click &lt;b&gt;End Template Editing&lt;/b&gt; in the smart tag.&lt;br /&gt;&lt;br /&gt;&lt;img style="border: 1px solid black;" src="http://www.c-sharpcorner.com/UploadFile/mosessaur/webpartzones01122006045127AM/Images/DeclarativeCatalogPart.JPG" width="275" border="0" height="371" /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Switch to Source view and add Title attribute to your &lt;b&gt;UserControl&lt;/b&gt; you have just dropped, set its value to "&lt;i&gt;RSS Reader&lt;/i&gt;". Be careful to edit the correct control:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;img style="width: 604px; height: 356px;" alt="" src="http://www.c-sharpcorner.com/UploadFile/mosessaur/webpartzones01122006045127AM/Images/DeclarativeCatalogPartCode.jpg" align="baseline" border="0" hspace="0" /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;img style="border: 1px solid black;" src="http://www.c-sharpcorner.com/UploadFile/mosessaur/webpartzones01122006045127AM/Images/DeclarativeCatalogPartComplete.JPG" width="270" border="0" height="239" /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Drag and drop a &lt;b&gt;DropDownList&lt;/b&gt; into your Web From but out of the table area, rename it to &lt;b&gt;cmbWebPartPageMenu&lt;/b&gt;. Then add the following items to it.&lt;br /&gt;&lt;br /&gt;Normal View&lt;br /&gt;Design View&lt;br /&gt;Edit View&lt;br /&gt;Manage WebParts&lt;br /&gt;&lt;br /&gt;&lt;img style="border: 1px solid black;" src="http://www.c-sharpcorner.com/UploadFile/mosessaur/webpartzones01122006045127AM/Images/DropDownListMenuCode.JPG" width="463" border="0" height="118" /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Set the &lt;b&gt;AutoPostBack&lt;/b&gt; property of the &lt;b&gt;DropDownList&lt;/b&gt; Control to true. and double click on it to implement it default event &lt;b&gt;SelectedIndexChanged:&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;&lt;span style="color:#0000ff;"&gt;protected void&lt;/span&gt; cmbWebPartPageMenu_SelectedIndexChanged(&lt;span style="color:#0000ff;"&gt;object&lt;/span&gt; sender, EventArgs e)&lt;br /&gt;{ &lt;/span&gt; &lt;blockquote&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;&lt;span style="color:#0000ff;"&gt;switch&lt;/span&gt; (cmbWebPartPageMenu.SelectedIndex)&lt;br /&gt;{ &lt;/span&gt; &lt;blockquote&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;&lt;span style="color:#0000ff;"&gt;case&lt;/span&gt; 0:&lt;/span&gt;  &lt;blockquote&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;wpManager.DisplayMode = WebPartManager.BrowseDisplayMode;&lt;br /&gt;break;&lt;/span&gt;&lt;/blockquote&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;&lt;span style="color:#0000ff;"&gt;case&lt;/span&gt; 1:&lt;/span&gt;  &lt;blockquote&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;wpManager.DisplayMode = WebPartManager.DesignDisplayMode;&lt;br /&gt;break;&lt;/span&gt;&lt;/blockquote&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;&lt;span style="color:#0000ff;"&gt;case&lt;/span&gt; 2:&lt;/span&gt;  &lt;blockquote&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;wpManager.DisplayMode = WebPartManager.EditDisplayMode;&lt;br /&gt;break;&lt;/span&gt;&lt;/blockquote&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;&lt;span style="color:#0000ff;"&gt;case&lt;/span&gt; 3:&lt;/span&gt;  &lt;blockquote&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;wpManager.DisplayMode = WebPartManager.CatalogDisplayMode;&lt;br /&gt;break;&lt;/span&gt;&lt;/blockquote&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;&lt;span style="color:#0000ff;"&gt;case&lt;/span&gt; 4:&lt;/span&gt;  &lt;blockquote&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;wpManager.DisplayMode = WebPartManager.ConnectDisplayMode;&lt;br /&gt;break;&lt;/span&gt;&lt;/blockquote&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;&lt;span style="color:#0000ff;"&gt;default&lt;/span&gt;:&lt;/span&gt;  &lt;blockquote&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;wpManager.DisplayMode = WebPartManager.BrowseDisplayMode;&lt;br /&gt;break;&lt;/span&gt;&lt;/blockquote&gt;&lt;/blockquote&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;} &lt;/span&gt;&lt;/blockquote&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Now run your page, select Manage WebParts option and note the changes on the page.&lt;br /&gt;&lt;br /&gt;&lt;img style="border: 1px solid black;" src="http://www.c-sharpcorner.com/UploadFile/mosessaur/webpartzones01122006045127AM/Images/CatalogZone-runtime01.JPG" width="268" border="0" height="198" /&gt;&lt;br /&gt;&lt;br /&gt;Click on Declarative Catalog link and notice the the deference.&lt;br /&gt;&lt;br /&gt;For any WebPart on the the page, click on its menu at the top right corner, and select Close. Notice the changes on the Catalog Zone. you will fine the Page Catalog is increased. Click on Page Catalog link and notice the change on the zone. You can add any WebPart listed to your page, by checking the checkbox of the WebPart, selecting the WebPart Zone and then click Add. &lt;/li&gt;&lt;/span&gt;&lt;/ol&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;Hope by now you understand the deference between &lt;b&gt;DeclarativeCatalogPart&lt;/b&gt; and &lt;b&gt;PageCatalogPart.&lt;/b&gt; As &lt;b&gt;DeclarativeCatalogPart&lt;/b&gt; contains WebParts that is possible to be added to the page and you defined them during design time. But they may not exists physically on the page. While &lt;b&gt;PageCatalogPart&lt;/b&gt; contains all WebParts hosted on the Page.&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;Now let's work with the &lt;b&gt;EditorZone &lt;/b&gt;Control.&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;b&gt;Working with the EditorZone and add personalizable properties to WebParts:&lt;/b&gt;&lt;/span&gt;&lt;/p&gt; &lt;ol&gt;&lt;span style="font-size:85%;"&gt;&lt;li&gt;As we did while working with &lt;b&gt;CatalogZone&lt;/b&gt; Control, drag and drop &lt;b&gt;EditorZone&lt;/b&gt; Control into the 4th column just underneath the CatalogZone control, rename it to &lt;b&gt;wpezEditor&lt;/b&gt;. Also set the Auto Format to Colorful.&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Drag and drop &lt;b&gt;PropertyGridEditorPart &amp;amp; AppearanceEditorPart &lt;/b&gt;into the &lt;b&gt;EditorZone&lt;/b&gt; control. rename the controls to &lt;b&gt;wpPropertyGrid &amp;amp; wpAppearanceEditor.&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Open your &lt;b&gt;UCtrlTitles.ascx&lt;/b&gt; control and switch to Code-Behind. We want to make one of the columns of the GridView inside that control to be optional for view. We will configure the Price Column for this.&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Declare a class level Boolean variable and name it _showPriceColumn as the following.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;&lt;span style="color:#0000ff;"&gt;private bool&lt;/span&gt; _showPriceColumn = &lt;span style="color:#0000ff;"&gt;false&lt;/span&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Create a property for this variable. Mark the property with the following attributes:&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Personalizable()&lt;/b&gt; to be able to personalize the property for the WebPart.&lt;br /&gt;&lt;b&gt;WebBrowsable()&lt;/b&gt; to be able to edit its value while in editing mode.&lt;br /&gt;&lt;b&gt;WebDisplayName("Show Price Column")&lt;/b&gt; to display friendly name on the property grid &lt;b&gt;wpPropertyGrid.&lt;br /&gt;&lt;br /&gt;&lt;/b&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;[&lt;span style="color:#008080;"&gt;Personalizable&lt;/span&gt;(), &lt;span style="color:#008080;"&gt;WebBrowsable&lt;/span&gt;(), &lt;span style="color:#008080;"&gt;WebDisplayName&lt;/span&gt;("Show Price Column")]&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;public bool&lt;/span&gt; ShowPriceColumn&lt;br /&gt;{&lt;/span&gt;  &lt;blockquote&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;&lt;span style="color:#0000ff;"&gt;get&lt;/span&gt; { &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; _showPriceColumn; }&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;set&lt;/span&gt; { _showPriceColumn = &lt;span style="color:#0000ff;"&gt;value&lt;/span&gt;; }&lt;/span&gt;&lt;/blockquote&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt; &lt;/li&gt;&lt;li&gt;Now override the OnPreRender Method of your control as the following:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;&lt;span style="color:#0000ff;"&gt;protected override void&lt;/span&gt; OnPreRender(&lt;span style="color:#008080;"&gt;EventArgs&lt;/span&gt; e)&lt;br /&gt;{&lt;/span&gt;  &lt;blockquote&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;&lt;span style="color:#0000ff;"&gt;base&lt;/span&gt;.OnPreRender(e);&lt;br /&gt;gvTitles.Columns[2].Visible = ShowPriceColumn;&lt;/span&gt;&lt;/blockquote&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt; &lt;/li&gt;&lt;li&gt;Save your work and test the project. From the drop down list option, select Edit View. Then for your Titles or Books WebPart, select Edit from the top right corner menu or it. Notice that the Appearance and Property Grids Displayed. Also notice that the price column is not visible.&lt;br /&gt;&lt;br /&gt;&lt;img style="border: 1px solid black;" src="http://www.c-sharpcorner.com/UploadFile/mosessaur/webpartzones01122006045127AM/Images/WebPartsEditView.JPG" width="286" border="0" height="474" /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Check the Show Price Column checkbox in the property grid. and click apply, Notice that the Price Column on the GridView is now visible. &lt;/li&gt;&lt;/span&gt;&lt;/ol&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;Give yourself 10 min to examine the whole solution running.&lt;/span&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/ynBt/~4/xY7i08Z1qnY" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://purl.org/atom/app#">2009-01-06T09:42:02.293+05:30</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://dotnetfaqs-edu.blogspot.com/2009/01/working-with-webparts-page-webpart.html</feedburner:origLink></item><item><title>Creating a Simple WebPart Page and use WebServer controls as WebParts-1</title><link>http://feedproxy.google.com/~r/blogspot/ynBt/~3/ebxnd0bNEeI/creating-simple-webpart-page-and-use.html</link><category>ASP.NET Controls</category><author>noreply@blogger.com (Tiru)</author><pubDate>Mon, 05 Jan 2009 20:09:57 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-6426652519813936980.post-7520894418551026646</guid><description>&lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;b&gt;Introduction:&lt;br /&gt;&lt;br /&gt;&lt;/b&gt;Portal web sites such as MY MSN and MSN Spaces, often organize their data into discrete units that support a degree of personalization. Information is organized into standalone parts [WebParts], and users can rearrange those parts to suit their individual working styles. Such personalization also lets users hide parts that contain information in which they have no interest. What's more, users can save their settings so that the site will remember their preferences the next time they visit the site. In ASP.NET 2.0, you can now build web portals that offer this kind of modularization of information and personalization using the new Web Parts Framework.&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;b&gt;Scope of this Tutorial:&lt;br /&gt;&lt;br /&gt;&lt;/b&gt;Here we will see how to add web parts to a web part page. Developing advanced WebParts from scratch is out of this tutorial scope. This tutorial also may has subsequent tutorial that explains more about Web Parts Framework.&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;b&gt;Assumptions:&lt;br /&gt;&lt;br /&gt;&lt;/b&gt;This tutorial assumes you are familiar with Data Access Controls and Data Binding Controls such as SqlDataSource and GridView. Also it requires SQL Sever 2005 Express Edition and Visual Web Developer. If you don't have SQL Server Express 2005, install ASPNETDB in your SQL Server instance using &lt;b&gt;aspnet_regsql&lt;/b&gt; tool. and configure your application to use this instance as your personalization provider.&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;b&gt;How to create WebParts Page:&lt;br /&gt;&lt;br /&gt;&lt;/b&gt;To create a WebParts Page, you need to work with a specific ASP.Net 2.0 Controls:&lt;/span&gt;&lt;/p&gt; &lt;ul&gt;&lt;span style="font-size:85%;"&gt;&lt;li&gt;&lt;b&gt;WebPartManager&lt;/b&gt; Control, which manages all Web Parts controls on a WebParts Page and must be the first control that you add to the page.&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt; &lt;p dir="ltr"&gt;&lt;b&gt;WebPartZone &lt;/b&gt;Control, which contains and provides overall layout for the Web Part controls that compose the main UI of a page. This control serves as an anchor for Web Part controls. Multiple controls of this control forms the WebParts Page.&lt;br /&gt;&lt;br /&gt;The &lt;b&gt;WebPartZone&lt;/b&gt; may contains one or more WebParts. &lt;/p&gt;&lt;/li&gt;&lt;/span&gt;&lt;/ul&gt; &lt;p dir="ltr"&gt;&lt;span style="font-size:85%;"&gt;&lt;u&gt;&lt;b&gt;To create a WebPart Page:&lt;/b&gt;&lt;/u&gt;&lt;/span&gt;&lt;/p&gt; &lt;ol dir="ltr"&gt;&lt;span style="font-size:85%;"&gt;&lt;li dir="ltr"&gt; &lt;p dir="ltr"&gt;Create a home page for the Web Parts. Launch Visual Studio 2005 and create a new web site project.&lt;br /&gt;&lt;/p&gt; &lt;/li&gt;&lt;li dir="ltr"&gt; &lt;p dir="ltr"&gt;While in design view, drag and drop a &lt;b&gt;WebPartManager&lt;/b&gt; control from the toolbox (under the WebParts tab) onto the default Web Form, rename it to &lt;b&gt;wpManager.&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;&lt;img style="border: 1px solid black;" alt="WebParts Controls Tab" src="http://www.c-sharpcorner.com/UploadFile/mosessaur/webpartspage01102006193824PM/Images/WebPartsControls.JPG" align="baseline" border="0" hspace="0" /&gt;&lt;br /&gt;&lt;/p&gt; &lt;/li&gt;&lt;li dir="ltr"&gt; &lt;p dir="ltr"&gt;From Layout menu item, select Insert Table, insert table with 3 columns and 1 row. This is where the Web Parts on your page are to be located.&lt;br /&gt;&lt;/p&gt; &lt;/li&gt;&lt;li dir="ltr"&gt; &lt;p dir="ltr"&gt;Drag and drop a &lt;b&gt;WebPartZone&lt;/b&gt; control from the Toolbox (under the WebParts tab) into each of the table's three cells. Each WebPartZone control will serve as the docking area for one or more Web Parts. A Web Part zone is an area where Web Parts are anchored. It also defines the default layout and appearance of each Web Part within that zone.&lt;br /&gt;&lt;/p&gt; &lt;/li&gt;&lt;li dir="ltr"&gt; &lt;p dir="ltr"&gt;Set the ID property for each WebPartZone Control to be &lt;b&gt;wpzLeft&lt;/b&gt;, &lt;b&gt;wpzMiddle&lt;/b&gt; and &lt;b&gt;wpzRight&lt;/b&gt;. Then for each one set the Auto format to Professional.&lt;br /&gt;&lt;br /&gt;&lt;img style="border: 1px solid black;" alt="Auto Format" src="http://www.c-sharpcorner.com/UploadFile/mosessaur/webpartspage01102006193824PM/Images/WebPartZoneAutoFormat.JPG" align="baseline" border="0" hspace="0" /&gt;&lt;br /&gt;&lt;/p&gt; &lt;/li&gt;&lt;li dir="ltr"&gt; &lt;p dir="ltr"&gt;Save your form. &lt;/p&gt;&lt;/li&gt;&lt;/span&gt;&lt;/ol&gt; &lt;p dir="ltr"&gt;&lt;span style="font-size:85%;"&gt;You have created your WebParts Page. Now you want to add WebParts to your page, and manage them at run time so you can rearrange WebParts positions.&lt;br /&gt;&lt;br /&gt;Next we will add 2 WebParts, one will display Information from SQL Server Database. While the other one will display data from XML file.&lt;br /&gt;&lt;br /&gt;&lt;u&gt;&lt;b&gt;Adding WebParts to the WebParts Page:&lt;/b&gt;&lt;/u&gt;&lt;/span&gt;&lt;/p&gt; &lt;ol dir="ltr"&gt;&lt;span style="font-size:85%;"&gt;&lt;li dir="ltr"&gt; &lt;p dir="ltr"&gt;Drag and drop &lt;b&gt;SqlDataSource&lt;/b&gt; control into you Web Form, rename it to &lt;b&gt;sdsTitles&lt;/b&gt;. Configure it to retrieve data from Titles Table in Pubs Database. [you can use SQL Server 2000 or SQL Server 2005 any Edition].&lt;br /&gt;&lt;br /&gt;&lt;img style="border: 1px solid black; width: 561px; height: 91px;" alt="sdsTitles Code " src="http://www.c-sharpcorner.com/UploadFile/mosessaur/webpartspage01102006193824PM/Images/sdsTitlesCode.JPG" align="baseline" border="0" hspace="0" /&gt;&lt;br /&gt;&lt;/p&gt; &lt;/li&gt;&lt;li dir="ltr"&gt; &lt;p dir="ltr"&gt;Drag and drop &lt;b&gt;GridView&lt;/b&gt; into &lt;b&gt;wpzLeft&lt;/b&gt; &lt;b&gt;WebPartZone&lt;/b&gt; control, rename it to &lt;b&gt;gvTitles&lt;/b&gt;. Configure &lt;b&gt;gvTitles&lt;/b&gt; to user &lt;b&gt;sdsTitles&lt;/b&gt; as a Data Source.&lt;br /&gt;&lt;/p&gt; &lt;/li&gt;&lt;li dir="ltr"&gt; &lt;p dir="ltr"&gt;Switch to the Source View and add &lt;b&gt;title&lt;/b&gt; attribute to the &lt;b&gt;GridVew&lt;/b&gt; &lt;b&gt;-gvTitles-&lt;/b&gt; control and set its value to "&lt;i&gt;Titles&lt;/i&gt;".&lt;br /&gt;&lt;br /&gt;&lt;img style="border: 1px solid black;" alt="" src="http://www.c-sharpcorner.com/UploadFile/mosessaur/webpartspage01102006193824PM/Images/GridViewTitleCode.JPG" align="baseline" border="0" hspace="0" /&gt;&lt;br /&gt;&lt;br /&gt;Set Auto format for the &lt;b&gt;GridView&lt;/b&gt; control to classic, also set the Paging and Sorting options, and set PageSize property to 5.&lt;br /&gt;&lt;br /&gt;&lt;img style="border: 1px solid black; width: 531px; height: 539px;" alt="GridView Settings" src="http://www.c-sharpcorner.com/UploadFile/mosessaur/webpartspage01102006193824PM/Images/GridViewSettings.JPG" align="baseline" border="0" hspace="0" /&gt;&lt;br /&gt;&lt;/p&gt; &lt;/li&gt;&lt;li dir="ltr"&gt; &lt;p dir="ltr"&gt;Drag and drop &lt;b&gt;XmlDataSource&lt;/b&gt; control to your Web Form, rename it to &lt;b&gt;xdsRSS&lt;/b&gt;. Configure it to use the RSS.xml that is attached with the demo project, or use any other well-formed XML file you wish.&lt;br /&gt;&lt;br /&gt;&lt;img style="border: 1px solid black;" alt="xdsRSS Configuration" src="http://www.c-sharpcorner.com/UploadFile/mosessaur/webpartspage01102006193824PM/Images/xdsRSSConfig.JPG" align="baseline" border="0" hspace="0" /&gt;&lt;br /&gt;&lt;/p&gt; &lt;/li&gt;&lt;li dir="ltr"&gt; &lt;p dir="ltr"&gt;Drag and drop &lt;b&gt;DataList&lt;/b&gt; into &lt;b&gt;wpzMiddle&lt;/b&gt;, and rename it to &lt;b&gt;dlstRss&lt;/b&gt;. Switch to source view and configure your &lt;b&gt;DataList&lt;/b&gt; as the following.&lt;br /&gt;&lt;br /&gt;&lt;img style="border: 1px solid black; width: 570px; height: 140px;" alt="dlstRss Source View" src="http://www.c-sharpcorner.com/UploadFile/mosessaur/webpartspage01102006193824PM/Images/dlstRssCode.JPG" align="baseline" border="0" hspace="0" /&gt;&lt;br /&gt;&lt;/p&gt; &lt;/li&gt;&lt;li dir="ltr"&gt; &lt;p dir="ltr"&gt;Now test your page. You will be able to see the two Web Parts, minimize them or close them only. On the following steps you'll be able to create to move them and rearrange them.&lt;br /&gt;&lt;/p&gt; &lt;/li&gt;&lt;li dir="ltr"&gt; &lt;p dir="ltr"&gt;Drag and drop &lt;b&gt;LinkBotton&lt;/b&gt; to your page, not into any Web Part Zone, rename it to &lt;b&gt;btnDesign&lt;/b&gt;. and set its &lt;b&gt;text&lt;/b&gt; property to "&lt;i&gt;Design View&lt;/i&gt;"&lt;br /&gt;&lt;/p&gt; &lt;/li&gt;&lt;li dir="ltr"&gt;Double click on the button to add click event handler, then add the following code in the event handler method:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;&lt;span style="color:#0000ff;"&gt;protected void&lt;/span&gt; btnDesign_Click(&lt;span style="color:#0000ff;"&gt;object&lt;/span&gt; sender, &lt;span style="color:#008080;"&gt;EventArgs&lt;/span&gt; e)&lt;br /&gt;{&lt;/span&gt;  &lt;blockquote&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;&lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (btnDesign.Text == "Design View")&lt;br /&gt;{&lt;/span&gt;  &lt;blockquote&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;wpManager.DisplayMode = &lt;span style="color:#008080;"&gt;WebPartManager&lt;/span&gt;.DesignDisplayMode;&lt;br /&gt;btnDesign.Text = "Page View";&lt;/span&gt;&lt;/blockquote&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;}&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;else&lt;/span&gt;&lt;br /&gt;{&lt;/span&gt;  &lt;blockquote&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;wpManager.DisplayMode = &lt;span style="color:#008080;"&gt;WebPartManager&lt;/span&gt;.BrowseDisplayMode;&lt;br /&gt;btnDesign.Text = "Design View";&lt;/span&gt;&lt;/blockquote&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;}&lt;/span&gt;&lt;/blockquote&gt; &lt;p&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;}&lt;br /&gt;&lt;/span&gt;&lt;/p&gt; &lt;/li&gt;&lt;li dir="ltr"&gt;Now Run your application, note when you click on the button you can now rearrange you web parts on the page.&lt;br /&gt;&lt;br /&gt;&lt;img style="border: 1px solid black; width: 602px; height: 600px;" alt="" src="http://www.c-sharpcorner.com/UploadFile/mosessaur/webpartspage01102006193824PM/Images/RunTimeSmall.JPG" align="baseline" border="0" hspace="0" /&gt; &lt;/li&gt;&lt;/span&gt;&lt;/ol&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;b&gt;Conclusion:&lt;br /&gt;&lt;br /&gt;&lt;/b&gt;Now have explored the basics of creating WebParts Page and adding WebParts to it at design/development time. This demo showed that every Control in ASP.Net 2.0 can be a web part without customization or extra code. Same for Custom User Controls; as you can put any controls we have just worked with into a user control, then drag and drop you user control into the &lt;b&gt;WebPartZone&lt;/b&gt; and you will get your user control as WebPart.&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-size:85%;"&gt;WebParts is special kind of WebServer Controls. It has more advanced feature. Hope we will be able to discuss them in subsequent tutorials.&lt;/span&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/ynBt/~4/ebxnd0bNEeI" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://purl.org/atom/app#">2009-01-06T09:39:57.403+05:30</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://dotnetfaqs-edu.blogspot.com/2009/01/creating-simple-webpart-page-and-use.html</feedburner:origLink></item><media:rating>nonadult</media:rating></channel></rss>
