<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://weblogs.asp.net/utility/FeedStylesheets/atom.xsl" media="screen"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en"><title type="html">Guru Sarkar's Blog</title><subtitle type="html" /><id>http://weblogs.asp.net/gurusarkar/atom.aspx</id><link rel="alternate" type="text/html" href="http://weblogs.asp.net/gurusarkar/default.aspx" /><link rel="self" type="application/atom+xml" href="http://weblogs.asp.net/gurusarkar/atom.aspx" /><generator uri="http://communityserver.org" version="3.0.20510.895">Community Server</generator><updated>2010-09-22T14:00:00Z</updated><entry><title>Procedure or function expects parameter which was not supplied.</title><link rel="alternate" type="text/html" href="http://weblogs.asp.net/gurusarkar/archive/2011/08/23/procedure-or-function-expects-parameter-which-was-not-supplied.aspx" /><id>http://weblogs.asp.net/gurusarkar/archive/2011/08/23/procedure-or-function-expects-parameter-which-was-not-supplied.aspx</id><published>2011-08-23T18:50:12Z</published><updated>2011-08-23T18:50:12Z</updated><content type="html">Recently I got this error when doing a ADO.NET database call using ExecuteReader. Procedure or function expects parameter '@myid' , which was not supplied. Actually, the error is kind of misleading. Why because I clearly adding my parameter @myid to the SqlParameters collection of the SqlCommand. cmd.Parameters.Add( “@myid”,1 ) Yes, actually, I had to pass an hard-coded 1 as a value. @myid is defined as int in my database. All top search suggested me that I need to set CommandType.StoredProcedure...(&lt;a href="http://weblogs.asp.net/gurusarkar/archive/2011/08/23/procedure-or-function-expects-parameter-which-was-not-supplied.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7922425" width="1" height="1"&gt;</content><author><name>guru_sarkar</name><uri>http://weblogs.asp.net/members/guru_5F00_sarkar.aspx</uri></author><category term="ADO.NET" scheme="http://weblogs.asp.net/gurusarkar/archive/tags/ADO.NET/default.aspx" /><category term="Stored Procedure" scheme="http://weblogs.asp.net/gurusarkar/archive/tags/Stored+Procedure/default.aspx" /><category term="Sql Server" scheme="http://weblogs.asp.net/gurusarkar/archive/tags/Sql+Server/default.aspx" /></entry><entry><title>Twitter like server-side notifications with ASP.NET and jQuery</title><link rel="alternate" type="text/html" href="http://weblogs.asp.net/gurusarkar/archive/2011/08/14/notifications-with-asp-net.aspx" /><link rel="enclosure" type="application/x-zip-compressed" length="185792" href="http://weblogs.asp.net/gurusarkar/attachment/7909834.ashx" /><id>http://weblogs.asp.net/gurusarkar/archive/2011/08/14/notifications-with-asp-net.aspx</id><published>2011-08-14T06:07:00Z</published><updated>2011-08-14T06:07:00Z</updated><content type="html">I have written a control that can be used to show notification messages like twitter from server-side. This control is kind of a wrapper around a jquery plugin called jnotify by Giva Labs . I thought I will put it up on web if someone wants to use it. jnotify Plugin: Please read about this wonderful plugin here because it does all the UI creation and display magic using jquery. AspNetNotify Control: The control I wrote is called AspNetNotify. The control exposes few properties equivalent to the options...(&lt;a href="http://weblogs.asp.net/gurusarkar/archive/2011/08/14/notifications-with-asp-net.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7909834" width="1" height="1"&gt;</content><author><name>guru_sarkar</name><uri>http://weblogs.asp.net/members/guru_5F00_sarkar.aspx</uri></author><category term="ASP.NET" scheme="http://weblogs.asp.net/gurusarkar/archive/tags/ASP.NET/default.aspx" /><category term="jQuery" scheme="http://weblogs.asp.net/gurusarkar/archive/tags/jQuery/default.aspx" /><category term="jnotify" scheme="http://weblogs.asp.net/gurusarkar/archive/tags/jnotify/default.aspx" /></entry><entry><title>jQuery UI Datepicker Visible upon first time page load</title><link rel="alternate" type="text/html" href="http://weblogs.asp.net/gurusarkar/archive/2011/08/10/jquery-ui-datepicker-visible-upon-first-time-page-load.aspx" /><id>http://weblogs.asp.net/gurusarkar/archive/2011/08/10/jquery-ui-datepicker-visible-upon-first-time-page-load.aspx</id><published>2011-08-11T02:12:13Z</published><updated>2011-08-11T02:12:13Z</updated><content type="html">I have used jQuery UI Datepicker several times before but in one of my recent implementation, I started seeing this weird behavior. At the very bottom of my page there was a thin rectangular box. See the image below: When I selected that element it turned out to be date-picker. That div disappears when the DatePicker is accessed at least once. Looked for the problem and seems it is bug and nobody has tried to resolve it so far. But there is a workaround and that is to explicitly hide it via css....(&lt;a href="http://weblogs.asp.net/gurusarkar/archive/2011/08/10/jquery-ui-datepicker-visible-upon-first-time-page-load.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7905289" width="1" height="1"&gt;</content><author><name>guru_sarkar</name><uri>http://weblogs.asp.net/members/guru_5F00_sarkar.aspx</uri></author><category term="jQuery" scheme="http://weblogs.asp.net/gurusarkar/archive/tags/jQuery/default.aspx" /><category term="datepicker" scheme="http://weblogs.asp.net/gurusarkar/archive/tags/datepicker/default.aspx" /><category term="jQuery UI" scheme="http://weblogs.asp.net/gurusarkar/archive/tags/jQuery+UI/default.aspx" /></entry><entry><title>Adjust Text Input and Textarea Fonts</title><link rel="alternate" type="text/html" href="http://weblogs.asp.net/gurusarkar/archive/2011/08/04/adjust-text-and-textarea-inputs-fonts.aspx" /><id>http://weblogs.asp.net/gurusarkar/archive/2011/08/04/adjust-text-and-textarea-inputs-fonts.aspx</id><published>2011-08-04T22:33:00Z</published><updated>2011-08-04T22:33:00Z</updated><content type="html">I had my text inputs and textareas showing different text font though they were essentially using same styles like: input , textarea { // some styles}; The problem was the font styling was not included in the above css but was defined in body. I added this and it the textarea fonts started showing similar to other text inputs. .mytextarea { font-family : inherit; } Hope this helps. References: Setting Textarea font to match rest text inputs...(&lt;a href="http://weblogs.asp.net/gurusarkar/archive/2011/08/04/adjust-text-and-textarea-inputs-fonts.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7897250" width="1" height="1"&gt;</content><author><name>guru_sarkar</name><uri>http://weblogs.asp.net/members/guru_5F00_sarkar.aspx</uri></author></entry><entry><title>Problem with Unordered List ( ul / li ) tags with fixed–width</title><link rel="alternate" type="text/html" href="http://weblogs.asp.net/gurusarkar/archive/2011/05/11/problem-with-unordered-list-ul-li-tags-with-fixed-width.aspx" /><id>http://weblogs.asp.net/gurusarkar/archive/2011/05/11/problem-with-unordered-list-ul-li-tags-with-fixed-width.aspx</id><published>2011-05-11T22:20:26Z</published><updated>2011-05-11T22:20:26Z</updated><content type="html">This is a very simple issue. I had an unordered list with few items in it. I wanted all the li to be fixed-width. I set the width of the ul and li but it won’t work. Here is what it looked like: I wanted all li to spread evenly along the ul and not to shrink. Here is the code that I had: &amp;lt;! DOCTYPE html PUBLIC &amp;quot;-//W3C//DTD XHTML 1.0 Transitional//EN&amp;quot; &amp;quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&amp;quot; &amp;gt; &amp;lt; html xmlns =&amp;quot;http://www.w3.org/1999/xhtml&amp;quot; &amp;gt;...(&lt;a href="http://weblogs.asp.net/gurusarkar/archive/2011/05/11/problem-with-unordered-list-ul-li-tags-with-fixed-width.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7787037" width="1" height="1"&gt;</content><author><name>guru_sarkar</name><uri>http://weblogs.asp.net/members/guru_5F00_sarkar.aspx</uri></author><category term="CSS" scheme="http://weblogs.asp.net/gurusarkar/archive/tags/CSS/default.aspx" /><category term="Html" scheme="http://weblogs.asp.net/gurusarkar/archive/tags/Html/default.aspx" /></entry><entry><title>Part 3: Showing ASP.NET Server-Side Messages in a Custom Dialog (Server-side with ASP.NET AJAX)</title><link rel="alternate" type="text/html" href="http://weblogs.asp.net/gurusarkar/archive/2011/03/28/part-3-showing-asp-net-server-side-messages-in-a-custom-dialog-server-side-with-asp-net-ajax.aspx" /><id>http://weblogs.asp.net/gurusarkar/archive/2011/03/28/part-3-showing-asp-net-server-side-messages-in-a-custom-dialog-server-side-with-asp-net-ajax.aspx</id><published>2011-03-28T23:14:00Z</published><updated>2011-03-28T23:14:00Z</updated><content type="html">Scenario: There are times when you want to display validation or error message(s) to the user in a pop-up dialog. These messages could be coming from client-side or server-side. In this multi-part series I am going to provide you with the code to accomplish this. Yes, I am not going to explain building from scratch but provided you with working sample, which you can integrate in your web site/application. In this part I have shared the code that will work when you are using ASP.NET AJAX UpdatePanel...(&lt;a href="http://weblogs.asp.net/gurusarkar/archive/2011/03/28/part-3-showing-asp-net-server-side-messages-in-a-custom-dialog-server-side-with-asp-net-ajax.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7736952" width="1" height="1"&gt;</content><author><name>guru_sarkar</name><uri>http://weblogs.asp.net/members/guru_5F00_sarkar.aspx</uri></author></entry><entry><title>Get ValidationGroup of asp.net control in javascript</title><link rel="alternate" type="text/html" href="http://weblogs.asp.net/gurusarkar/archive/2010/12/28/get-validationgroup-of-asp-net-control-in-javascript.aspx" /><id>http://weblogs.asp.net/gurusarkar/archive/2010/12/28/get-validationgroup-of-asp-net-control-in-javascript.aspx</id><published>2010-12-28T23:55:00Z</published><updated>2010-12-28T23:55:00Z</updated><content type="html">Technorati Tags: ValidationGroup , ASP.NET Validator , JavaScript Scenario: Updated : Example 1 scenario - I already posted about it earlier here but will leave it here for reference. Example 1: I wanted to run Page_ClientValidate upon selection change in a RadioButtonList. I have used jQuery to do some of the finding work. Here is the js code. You can download the sample page here to see it in action. $( function () { $( '.rbl' ).change( function () { var id = $( this ).attr( 'id' ); var spans ...(&lt;a href="http://weblogs.asp.net/gurusarkar/archive/2010/12/28/get-validationgroup-of-asp-net-control-in-javascript.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7669731" width="1" height="1"&gt;</content><author><name>guru_sarkar</name><uri>http://weblogs.asp.net/members/guru_5F00_sarkar.aspx</uri></author><category term="ASP.NET" scheme="http://weblogs.asp.net/gurusarkar/archive/tags/ASP.NET/default.aspx" /><category term="JavaScript" scheme="http://weblogs.asp.net/gurusarkar/archive/tags/JavaScript/default.aspx" /><category term="jQuery" scheme="http://weblogs.asp.net/gurusarkar/archive/tags/jQuery/default.aspx" /><category term="asp.NET validation" scheme="http://weblogs.asp.net/gurusarkar/archive/tags/asp.NET+validation/default.aspx" /></entry><entry><title>Part 2: Showing ASP.NET Server-Side Messages in a Custom Dialog (Server-side without ASP.NET AJAX)</title><link rel="alternate" type="text/html" href="http://weblogs.asp.net/gurusarkar/archive/2010/12/18/part-2-showing-asp-net-validation-summary-in-a-custom-dialog-server-side.aspx" /><id>http://weblogs.asp.net/gurusarkar/archive/2010/12/18/part-2-showing-asp-net-validation-summary-in-a-custom-dialog-server-side.aspx</id><published>2010-12-19T01:31:57Z</published><updated>2010-12-19T01:31:57Z</updated><content type="html">Updated (03/28/2011): There were issues if you are using asp.net UpdatePanel and postback is coming from within the panel. So I have updated the code in the dowload and added a separate post to handle the issue. Please look at the Part-3: Include Messages from Server-Side – Using ASP.NET UpdatePanel Scenario: There are times when you want to display validation or error message(s) to the user in a pop-up dialog. These messages could be coming from client-side or server-side. In this multi-part series...(&lt;a href="http://weblogs.asp.net/gurusarkar/archive/2010/12/18/part-2-showing-asp-net-validation-summary-in-a-custom-dialog-server-side.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7663956" width="1" height="1"&gt;</content><author><name>guru_sarkar</name><uri>http://weblogs.asp.net/members/guru_5F00_sarkar.aspx</uri></author></entry><entry><title>Part 1: Showing ASP.NET Validation Summary in a Custom Dialog (Client-Side)</title><link rel="alternate" type="text/html" href="http://weblogs.asp.net/gurusarkar/archive/2010/12/14/part-1-showing-asp-net-validation-summary-in-a-custom-dialog.aspx" /><link rel="enclosure" type="application/zip" length="110758" href="http://weblogs.asp.net/gurusarkar/attachment/7661851.ashx" /><id>http://weblogs.asp.net/gurusarkar/archive/2010/12/14/part-1-showing-asp-net-validation-summary-in-a-custom-dialog.aspx</id><published>2010-12-14T17:03:00Z</published><updated>2010-12-14T17:03:00Z</updated><content type="html">&lt;p&gt;&lt;b&gt;Scenario:&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;There are times when you want to display validation or error message(s) to the user in a pop-up dialog. These messages could be coming from client-side or server-side. In this multi-part series I am going to provide you with the code to accomplish this. Yes, I am not going to explain building from scratch but provided you with working sample, which you can integrate in your web site/application. &lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Background:&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;ASP.NET validation controls are great way to let users know about the constraints on your input controls. Using these controls you can display error message next to the control telling users what needs to be corrected.&amp;nbsp; You can check more about those controls &lt;a href="http://msdn.microsoft.com/en-us/library/aa479013.aspx" target="_blank" mce_href="http://msdn.microsoft.com/en-us/library/aa479013.aspx"&gt;here&lt;/a&gt; (msdn) or &lt;a href="http://quickstarts.asp.net/QuickStartv20/aspnet/doc/validation/default.aspx" target="_blank" mce_href="http://quickstarts.asp.net/QuickStartv20/aspnet/doc/validation/default.aspx"&gt;here&lt;/a&gt; (quickstarts). &lt;/p&gt;  &lt;p&gt;One of the controls is &lt;a href="http://msdn.microsoft.com/en-us/library/aa479013.aspx#aspnet-validateaspnetservercontrols_topic8" target="_blank" mce_href="http://msdn.microsoft.com/en-us/library/aa479013.aspx#aspnet-validateaspnetservercontrols_topic8"&gt;ValidationSummary&lt;/a&gt; control. As the name suggests, it displays the summary of the validation i.e. it aggregates and displays the error messages for each failed validation. You can place this control anywhere on the page and not necessarily right next to any control. But if you are running out of space on the page, it has a property – &lt;i&gt;ShowMessageBox – &lt;/i&gt;which displays the summary of error messages in a pop-up dialog. But unfortunately this message-box has a default look. There is no way to customize the UI for this dialog. Now if you are like me who want a customized UI, then ValidationSummary is not the control for you and so you need to keep reading.&lt;/p&gt;  &lt;p&gt;So instead of using ValidationSummary, I have come up with a script that uses &lt;a href="http://jqueryui.com/demos/dialog/" target="_blank" mce_href="http://jqueryui.com/demos/dialog/"&gt;jQuery UI Dialog&lt;/a&gt; to display the error message summary.&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Road Map:&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;Here is what I think will be the series like:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Part-1: Client-side Validation Summary &lt;/li&gt;    &lt;li&gt;Part-2: &lt;a href="http://weblogs.asp.net/gurusarkar/archive/2010/12/18/part-2-showing-asp-net-validation-summary-in-a-custom-dialog-server-side.aspx"&gt;Include Messages from Server-Side without ASP.NET AJAX&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;Part-3: &lt;a href="http://weblogs.asp.net/gurusarkar/archive/2011/03/28/part-3-showing-asp-net-server-side-messages-in-a-custom-dialog-server-side-with-asp-net-ajax.aspx"&gt;Include Messages from Server-Side using ASP.NET AJAX&lt;/a&gt;&lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;&lt;b&gt;Requirements:&lt;/b&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;ASP.NET Validation Controls: You must be using ASP.NET Validation Controls. So you will need know at least how to use those controls. &lt;/li&gt;    &lt;li&gt;jQuery UI Dialog: We are going to use jQuery and jQuery UI Dialog. You don’t need to know how they work as I have taken care of it. But you will need those libraries. As I will discuss below, you can download them and include them in your project or you can use CDN, as in the sample provided. &lt;/li&gt;    &lt;li&gt;Styles: I have used jQuery UI smoothness theme&amp;nbsp; but also have some customization. You are free to use your own UI. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;b&gt;Download Available:&lt;/b&gt; &lt;a href="http://weblogs.asp.net/blogs/gurusarkar/samplecode//EsDialogDemo_Updated.zip" mce_href="http://weblogs.asp.net/blogs/gurusarkar/samplecode//EsDialogDemo_Updated.zip"&gt;Click here to download &lt;/a&gt;    &lt;br&gt;&lt;/p&gt;  &lt;p&gt;The download provided includes the main files you will need to implement this within your project and also sample files that demonstrates the usage of these scripts. Feel free to post comment / ask me if you find any difficulty. I am going to explain later what the files are in the sample project. I would highly recommend to download the sample first and keep it open while reading further.&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;What’s in this part?&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;The sample I am providing in this part includes Client-side validation scenario only. Any failed validation detected on the client-side will be displayed in the error dialog. Here is the screen-shot of what it will look like when validation fails.&lt;/p&gt;  &lt;p&gt;&lt;i&gt;RequiredFieldValidator Messages:&lt;/i&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/gurusarkar/esClient_1_58C9C645.jpg" mce_href="http://weblogs.asp.net/blogs/gurusarkar/esClient_1_58C9C645.jpg"&gt;&lt;img src="http://weblogs.asp.net/blogs/gurusarkar/esClient_1_thumb_77147D3B.jpg" style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="esClient_1" alt="esClient_1" mce_src="http://weblogs.asp.net/blogs/gurusarkar/esClient_1_thumb_77147D3B.jpg" border="0" height="108" width="244"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;RangeValidator Message for Age:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/gurusarkar/esClient_12_50B299F0.jpg" mce_href="http://weblogs.asp.net/blogs/gurusarkar/esClient_12_50B299F0.jpg"&gt;&lt;img src="http://weblogs.asp.net/blogs/gurusarkar/esClient_12_thumb_27A7FAF4.jpg" style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="esClient_12" alt="esClient_12" mce_src="http://weblogs.asp.net/blogs/gurusarkar/esClient_12_thumb_27A7FAF4.jpg" border="0" height="82" width="244"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Hope this will give you an idea what I was talking for so long. Yes, the messages are coming from asp.net validator controls and the dialog you are looking at is jQuery UI Dialog.&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Project Structure and Files:&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;Let me explain what’s included in the sample download. Here is the current project structure:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/gurusarkar/projectStructure_0550657B.jpg" mce_href="http://weblogs.asp.net/blogs/gurusarkar/projectStructure_0550657B.jpg"&gt;&lt;img src="http://weblogs.asp.net/blogs/gurusarkar/projectStructure_thumb_232EE97C.jpg" style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="projectStructure" alt="projectStructure" mce_src="http://weblogs.asp.net/blogs/gurusarkar/projectStructure_thumb_232EE97C.jpg" border="0" height="244" width="217"&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;1: &lt;b&gt;Root&lt;/b&gt; of the site&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;p&gt;&lt;b&gt;web.config:&lt;/b&gt; It has nothing special. Since this project was developed using VWD Express 2010 + .NET 4.0, it has targetFramework set in there. The key point to note is the&amp;nbsp; &lt;i&gt;&amp;lt;pages theme=”Default”&amp;gt;. &lt;/i&gt;Yes, I need a skin file under the App_Themes/Default. So I have added that.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;&lt;b&gt;Site.master:&lt;/b&gt; That is the masterpage which my pages are using. Check the &amp;lt;head&amp;gt; tag of the page. I have used jquery’s CDN to reference core jquery library (version 1.4.4). Also I have used microsoft’s CDN to reference the jquery UI (v- 1.8.5) library. In addition to those there is dialogScript.js and sitestyles.css references added. Rest is all normal UI. &lt;i&gt;Note: If you are not using masterpage then all these file references should go in the head section of your page.&lt;/i&gt;&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;&lt;b&gt;ESDialog_ClientSide_1.aspx&lt;/b&gt;: This is the sample file that shows how to setup the UI for our error message dialog. I will showing that and explain it in a bit. &lt;/li&gt;    &lt;li&gt;App_Themes and scripts folders: Read below: &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;2: &lt;b&gt;App_Themes&lt;/b&gt; folder: This is the custom asp.net folder that has one theme called Default.&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;b&gt;       &lt;p&gt;&lt;b&gt;Default&lt;/b&gt;: That is the asp.net Theme I added. It has images folder that has images which are required by jquery UI Smoothness theme.&lt;/p&gt;     &lt;/b&gt;&lt;/li&gt;    &lt;li&gt;     &lt;p&gt;&lt;b&gt;jquery-ui-1.8.7.custom.css&lt;/b&gt; : This is the file that came with the downloaded for the smootheness theme(&lt;a href="http://jqueryui.com/download" title="http://jqueryui.com/download" mce_href="http://jqueryui.com/download"&gt;http://jqueryui.com/download&lt;/a&gt;) which is need for the dialog’s look and feel. I simply added this file and the &lt;i&gt;images folder &lt;/i&gt;that came with the dialog. So if you want to use different theme you simply need to add a your new file and images.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;&lt;b&gt;images&lt;/b&gt; folder: As mentioned above is comes as a part of UI dialog with smoothness theme download.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;&lt;b&gt;sitestyles.css&lt;/b&gt;: This file has styles for the master page as well as some customization to dialog.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;SkinFile.skin: This is for any site-wide skinning required. I need that to make the validator text to appear red because by default in ASP.NET 4.0 the text color is black.&lt;/p&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;3: &lt;b&gt;Scripts&lt;/b&gt; folder: It includes the javascript files.&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;p&gt;dialogScript.js: This is the core file that does all the magic of aggregating or removing the messages, showing/hiding of the error dialog and a lot. &lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;future.js: This is not used but I just lying in there and has some code for future use i.e. server-side messages part&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;jquery-1.4.4.js : This is the core-jquery library. Since we are referencing it via cdn we are not using it. I have added it just as a reference purpose. In case if you don’t want to use CDN, you can simply add reference to this file in your masterpage’s &amp;lt;head&amp;gt;.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;jquery-ui-1.8.7.custom.min.js: Like jquery-core this is for reference purpose only and not used in the sample since we are referencing it via microsoft’s CDN.&lt;/p&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;I think that’s all for what is in the project.&lt;/p&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Setup:&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;Here are some basic steps that might help you integrate my solution within your project:&lt;/p&gt;  &lt;p&gt;1: dialogScript.js: Add dialogScript.js in your project and add the reference to it either in your MasterPage or the Page’s &amp;lt;head&amp;gt; section.&lt;/p&gt;  &lt;p&gt;2: jquery core: Download the latest core &lt;a href="http://docs.jquery.com/Downloading_jQuery" target="_blank" mce_href="http://docs.jquery.com/Downloading_jQuery"&gt;jQuery library&lt;/a&gt; (or use what I have provided in the sample) and add there reference to it Or You can use CDN reference as in my sample.&lt;/p&gt;  &lt;p&gt;3: JqueryUI: Add reference to jqueryUI library as shown in sample via CDN or you can use the one I have in the scripts folder.&lt;/p&gt;  &lt;p&gt;4: Themes: Copy my themes folder to App_themes folder. If you have already have a theme and would like to use it then add the contents of the Default them to your existing theme.&lt;/p&gt;  &lt;p&gt;5: The Page: On the page where you want to use this dialog summary, the below divs with exact same ids is &lt;b&gt;mandatory:&lt;/b&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: rgb(244,244,244); margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: 'Courier New',courier,monospace; direction: ltr; height: auto; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;     &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: rgb(244,244,244); margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',courier,monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;br&gt;&lt;span style="color: rgb(0,0,255)"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128,0,0)"&gt;div&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;="error-messages"&lt;/span&gt;&lt;span style="color: rgb(0,0,255)"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;     &lt;span style="color: rgb(0,0,255)"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128,0,0)"&gt;div&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;="message-content"&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;/&amp;gt;&lt;/span&gt;&lt;br&gt; &lt;span style="color: rgb(0,0,255)"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128,0,0)"&gt;div&lt;/span&gt;&lt;span style="color: rgb(0,0,255)"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/blockquote&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;

&lt;p&gt;Yes, that is all the markup you need on your page for our dialog script to work.&lt;/p&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Notes:&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;1: I am not using any AJAX i.e. ScriptManager / UpdatePanel in the sample. I believe it should work with little bit of tweaking. So you can try it. I have kept it for next part where I will be using ASP.NET Ajax.&lt;/p&gt;

&lt;p&gt;2: You can customize the dialog behavior in several ways. You can do it in dialogScript.js and also the look of the dialog using different styles. Let me know if you need any help.&lt;/p&gt;

&lt;p&gt;3: This script was developed considering my custom use scenario, so there are chances it might not work in certain cases. If you find some let me know, I will try to adjust the script in possible. 
  &lt;br&gt;&lt;/p&gt;

&lt;p&gt;&lt;b&gt;&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Conclusion:&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;Hope this is helpful. Sorry, I haven’t provided much explanation of the code, but feel free to ask if something doesn’t work or doesn’t make sense or have any difficulty setting up this guy.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/gurusarkar/samplecode//EsDialogDemo_Updated.zip" mce_href="http://weblogs.asp.net/blogs/gurusarkar/samplecode//EsDialogDemo_Updated.zip"&gt;&lt;b&gt;Sample Download&lt;/b&gt;&lt;/a&gt; 

  &lt;br&gt;&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Credits and Resources:&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;Here are some resources which helped me put this sample together.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href="http://stackoverflow.com/questions/124682/can-you-have-custom-client-side-javascript-validation-for-standard-asp-net-web-fo/125158#125158" target="_blank" mce_href="http://stackoverflow.com/questions/124682/can-you-have-custom-client-side-javascript-validation-for-standard-asp-net-web-fo/125158#125158"&gt;Geoff’s Comment:&lt;/a&gt; This comment is the major contributor to the idea. &lt;/li&gt;

  &lt;li&gt;&lt;a href="http://docs.jquery.com/Downloading_jQuery" target="_blank" mce_href="http://docs.jquery.com/Downloading_jQuery"&gt;jQuery Core&lt;/a&gt; &lt;/li&gt;

  &lt;li&gt;&lt;a href="http://jqueryui.com/download" target="_blank" mce_href="http://jqueryui.com/download"&gt;jQuery UI Dialog&lt;/a&gt; &lt;/li&gt;

  &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/aa479045.aspx" target="_blank" mce_href="http://msdn.microsoft.com/en-us/library/aa479045.aspx"&gt;ASP.NET Validation in Depth&lt;/a&gt; &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Thanks for staying along….&lt;/p&gt;&lt;p&gt;&lt;b&gt;Updated (04/15/2011): Added CustomValidator to sample. &lt;/b&gt;&lt;br&gt;&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7661851" width="1" height="1"&gt;</content><author><name>guru_sarkar</name><uri>http://weblogs.asp.net/members/guru_5F00_sarkar.aspx</uri></author></entry><entry><title>Custom Control with Embedded CSS and Images</title><link rel="alternate" type="text/html" href="http://weblogs.asp.net/gurusarkar/archive/2010/12/10/custom-control-and-embedded-css-and-images.aspx" /><id>http://weblogs.asp.net/gurusarkar/archive/2010/12/10/custom-control-and-embedded-css-and-images.aspx</id><published>2010-12-10T18:00:00Z</published><updated>2010-12-10T18:00:00Z</updated><content type="html">&lt;div id="codeSnippetWrapper" class="csharpcode-wrapper"&gt;   &lt;p&gt;&lt;strong&gt;Scenario:&lt;/strong&gt;&lt;/p&gt; &lt;/div&gt;  &lt;p&gt;I am creating&amp;#160; an ASP.NET custom control (I will blog about it later) which requires embedded resources like CSS, JS and images. My control worked fine but the background image won’t show up. &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;My Initial Setup:&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;I set the Build Action for all my resources to “Embedded Resource”. Here is how I had my css and image entry in the &lt;i&gt;AssemblyInfo.cs:&lt;/i&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; height: auto; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;     &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;       &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;[&lt;span style="color: #0000ff"&gt;assembly&lt;/span&gt;: System.Web.UI.WebResource(&lt;span style="color: #006080"&gt;&amp;quot;MyProjectName.styles.css&amp;quot;&lt;/span&gt;, &lt;span style="color: #006080"&gt;&amp;quot;text/css&amp;quot;&lt;/span&gt;]&lt;/pre&gt;
&lt;!--CRLF--&gt;

      &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;[&lt;span style="color: #0000ff"&gt;assembly&lt;/span&gt;: System.Web.UI.WebResource(&lt;span style="color: #006080"&gt;&amp;quot;MyProjectName.background.png&amp;quot;&lt;/span&gt;, &lt;span style="color: #006080"&gt;&amp;quot;image/png&amp;quot;&lt;/span&gt;)]&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
  &lt;/div&gt;
&lt;/blockquote&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;
&lt;a href="http://11011.net/software/vspaste" mce_href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;And this is how I had my background image reference in my&lt;i&gt; styles.css&lt;/i&gt;:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; height: auto; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #cc6633"&gt;.myclass&lt;/span&gt; { &lt;span style="color: #0000ff"&gt;width&lt;/span&gt;: &lt;span style="color: #006080"&gt;16px;&lt;/span&gt; &lt;span style="color: #0000ff"&gt;height&lt;/span&gt;: &lt;span style="color: #006080"&gt;16px;&lt;/span&gt; &lt;span style="color: #0000ff"&gt;background-image&lt;/span&gt;: url(&lt;span style="color: #0000ff"&gt;background&lt;/span&gt;&lt;span style="color: #cc6633"&gt;.png&lt;/span&gt;); }&lt;/pre&gt;

    &lt;br /&gt;&lt;/div&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;b&gt;Settings that fixed it:&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;After some investigation I found that the image is not found because it was being reference to my site location and not the embedded resource. After searching all over the net I found few hidden lines that solved the issues. Check the Resources below where I found that info.&lt;/p&gt;

&lt;p&gt;Here are two changes I made to AssemblyInfo.cs and styles.css:&lt;/p&gt;

&lt;p id="codeSnippetWrapper"&gt;&lt;/p&gt;

&lt;blockquote&gt;
  &lt;div id="codeSnippetWrapper" class="csharpcode-wrapper"&gt;
    &lt;div id="codeSnippetWrapper" class="csharpcode-wrapper"&gt;
      &lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; height: auto; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
        &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;[&lt;span style="color: #0000ff"&gt;assembly&lt;/span&gt;: System.Web.UI.WebResource(&lt;span style="color: #006080"&gt;&amp;quot;MyProjectName.styles.css&amp;quot;&lt;/span&gt;, &lt;span style="color: #006080"&gt;&amp;quot;text/css&amp;quot;&lt;/span&gt;,PerformSubstitution=&lt;span style="color: #0000ff"&gt;true&lt;/span&gt;)]&lt;/pre&gt;

        &lt;br /&gt;&lt;/div&gt;

      &lt;br /&gt;&lt;/div&gt;

    &lt;br /&gt;&lt;/div&gt;
&lt;/blockquote&gt;

&lt;div&gt;
  &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: rgb(244,244,244); padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;,courier,monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;blockquote&gt;
      &lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; height: auto; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
        &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #cc6633"&gt;.myclass&lt;/span&gt; { &lt;span style="color: #0000ff"&gt;width&lt;/span&gt;: &lt;span style="color: #006080"&gt;16px;&lt;/span&gt; &lt;span style="color: #0000ff"&gt;height&lt;/span&gt;: &lt;span style="color: #006080"&gt;16px;&lt;/span&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;

          &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;           &lt;span style="color: #0000ff"&gt;background-image&lt;/span&gt;: url('&lt;span style="color: #006080"&gt;&amp;lt;&lt;/span&gt;%=WebResource(&amp;quot;MyProjectName&lt;span style="color: #cc6633"&gt;.background&lt;/span&gt;&lt;span style="color: #cc6633"&gt;.png&lt;/span&gt;&amp;quot;)%&lt;span style="color: #006080"&gt;&amp;gt;&lt;/span&gt;');}&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
      &lt;/div&gt;
    &lt;/blockquote&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;b&gt;What those changes do?&lt;/b&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;PerformSubstitution=&lt;span style="color: blue"&gt;true &lt;/span&gt;&lt;b&gt;: &lt;/b&gt;The PerformSubstitution determines whether, during the processing of the embedded resource, other resource URLs are parsed and replaced with the full path to the resource. So when we set that to &lt;b&gt;&lt;i&gt;true &lt;/i&gt;&lt;/b&gt;the refernece to other web resources in the styles.css are resolved during the its parsing. In our case reference to background.png.&lt;/p&gt;
  &lt;/li&gt;

  &lt;li&gt;
    &lt;p&gt;&amp;lt;%=WebResource(&amp;quot;yourwebresource&amp;quot;)%&amp;gt; : That is the syntax to get the link to actual webresource. So '&amp;lt;%=WebResource(&amp;quot;MyProjectName.background.png&amp;quot;)%&amp;gt;' will be replaced with actual url to the resource when the styles.css is parsed before serving it.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;b&gt;Resources / References :&lt;/b&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a title="http://www.4guysfromrolla.com/articles/080906-1.aspx" href="http://www.4guysfromrolla.com/articles/080906-1.aspx" target="_blank" mce_href="http://www.4guysfromrolla.com/articles/080906-1.aspx"&gt;Accessing Embedded Resources through a URL using WebResource.axd&lt;/a&gt; &lt;/li&gt;

  &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.web.ui.webresourceattribute.performsubstitution.aspx" target="_blank" mce_href="http://msdn.microsoft.com/en-us/library/system.web.ui.webresourceattribute.performsubstitution.aspx"&gt;PerformSubstitution Attribute&lt;/a&gt; &lt;/li&gt;

  &lt;li&gt;&lt;a title="http://support.microsoft.com/kb/910442" href="http://support.microsoft.com/kb/910442" mce_href="http://support.microsoft.com/kb/910442"&gt;http://support.microsoft.com/kb/910442&lt;/a&gt; &lt;/li&gt;
&lt;/ul&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7659401" width="1" height="1"&gt;</content><author><name>guru_sarkar</name><uri>http://weblogs.asp.net/members/guru_5F00_sarkar.aspx</uri></author></entry><entry><title>Runtime Error ‘75’. Path / File Access error</title><link rel="alternate" type="text/html" href="http://weblogs.asp.net/gurusarkar/archive/2010/12/05/runtime-error-75-path-file-access-denied.aspx" /><id>http://weblogs.asp.net/gurusarkar/archive/2010/12/05/runtime-error-75-path-file-access-denied.aspx</id><published>2010-12-05T05:24:23Z</published><updated>2010-12-05T05:24:23Z</updated><content type="html">&lt;p&gt;Today I installed an interactive software AV Books. At the end of installation it asked me if I wanted to open it and I selected yes. So the program opens and everything seemed to be working.&lt;/p&gt;  &lt;p&gt;I closed it and after a while opened it again but I started getting the error: Runtime Error ‘75’. Path / File Access error.&lt;/p&gt;  &lt;p&gt;I tried several times and the program won’t start. I thought something got corrupted and so uninstalled it and did a fresh installed. The same result. Finally I searched and while searching I read somewhere ‘Vista’ and that’s it. As if the lightening struck me and I knew what might be causing that error. I just right clicked my program icon and selected ‘Run as Administrator’ and boom…there it opened.&lt;/p&gt;  &lt;h2&gt;In short: &lt;/h2&gt;  &lt;p&gt;Right-click the program –&amp;gt; Select ‘Run as Administrator’&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7655901" width="1" height="1"&gt;</content><author><name>guru_sarkar</name><uri>http://weblogs.asp.net/members/guru_5F00_sarkar.aspx</uri></author></entry><entry><title>Asp.Net Validation on jQuery datepicker date selection</title><link rel="alternate" type="text/html" href="http://weblogs.asp.net/gurusarkar/archive/2010/10/22/asp-net-validation-on-jquery-datepicker-date-selection.aspx" /><id>http://weblogs.asp.net/gurusarkar/archive/2010/10/22/asp-net-validation-on-jquery-datepicker-date-selection.aspx</id><published>2010-10-22T18:23:00Z</published><updated>2010-10-22T18:23:00Z</updated><content type="html">&lt;p&gt;&lt;b&gt;Scenario:&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;I was using jQuery datepicker for one on my test project. The asp.net textbox it was linked to was having RequiredFieldValidator(RFV) and a RegularExpressionValidaton(REV).&lt;/p&gt;  &lt;p&gt;If I simply press my button without entering anything in the textbox, the RFV would fire and show me the error message. Now when I selected a date from the jquery datepicker the error message still stayed there which I wanted it to disappear. The same thing happened for REV as well i.e.after selecting a date using datepicker, if I manually change it to some invalid date, the REV would fire-up and show me the regex error message. But upon re-selecting a valid date from the datepicker, the message won't go. &lt;/p&gt;  &lt;p&gt;After searching the web, here is what I came up with.&lt;/p&gt;  &lt;p&gt;&lt;b&gt;First Attempt:&lt;/b&gt;     &lt;br /&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;blockquote&gt;     &lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; height: auto; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;       &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #008000"&gt;//Find asp.net TextBox and hook it up with datepicker&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #008000"&gt;//Initialize the datepicker with onSelect event&lt;/span&gt;&lt;br /&gt;$(&lt;span style="color: #006080"&gt;&amp;quot;[id$='_txtDate']&amp;quot;&lt;/span&gt;).datepicker({&lt;br /&gt;  onSelect: onSelectHandler&lt;br /&gt; });&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #008000"&gt;//the onselectHandler with flaw&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;function&lt;/span&gt; onSelectHandler() {&lt;br /&gt; &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (&lt;span style="color: #0000ff"&gt;typeof&lt;/span&gt;(Page_ClientValidate) == &lt;span style="color: #006080"&gt;'function'&lt;/span&gt;)&lt;br /&gt;     Page_ClientValidate($(&lt;span style="color: #0000ff"&gt;this&lt;/span&gt;).attr(&lt;span style="color: #006080"&gt;'id'&lt;/span&gt;)); &lt;br /&gt;}&lt;/pre&gt;

      &lt;br /&gt;&lt;/div&gt;
  &lt;/blockquote&gt;

  &lt;blockquote&gt;&lt;/blockquote&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;b&gt;Explanation 1:&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;The first block/ function is where I hookup my textbox with the jQuery datepicker. Note the syntax ($(&amp;quot;[id$='_txtDate']&amp;quot;)) I am using to find my asp.net TextBox. Initialize the datepicker and set the handler for onSelect event. This is the event that is fired when you select a date in the datepicker.&lt;/p&gt;

&lt;p&gt;The onSelectHandler is the function that is called when onSelect event is fired. Here we see if we have a client-side validation function and if there is one then call that function pass the id of our textbox. We get that via $(this).attr('id'). &lt;i&gt;this&lt;/i&gt; refers to our textbox instance. That's it, if the value is valid the error message will disappear.&lt;/p&gt;

&lt;p&gt; This was my first attempt assuming I have got it right but no it had a flaw. The Page_ClientValidate function takes a 'validationgroup' as a parameter. So from my standpoint I was passing a &amp;quot;control id&amp;quot; but the function won't. Since it could not find any match for the value I was passing, it wasn't actually validating but just ignoring the validation and passing back true i.e. everything is valid. This causes every validation message to be made hidden.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Second attempt:&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;So now I knew that my only option is to somehow get the ValidationGroup. I knew that this property is not rendered along-side the control markup because I already tried that and also checked that in the html source. After digging around I found this post -&lt;a href="http://forums.asp.net/p/1531375/3708356.aspx" mce_href="http://forums.asp.net/p/1531375/3708356.aspx"&gt;Use JavaScript to get a control's ValidationGroup &lt;/a&gt;and learned that those properties are called 'expando properties'. Then I knew what to look for next. There I get something that was of my interest:&lt;a href="http://stackoverflow.com/questions/3627805/is-there-a-cross-browser-way-to-use-a-jquery-selector-on-an-expando-property" mce_href="http://stackoverflow.com/questions/3627805/is-there-a-cross-browser-way-to-use-a-jquery-selector-on-an-expando-property"&gt; is-there-a-cross-browser-way-to-use-a-jquery-selector-on-an-expando-property&lt;/a&gt;.

  &lt;br /&gt;&lt;/p&gt;

&lt;p&gt;There was a partial answer to my requirement and below is the modified onSelectHandler event:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; height: auto; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #008000"&gt;//Initialize the datepicker with onSelect event&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;$(&lt;span style="color: #006080"&gt;&amp;quot;[id$='_txtDate']&amp;quot;&lt;/span&gt;).datepicker({ &lt;br /&gt; onSelect: onSelectHandler&lt;br /&gt; });&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #008000"&gt;//onSelectHandler that works &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #0000ff"&gt;function&lt;/span&gt; onSelectHandler() {&lt;br /&gt;    &lt;span style="color: #008000"&gt;//get all the spans i.e. the validators and filter them by controltovalidate&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;var&lt;/span&gt; spans = $(&lt;span style="color: #006080"&gt;'span'&lt;/span&gt;).filter(&lt;span style="color: #0000ff"&gt;function&lt;/span&gt; () { &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.controltovalidate == id; });&lt;br /&gt;    &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (spans.length &amp;gt; 0){&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;var&lt;/span&gt; validationgroup = spans[0].validationGroup;&lt;br /&gt;        &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (&lt;span style="color: #0000ff"&gt;typeof&lt;/span&gt; (Page_ClientValidate) == &lt;span style="color: #006080"&gt;'function'&lt;/span&gt;) &lt;br /&gt;            Page_ClientValidate(validationgroup); &lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;

    &lt;br /&gt;&lt;/div&gt;
&lt;/blockquote&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;b&gt;Explanation 2:&lt;/b&gt;

  &lt;br /&gt;The key points from the second link were: (a) Asp.net Validators are rendered as 'span' tags and (b) You can access the controltovalidate property of the validator using the instance of that span. The (b) was the click that I can then get the validationGroup the same way, which I can then pass to Page_ClientValidate function. So that is the code. &lt;/p&gt;

&lt;p&gt;&lt;b&gt;Conclusion:&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;Basically we are just forcing validation on our textbox upon date selection in the datepicker. Simply calling Page_ClientValidate() was not my choice because my textbox was inside a databound control. I spent time to see if I can get hold of ValidationGroup but finally ended up with this which is more relevant in my case. &lt;/p&gt;

&lt;p&gt;Sorry this is a quick post. I might come back and modify it but for now just want to put the code up there. Thanks and let me know if you have any questions or any other comments.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Update-1: &lt;/b&gt; I found this solution has an issue. Upon date select it does clear out &lt;b&gt;'All'&lt;/b&gt; the validation error messages for other controls as well and not just for the single input textbox. I will post back if I find an alternative. &lt;/p&gt;

&lt;p&gt;&lt;b&gt;Update-2&lt;/b&gt;: Added another code snippet that seems to be working.

  &lt;br /&gt;&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Refrences:&lt;/b&gt; &lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href="http://forums.asp.net/p/1471486/3410915.aspx" mce_href="http://forums.asp.net/p/1471486/3410915.aspx"&gt;http://forums.asp.net/p/1471486/3410915.aspx &lt;/a&gt;&lt;/li&gt;

  &lt;li&gt;&lt;a href="http://forums.asp.net/p/1531375/3708356.aspx"&gt;Use JavaScript to get a control's ValidationGroup&lt;/a&gt;&lt;/li&gt;

  &lt;li&gt;&lt;a href="http://stackoverflow.com/questions/3627805/is-there-a-cross-browser-way-to-use-a-jquery-selector-on-an-expando-property"&gt;is-there-a-cross-browser-way-to-use-a-jquery-selector-on-an-expando-property&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7631174" width="1" height="1"&gt;</content><author><name>guru_sarkar</name><uri>http://weblogs.asp.net/members/guru_5F00_sarkar.aspx</uri></author></entry><entry><title>Get RadioButtonList SelectedValue in JavaScript</title><link rel="alternate" type="text/html" href="http://weblogs.asp.net/gurusarkar/archive/2010/10/14/get-radiobuttonlist-selectedvalue-in-javascript.aspx" /><id>http://weblogs.asp.net/gurusarkar/archive/2010/10/14/get-radiobuttonlist-selectedvalue-in-javascript.aspx</id><published>2010-10-14T17:32:00Z</published><updated>2010-10-14T17:32:00Z</updated><content type="html">&lt;p&gt;&lt;b&gt;Scenario: &lt;/b&gt;There will be times when you would like to access the selected value of your RadioButtonList on the client-side via JavaScript. One of those time coulde be you want to hide/show something elements on your page based on the radio button option selected. Another time could be you want to open a popup window and pass this value to a page via querystring. So the code sample below will is what you can use to get the selected value of the RadioButonList and then use is per your need.&lt;/p&gt;  &lt;p&gt;This is nothing really new but a very old concept. I was lying around in one of my testsite and recently I found someone asking the same question on one of the forum. So I thought to put this on here.&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Code:&lt;/b&gt; &lt;/p&gt;  &lt;p&gt;&amp;#160; JavaScipt&lt;/p&gt;  &lt;pre class="brush: html"&gt;&lt;script language="javascript" type="text/javascript"&gt;
        function rblSelectedValue() {
            //Get the radiobuttonlist reference
            var radio = document.getElementsByName('&lt;%= RadioButtonList1.ClientID %&gt;');
            
            //local variable to store selectedvalue
            var selectedvalue;
            
            //loop through the items in radiobuttonlist
            for (var j = 0; j &lt; radio.length; j++) {
                if (radio[j].checked) {
                    selectedvalue = radio[j].value;
                    alert(selectedvalue);
                    var popupurl = "PopUp.aspx?selval=" + selectedvalue;
                    window.open(popupurl, '', 'height=700,width=700,resizable,scrollbars');
                    break;
                }
            }
        }
&lt;/script&gt;&lt;/pre&gt;

&lt;p&gt;RadioButtonList&lt;/p&gt;

&lt;pre class="brush: html"&gt; &lt;asp:radiobuttonlist id="RadioButtonList1" onclick="rblSelectedValue()" runat="server"&gt;
            &lt;asp:listitem value="1"&gt;One&lt;/asp:listitem&gt;
            &lt;asp:listitem value="2"&gt;Two&lt;/asp:listitem&gt;
            &lt;asp:listitem value="3"&gt;Three&lt;/asp:listitem&gt;
            &lt;asp:listitem value="4"&gt;Four&lt;/asp:listitem&gt;
        &lt;/asp:radiobuttonlist&gt;&lt;/pre&gt;

&lt;p&gt;&lt;b&gt;Brief Explanation:&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;The RadioButtonList has four items and and &amp;quot;onclick&amp;quot; event that will call the rblSelectedValue javascript function.&lt;/p&gt;

&lt;p&gt;In the rblSelectedValue() function, first we get the reference to our RadioButtonList1. &lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;pre class="brush: html"&gt;     var radio = document.getElementsByName('&amp;lt;%= RadioButtonList1.ClientID %&amp;gt;');&lt;/pre&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;Note we are not using 'RadioButtonList1&amp;quot; as a parameter to getElementsByName method but using a special syntax to the the ClientID for the RBL1, which is generated by asp.net framework.&lt;/p&gt;

&lt;p&gt;Then we loop through the items in the RBL using for loop. Note the radio.length, which gives the the number of items in the radiobuttonlist. In the loop we check if the individual item is checked and if it is then assign the value of that item to our local variable, selectedValue.&lt;/p&gt;

&lt;p&gt;Now we can use this value as per our need. As shown in the example, we have an alert as a debug statement to check if we are getting right value and then we are passing this value as a querystring parameter to a url and open that url in a new popup window using window.open method.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Update (04/25/2011):&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;Here is code to get selected value of RadioButtonList using jQuery. The two different ways are more generic i.e. if you have multiple radiobuttonlist, you don’t have to replicate js code for each of them.&lt;/p&gt;

&lt;p&gt;1: Adding onclick event directly to RadioButtoList:&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;span style="color: #0000ff"&gt;function&lt;/span&gt; rblSelectedValue(rbl) {&lt;br /&gt;            &lt;span style="color: #0000ff"&gt;var&lt;/span&gt; selectedvalue = $(&lt;span style="color: #006080"&gt;&amp;quot;#&amp;quot;&lt;/span&gt; + rbl.id + &lt;span style="color: #006080"&gt;&amp;quot; input:radio:checked&amp;quot;&lt;/span&gt;).val();&lt;br /&gt;            alert(selectedvalue);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;&amp;lt;asp:RadioButtonList ID=&lt;span style="color: #006080"&gt;&amp;quot;RadioButtonList1&amp;quot;&lt;/span&gt; runat=&lt;span style="color: #006080"&gt;&amp;quot;server&amp;quot;&lt;/span&gt; OnClick=&lt;span style="color: #006080"&gt;&amp;quot;rblSelectedValue(this)&amp;quot;&lt;/span&gt;&amp;gt;&lt;br /&gt;&lt;/pre&gt;

    &lt;br /&gt;&lt;/div&gt;

  &lt;pre class="csharpcode"&gt;2: Add identical CssClass to each RadioButtonList:&lt;/pre&gt;

  &lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;$(&lt;span style="color: #0000ff"&gt;function&lt;/span&gt; () {&lt;br /&gt;   $(&lt;span style="color: #006080"&gt;&amp;quot;.myrbl&amp;quot;&lt;/span&gt;).click(&lt;span style="color: #0000ff"&gt;function&lt;/span&gt; () {&lt;br /&gt;     &lt;span style="color: #0000ff"&gt;var&lt;/span&gt; selectedvalue = $(&lt;span style="color: #006080"&gt;&amp;quot;#&amp;quot;&lt;/span&gt; + $(&lt;span style="color: #0000ff"&gt;this&lt;/span&gt;).attr(&lt;span style="color: #006080"&gt;'id'&lt;/span&gt;) + &lt;span style="color: #006080"&gt;&amp;quot; input:radio:checked&amp;quot;&lt;/span&gt;).val();&lt;br /&gt;     alert(selectedvalue);&lt;br /&gt;   });&lt;br /&gt;});&lt;br /&gt;&lt;br /&gt;&amp;lt;asp:RadioButtonList ID=&lt;span style="color: #006080"&gt;&amp;quot;RadioButtonList1&amp;quot;&lt;/span&gt; runat=&lt;span style="color: #006080"&gt;&amp;quot;server&amp;quot;&lt;/span&gt; CssClass=&lt;span style="color: #006080"&gt;&amp;quot;myrbl&amp;quot;&lt;/span&gt;&amp;gt;&lt;/pre&gt;

    &lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;b&gt;&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Conclusion:&lt;/b&gt; &lt;/p&gt;

&lt;p&gt;Using pure JavaScript is one way. We can use jQuery to achieve the same goal. Let me know if anyone is looking for a jQuery sample. 
  &lt;br /&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;References:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a title="http://shawpnendu.blogspot.com/2010/10/how-to-set-get-radiobuttonlist-selected.html" href="http://shawpnendu.blogspot.com/2010/10/how-to-set-get-radiobuttonlist-selected.html" target="_blank"&gt;How-to-set-get-radiobuttonlist-selected Value&lt;/a&gt; &lt;/li&gt;
&lt;/ul&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7626855" width="1" height="1"&gt;</content><author><name>guru_sarkar</name><uri>http://weblogs.asp.net/members/guru_5F00_sarkar.aspx</uri></author></entry><entry><title>Pass querystring parameter with NavigaterUrl in HyperLink inside a GridView</title><link rel="alternate" type="text/html" href="http://weblogs.asp.net/gurusarkar/archive/2010/09/23/pass-querystring-parameter-with-navigaterurl-in-hyperlink-inside-a-gridview.aspx" /><id>http://weblogs.asp.net/gurusarkar/archive/2010/09/23/pass-querystring-parameter-with-navigaterurl-in-hyperlink-inside-a-gridview.aspx</id><published>2010-09-23T17:53:00Z</published><updated>2010-09-23T17:53:00Z</updated><content type="html">&lt;p&gt;&lt;b&gt;&lt;/b&gt;&lt;b&gt;&lt;/b&gt;&lt;/p&gt;
&lt;h3&gt;&lt;b&gt;Scenario:&lt;/b&gt;&lt;/h3&gt;
&lt;p&gt;Say you have a databound control like Gridview, Repeater or ListView that contains a column with link (HyperLink)&amp;nbsp; to another page. In most of the cases, you might want to pass a value to another page to know which row or item was clicked by the use. E.g. You have a page that displays Customer records in a GridView and you have a link, when clicked takes the user to another page, where you want to display detailed information of the customer record the user selected in the GridView.&lt;/p&gt;
&lt;p&gt;There are different ways to do this. You can use any of these depending on your scenario. I would say all these are already documented but I am just putting it together.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;&lt;b&gt;Note:&lt;/b&gt;&lt;/i&gt; I will be taking example of GridView these concepts should work for other databound Controls like Repeater, DataList, Listview, etc. There might need little modifications though based on which control you are using. All different ways shown below might not work will all but atleast on of them should work.&amp;nbsp; If you find any difficulty post your question on &lt;a href="http://forums.asp.net/24.aspx" mce_href="http://forums.asp.net/24.aspx"&gt;www.asp.net forums&lt;/a&gt; and a link to that question as a comment to this post. I will look into it and post back. &lt;br&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;1-a: Using HyperLinkField of GridView&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;Below is the code with GridView bound to a SqlDataSource (SDS). The SDS fetches CustomerID, CompanyName and ContactName from Northwind database. There is a link, Details, clicking on which will take you to another page CustomeDetails.aspx which will display more details about that customer. For that we need at least a CustomerId, which we can pass it via querystring to customer details page. The code below uses &lt;a href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.hyperlinkfield.aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.hyperlinkfield.aspx"&gt;HyperLinkField&lt;/a&gt; that will display Details link.&lt;/p&gt;
&lt;div style="BORDER-BOTTOM: silver 1px solid; TEXT-ALIGN: left; BORDER-LEFT: silver 1px solid; PADDING-BOTTOM: 4px; LINE-HEIGHT: 12pt; BACKGROUND-COLOR: #f4f4f4; MARGIN: 20px 0px 10px; PADDING-LEFT: 4px; WIDTH: 97.5%; PADDING-RIGHT: 4px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; MAX-HEIGHT: 200px; FONT-SIZE: 8pt; OVERFLOW: auto; BORDER-TOP: silver 1px solid; CURSOR: text; BORDER-RIGHT: silver 1px solid; PADDING-TOP: 4px" id="codeSnippetWrapper"&gt;
&lt;div style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px" id="codeSnippet"&gt;&lt;pre style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;ASP:GRIDVIEW&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;id&lt;/span&gt;=&lt;span style="COLOR: #ff0000"&gt;GridView1&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: #ff0000"&gt;autogeneratecolumns&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="False"&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;datakeynames&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="CustomerID"&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;datasourceid&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="SqlDataSource1"&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt;     &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    &lt;span style="COLOR: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;COLUMNS&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt;     &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;        &lt;span style="COLOR: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;ASP:HYPERLINKFIELD&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;text&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="Detail"&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;datanavigateurlfields&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="CustomerID"&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;datanavigateurlformatstring&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="CustomerDetails.aspx?customerId={0}"&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;ASP:HYPERLINKFIELD&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt;         &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;        &lt;span style="COLOR: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;ASP:BOUNDFIELD&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;datafield&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="CustomerID"&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;headertext&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="CustomerID"&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;readonly&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="True"&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;sortexpression&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="CustomerID"&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;ASP:BOUNDFIELD&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt;         &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;        &lt;span style="COLOR: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;ASP:BOUNDFIELD&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;datafield&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="CompanyName"&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;headertext&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="CompanyName"&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;sortexpression&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="CompanyName"&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;ASP:BOUNDFIELD&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt;         &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;        &lt;span style="COLOR: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;ASP:BOUNDFIELD&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;datafield&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="ContactName"&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;headertext&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="ContactName"&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;sortexpression&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="ContactName"&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;ASP:BOUNDFIELD&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt;     &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    &lt;span style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;COLUMNS&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;ASP:GRIDVIEW&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;ASP:SQLDATASOURCE&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;id&lt;/span&gt;=&lt;span style="COLOR: #ff0000"&gt;SqlDataSource1&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: #ff0000"&gt;connectionstring&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="&amp;lt;%$ ConnectionStrings:NORTHWNDConnectionString %&amp;gt;"&lt;/span&gt; &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;span style="COLOR: #ff0000"&gt;selectcommand&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="SELECT [CustomerID], [CompanyName], [ContactName] FROM [Customers]"&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;ASP:SQLDATASOURCE&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;&lt;b&gt;Points to Note:&lt;/b&gt; &lt;/p&gt;
&lt;p&gt;a) &lt;a href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.hyperlinkfield.datanavigateurlfields.aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.hyperlinkfield.datanavigateurlfields.aspx"&gt;DataNavigateUrlFields&lt;/a&gt;: This corresponds to the field whose value we want to pass it into the querystring. Here it is CustomerID which we want to pass it to querystring.&lt;/p&gt;
&lt;p&gt;b) &lt;a href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.hyperlinkfield.datanavigateurlformatstring.aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.hyperlinkfield.datanavigateurlformatstring.aspx"&gt;DataNavigateUrlFormatString&lt;/a&gt;:This is the format of your url that will be rendered with the link. So in our e.g.CustomerDetails.aspx?customerId={0}, {0} corresponds to the "first field" in DataNavigateUrlFields i.e. CustomerID. When I said - first field -, it means yes we can have more than one fields, and is discussed next.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;1-b: Passing more than one Querystring parameter with HyperLinkField in GridView:&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;Now what if we want to pass more than one parameter to the querystring? We need to change the two fields discussed above. I the code below, I am passing CompanyName as well in the querystring.&lt;/p&gt;
&lt;blockquote&gt;
&lt;div style="BORDER-BOTTOM: silver 1px solid; TEXT-ALIGN: left; BORDER-LEFT: silver 1px solid; PADDING-BOTTOM: 4px; LINE-HEIGHT: 12pt; BACKGROUND-COLOR: #f4f4f4; MARGIN: 20px 0px 10px; PADDING-LEFT: 4px; WIDTH: 97.5%; PADDING-RIGHT: 4px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; MAX-HEIGHT: 200px; FONT-SIZE: 8pt; OVERFLOW: auto; BORDER-TOP: silver 1px solid; CURSOR: text; BORDER-RIGHT: silver 1px solid; PADDING-TOP: 4px" id="codeSnippetWrapper"&gt;
&lt;div style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px" id="codeSnippet"&gt;&lt;pre style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;asp:hyperlinkfield&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;text&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="Detail"&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;datanavigateurlfields&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="CustomerID,CompanyName"&lt;/span&gt; &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;span style="COLOR: #ff0000"&gt;datanavigateurlformatstring&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="CustomerDetails.aspx?customerId={0}&amp;amp;amp;companyName={1}"&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;p&gt;&lt;b&gt;Points to Note:&lt;/b&gt; &lt;/p&gt;
&lt;p&gt;a) The order of fields in DataNavigateUrlFields matters. i.e. {0} refers to CustomerID because it is the first field and {1} means CompanyName here. &lt;br&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;2-a: Set NavigateUrl property of &lt;/b&gt;&lt;b&gt;HyperLink in TemplateField in Markup &lt;br&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;If you want more granular control, you can use HyperLink control inside TemplateField column type instead of HypeLinkField. Then the code for HyperLink will look like below:&lt;/p&gt;
&lt;div style="BORDER-BOTTOM: silver 1px solid; TEXT-ALIGN: left; BORDER-LEFT: silver 1px solid; PADDING-BOTTOM: 4px; LINE-HEIGHT: 12pt; BACKGROUND-COLOR: #f4f4f4; MARGIN: 20px 0px 10px; PADDING-LEFT: 4px; WIDTH: 97.5%; PADDING-RIGHT: 4px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; MAX-HEIGHT: 200px; FONT-SIZE: 8pt; OVERFLOW: auto; BORDER-TOP: silver 1px solid; CURSOR: text; BORDER-RIGHT: silver 1px solid; PADDING-TOP: 4px" id="codeSnippetWrapper"&gt;
&lt;div style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px" id="codeSnippet"&gt;&lt;pre style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;asp:TemplateField&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;                &lt;span style="COLOR: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;ItemTemplate&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;                &lt;span style="COLOR: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;asp:HyperLink&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;ID&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="hlDetails1"&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;Text&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="Details"&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;runat&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="server"&lt;/span&gt; &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;                &lt;span style="COLOR: #ff0000"&gt;NavigateUrl&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;='&amp;lt;%# "CustomerDetails.aspx?customer=" + Eval("CustomerID") + "&amp;amp;CompanyName=" + Server.UrlEncode(Eval("CompanyName").ToString())%&amp;gt;'&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;/&amp;gt;&lt;/span&gt; &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;                &lt;span style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;ItemTemplate&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    &lt;span style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;asp:TemplateField&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;&lt;b&gt;Points to Note:&lt;/b&gt; &lt;/p&gt;
&lt;p&gt;a)&amp;nbsp; &lt;i&gt;NavigateUrl&lt;/i&gt;:&lt;i&gt; &lt;/i&gt;You will be using here the NavigateUrl property of HyperLink control and build it like a string.&lt;/p&gt;
&lt;p&gt;b) &lt;i&gt;Eval&lt;/i&gt; : Using Eval method to get the field values e.g. Eval("CustomerID"&lt;/p&gt;
&lt;p&gt;c) &lt;i&gt;Server.UrlEncode: &lt;/i&gt;If you think your field is going to have spaces or special characters then use that. e.g. here the CompanyName can have spaces.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;2-b: &lt;/b&gt;&lt;b&gt;Set NavigateUrl property of &lt;/b&gt;&lt;b&gt;HyperLink by Calling method in code-behind:&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;In this case, say you don't want to have too much manipulation in your markup or want some dynamic way to get the pagename, here is one another way to set the NavigateUrl property of HyperLink Field. This is the method that should work with almost all DataBound controls i.e. GV,DataList, Repeater, DetailsView, ListView, etc. &lt;br&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;div id="codeSnippetWrapper"&gt;
&lt;div style="BORDER-BOTTOM: silver 1px solid; TEXT-ALIGN: left; BORDER-LEFT: silver 1px solid; PADDING-BOTTOM: 4px; LINE-HEIGHT: 12pt; BACKGROUND-COLOR: #f4f4f4; MARGIN: 20px 0px 10px; PADDING-LEFT: 4px; WIDTH: 97.5%; PADDING-RIGHT: 4px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; MAX-HEIGHT: 200px; FONT-SIZE: 8pt; OVERFLOW: auto; BORDER-TOP: silver 1px solid; CURSOR: text; BORDER-RIGHT: silver 1px solid; PADDING-TOP: 4px" id="codeSnippetWrapper"&gt;
&lt;div style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px" id="codeSnippet"&gt;&lt;pre style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;asp:TemplateField&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    &lt;span style="COLOR: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;ItemTemplate&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;        &lt;span style="COLOR: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;asp:HyperLink&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;id&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="hlDetails2"&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;Text&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="Details"&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;Runat&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="server"&lt;/span&gt; &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;        &lt;span style="COLOR: #ff0000"&gt;NavigateUrl&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;='&amp;lt;%# GetUrl(Eval("CustomerID"),Eval("CompanyName"))%&amp;gt;'&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;/&amp;gt;&lt;/span&gt; &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    &lt;span style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;ItemTemplate&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;asp:TemplateField&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;br&gt;&lt;/div&gt;
&lt;div style="BORDER-BOTTOM: silver 1px solid; TEXT-ALIGN: left; BORDER-LEFT: silver 1px solid; PADDING-BOTTOM: 4px; LINE-HEIGHT: 12pt; BACKGROUND-COLOR: #f4f4f4; MARGIN: 20px 0px 10px; PADDING-LEFT: 4px; WIDTH: 97.5%; PADDING-RIGHT: 4px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; MAX-HEIGHT: 200px; FONT-SIZE: 8pt; OVERFLOW: auto; BORDER-TOP: silver 1px solid; CURSOR: text; BORDER-RIGHT: silver 1px solid; PADDING-TOP: 4px" id="codeSnippetWrapper"&gt;
&lt;div style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px" id="codeSnippet"&gt;&lt;pre style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;span style="COLOR: #0000ff"&gt;public&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt; GetUrl(&lt;span style="COLOR: #0000ff"&gt;object&lt;/span&gt; id, &lt;span style="COLOR: #0000ff"&gt;object&lt;/span&gt; companyname) &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt; { &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt; &lt;span style="COLOR: #008000"&gt;//here you can do validation e.g. if companyname is not null or something &lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt; &lt;span style="COLOR: #008000"&gt;//Also you can do some customization based on your logged-in user &lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt; &lt;span style="COLOR: #008000"&gt;//You can get the Page location dynamically from say web.config&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt; &lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt; url = &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;span style="COLOR: #006080"&gt;"~/CustomerDetails.aspx?customerid="&lt;/span&gt; + id.ToString() + &lt;span style="COLOR: #006080"&gt;"&amp;amp;companyname="&lt;/span&gt; + &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;Server.UrlEncode(companyname.ToString()); &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&amp;nbsp;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt; &lt;span style="COLOR: #0000ff"&gt;return&lt;/span&gt; url; &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt; }&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;p&gt;&lt;b&gt;Points to Note:&lt;/b&gt; &lt;/p&gt;
&lt;p&gt;a) NavigateUrl now calls GetUrl method in the code-behind. Our GetUrl method takes 2 parameters namely customerid and companyname which we want to pass as querystring parameter.&lt;/p&gt;
&lt;p&gt;b) GetUrl being in the code-behind, you can use all sort of customization/validation basically anything you want to build your url. &lt;/p&gt;
&lt;p&gt;&lt;b&gt;2-c: Set NavigateUrl in RowDataBound event&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;In this method we will use RowDataBound event of GridView Control. Now if you want to use it with Repeater or ListView or other control, you will be using corresponding event for that control. e.g. For Repeater you will be using ItemDataBound control. Below is the code:&lt;/p&gt;
&lt;p&gt;i) Add RowDataBound event to GV. So your markup will change like below(in C#).&lt;/p&gt;
&lt;blockquote&gt;
&lt;div style="BORDER-BOTTOM: silver 1px solid; TEXT-ALIGN: left; BORDER-LEFT: silver 1px solid; PADDING-BOTTOM: 4px; LINE-HEIGHT: 12pt; BACKGROUND-COLOR: #f4f4f4; MARGIN: 20px 0px 10px; PADDING-LEFT: 4px; WIDTH: 97.5%; PADDING-RIGHT: 4px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; MAX-HEIGHT: 200px; FONT-SIZE: 8pt; OVERFLOW: auto; BORDER-TOP: silver 1px solid; CURSOR: text; BORDER-RIGHT: silver 1px solid; PADDING-TOP: 4px" id="codeSnippetWrapper"&gt;
&lt;div style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px" id="codeSnippet"&gt;&lt;pre style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;asp:GridView&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;ID&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="GridView1"&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: #ff0000"&gt;AutoGenerateColumns&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="False"&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;DataKeyNames&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="CustomerID"&lt;/span&gt; &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;span style="COLOR: #ff0000"&gt;DataSourceID&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="SqlDataSource1"&lt;/span&gt; &lt;span style="COLOR: #ff0000"&gt;onrowdatabound&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;="GridView1_RowDataBound"&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;...&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;...&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #800000"&gt;asp:GridView&lt;/span&gt;&lt;span style="COLOR: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;p&gt;ii) Add this to your code-behind:&lt;/p&gt;
&lt;div style="BORDER-BOTTOM: silver 1px solid; TEXT-ALIGN: left; BORDER-LEFT: silver 1px solid; PADDING-BOTTOM: 4px; LINE-HEIGHT: 12pt; BACKGROUND-COLOR: #f4f4f4; MARGIN: 20px 0px 10px; PADDING-LEFT: 4px; WIDTH: 97.5%; PADDING-RIGHT: 4px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; MAX-HEIGHT: 200px; FONT-SIZE: 8pt; OVERFLOW: auto; BORDER-TOP: silver 1px solid; CURSOR: text; BORDER-RIGHT: silver 1px solid; PADDING-TOP: 4px" id="codeSnippetWrapper"&gt;
&lt;div style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px" id="codeSnippet"&gt;&lt;pre style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;span style="COLOR: #0000ff"&gt;protected&lt;/span&gt; &lt;span style="COLOR: #0000ff"&gt;void&lt;/span&gt; GridView1_RowDataBound(&lt;span style="COLOR: #0000ff"&gt;object&lt;/span&gt; sender, GridViewRowEventArgs e) &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;{ &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt; &lt;span style="COLOR: #0000ff"&gt;if&lt;/span&gt; (e.Row.RowType == DataControlRowType.DataRow) &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt; { &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    HyperLink hl = (HyperLink)e.Row.FindControl(&lt;span style="COLOR: #006080"&gt;"hlDetails2"&lt;/span&gt;); &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    &lt;span style="COLOR: #0000ff"&gt;if&lt;/span&gt; (hl != &lt;span style="COLOR: #0000ff"&gt;null&lt;/span&gt;) &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    { &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;        DataRowView drv = (DataRowView)e.Row.DataItem; &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;        &lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt; id = drv[&lt;span style="COLOR: #006080"&gt;"CustomerID"&lt;/span&gt;].ToString(); &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;        &lt;span style="COLOR: #0000ff"&gt;string&lt;/span&gt; companyname = drv[&lt;span style="COLOR: #006080"&gt;"CompanyName"&lt;/span&gt;].ToString(); &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;        hl.NavigateUrl = &lt;span style="COLOR: #006080"&gt;"~/CustomerDetails.aspx?customerid="&lt;/span&gt; + id.ToString() + &lt;span style="COLOR: #006080"&gt;"&amp;amp;companyname="&lt;/span&gt; + Server.UrlEncode(companyname.ToString()); &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    } &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt; } &lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;}&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;&lt;b&gt;Points To Note&lt;/b&gt;:&lt;/p&gt;
&lt;p&gt;a) As I said earlier this concept will work for other databound controls but will need to make sure you use right event and right properties.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Conclusion:&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;Hope one of these methods will come handy. There might be some errors or some other ways. Let me know if you find any and I will update this post accordingly.&lt;/p&gt;
&lt;p&gt;Sorry for the code-formatting. It is giving me hard time. So I have used in half and not in other. &lt;/p&gt;
&lt;p&gt;&lt;b&gt;Update: &lt;/b&gt;Finally I think the code-formatting now looks better.&lt;/p&gt;&lt;p&gt;&lt;b&gt;Update 9/9/2011:&lt;/b&gt; From the comment by wonjartran below let me point out that for using DataRowView, you will need to import&lt;b&gt; System.Data&lt;/b&gt; namespace.&lt;/p&gt;&lt;p&gt;i.e.&amp;nbsp;&lt;i&gt; using System.Data&lt;/i&gt; (C#) /&lt;i&gt; Imports System.Data &lt;/i&gt;(VB.NET) &lt;br&gt;&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7619554" width="1" height="1"&gt;</content><author><name>guru_sarkar</name><uri>http://weblogs.asp.net/members/guru_5F00_sarkar.aspx</uri></author></entry><entry><title>Get GridView RowIndex upon button click</title><link rel="alternate" type="text/html" href="http://weblogs.asp.net/gurusarkar/archive/2010/09/22/get-gridview-rowindex-upon-button-click.aspx" /><id>http://weblogs.asp.net/gurusarkar/archive/2010/09/22/get-gridview-rowindex-upon-button-click.aspx</id><published>2010-09-22T18:00:00Z</published><updated>2010-09-22T18:00:00Z</updated><content type="html">
&lt;p&gt;&lt;b&gt;Scenario:&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;There might be case when you want to get the row-index or any other details from the row, when a button inside a GridView Row is clicked. I will show you different ways.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;1:&amp;nbsp; "Select" link/button Click&lt;/b&gt;&lt;br&gt;&lt;br&gt;It is very easy when to get row information when you click auto-generated "Select" link/button in GridView row. When this link/button is clicked, gridview raises "Select" event. GridView exposes &lt;i&gt;&lt;b&gt;SelectedRow&lt;/b&gt;&lt;/i&gt; property which represents the currently selected row and &lt;i&gt;&lt;b&gt;SelectedIndex&lt;/b&gt;&lt;/i&gt; property which gives the rowindex of the currently selected Row.&lt;/p&gt;

&lt;p&gt;When you click the "Select" link/button, you might sometimes want to run custom code using RowIndex. You can do that easily by handling &lt;b&gt;&lt;i&gt;OnSelectedIndexChanged&lt;/i&gt;&lt;/b&gt; event and do your manipulation.&lt;/p&gt;

&lt;p&gt;Now suppose it is not a "Select" button i.e. a button whose CommandName is not 'Select'. In that case you can use any of the following options.&lt;br&gt;&lt;/p&gt;

&lt;p&gt;&lt;b&gt;2: Passing RowIndex as CommandArgument of the Button&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;a) Define you but inside a TemplateField.&lt;/p&gt;

&lt;p&gt;b) Set it's CommandName property to some meaningful value&lt;br&gt;&lt;/p&gt;

&lt;p&gt;c) Set the CommandArgument of the button as shown in code below.&lt;/p&gt;

&lt;p&gt;d) Then use OnRowCommand event to access the row as show in code below:&lt;/p&gt;

&lt;p&gt;e.g.&amp;nbsp; here is a sample TemplateField that has a button and the corresponding OnRowCommand event handler&lt;br&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;pre class="brush: html"&gt;&amp;lt;asp:TemplateField&amp;gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;ItemTemplate&amp;gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;asp:Button ID="Button1" CommandName="MyButtonClick" CommandArgument='&amp;lt;%# Container.DataItemIndex %&amp;gt;' &amp;nbsp;runat="server" Text="MyButton" /&amp;gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;asp:Button ID="Button2" runat="server" Text="Button" /&amp;gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/ItemTemplate&amp;gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/asp:TemplateField&amp;gt;&lt;/pre&gt;
&lt;/blockquote&gt;

&lt;blockquote&gt;
&lt;pre class="brush: html"&gt;&amp;nbsp;protected void GridView1_RowCommand(object sender, System.Web.UI.WebControls.GridViewCommandEventArgs e)&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (e.CommandName == "MyButtonClick")&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Get rowindex&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; int rowindex = Convert.ToInt32(e.CommandArgument);&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Get Row&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; GridViewRow gvr = GridView1.Rows[rowindex];&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;
&lt;/blockquote&gt;

&lt;p&gt;Point to note: CommandArgument='&amp;lt;%# Container.DataItemIndex %&amp;gt;'. Container.DataItemIndex gives the index of current item.&lt;br&gt;&lt;/p&gt;

&lt;p&gt;&lt;b&gt;3: &lt;/b&gt;&lt;b&gt;Use Button Click Event&lt;/b&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;pre class="brush: html"&gt;&amp;nbsp;&amp;lt;asp:TemplateField&amp;gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;ItemTemplate&amp;gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;asp:Button ID="Button1" runat="server" Text="Button" OnClick="MyButtonClick" /&amp;gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/ItemTemplate&amp;gt;&lt;br&gt;&amp;lt;/asp:TemplateField&amp;gt;
&amp;nbsp;protected void MyButtonClick(object sender, System.EventArgs e)&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Get the button that raised the event&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Button btn = (Button)sender;&lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Get the row that contains this button&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; GridViewRow gvr = (GridViewRow)btn.NamingContainer;&lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Get rowindex&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; int rowindex = gvr.RowIndex;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;br&gt;&lt;/pre&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;b&gt;Point to note:&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;The last method works with other controls like DropDownList, CheckBoxList, etc inside of gridview. e.g. In case of dropdownlist you will use the OnSelectedIndexChanged event&amp;nbsp; like shown below:&lt;/p&gt;

&lt;blockquote&gt;
&lt;pre class="brush: html"&gt;&amp;nbsp;protected void DropDownList1_SelectedIndexChanged(object sender, System.EventArgs e)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Get the dropdownlist that raised the event&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DropDownList ddl = (DropDownList)sender;&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Get the row that contains this dropdown&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; GridViewRow gvr = (GridViewRow)ddl .NamingContainer;&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Get rowindex&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; int rowindex = gvr.RowIndex;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&amp;nbsp; &lt;/pre&gt;
&lt;/blockquote&gt;

&lt;p&gt;Hope this helps. &lt;br&gt;&lt;/p&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7618762" width="1" height="1"&gt;</content><author><name>guru_sarkar</name><uri>http://weblogs.asp.net/members/guru_5F00_sarkar.aspx</uri></author><category term="GridView" scheme="http://weblogs.asp.net/gurusarkar/archive/tags/GridView/default.aspx" /><category term="RowIndex" scheme="http://weblogs.asp.net/gurusarkar/archive/tags/RowIndex/default.aspx" /></entry></feed>
