<?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">Joe Wrobel </title><subtitle type="html" /><id>http://weblogs.asp.net/joewrobel/atom.aspx</id><link rel="alternate" type="text/html" href="http://weblogs.asp.net/joewrobel/default.aspx" /><link rel="self" type="application/atom+xml" href="http://weblogs.asp.net/joewrobel/atom.aspx" /><generator uri="http://communityserver.org" version="3.0.20510.895">Community Server</generator><updated>2008-01-30T17:47:00Z</updated><entry><title>Conditional Formatting in the Silverlight DataGrid</title><link rel="alternate" type="text/html" href="http://weblogs.asp.net/joewrobel/archive/2009/01/25/conditional-formatting-in-the-silverlight-datagrid.aspx" /><id>http://weblogs.asp.net/joewrobel/archive/2009/01/25/conditional-formatting-in-the-silverlight-datagrid.aspx</id><published>2009-01-26T06:57:00Z</published><updated>2009-01-26T06:57:00Z</updated><content type="html">&lt;P&gt;I’ve been an asp.net developer for some time now and I was excited to jump on to Silverlight when it 2.0 &lt;BR&gt;was released a few months ago.&amp;nbsp; One thing I really struggled with was applying conditional formatting to &lt;BR&gt;the individual cells in the DataGrid control.&amp;nbsp; Coming from an asp.net background, I carried a lot of &lt;BR&gt;assumptions with me (big mistake).&amp;nbsp; I thought I could get a hold of the rows or cells collection and have &lt;BR&gt;my way with it, but no such luck.&amp;nbsp; I stumbled down several paths which all ultimately lead to dead ends.&amp;nbsp; &lt;BR&gt;After killing hours (maybe days) on trying to figure this out, I had to let it go and move on.&amp;nbsp; Now a month &lt;BR&gt;later I decided to give it another shot and I finally got it.&amp;nbsp; The answer was right in front of me all along.&amp;nbsp; &lt;BR&gt;I knew about the IValueConverter interface, but I didn’t fully understand its capabilities.&amp;nbsp; I thought it was &lt;BR&gt;only used for converting an object into a text representation or vice versa.&amp;nbsp; Actually, you can return &lt;BR&gt;anything you want from it.&amp;nbsp; So you can return a Button, Grid, or whatever.&lt;/P&gt;
&lt;P&gt;Another aspect I couldn’t figure out was how to get access to page members from within the Convert &lt;BR&gt;method.&amp;nbsp; For example, I wanted to render a button in the cell and wire up the button’s click event to a &lt;BR&gt;method in the page.&amp;nbsp; Sure, you could do this to a certain extent using templates, but then I couldn’t &lt;BR&gt;find a way to change the template conditionally based on a value in the bound data item.&lt;/P&gt;
&lt;P&gt;The solution I came up with was to create a delegate along with a class which implemented the &lt;BR&gt;IValueConverter interface and exposed two events.&amp;nbsp; One for converting and the other for converting &lt;BR&gt;back.&amp;nbsp; I can then declare this converter in the resources collection and setup a handler in the page &lt;BR&gt;as shown below.&lt;/P&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;UserControl.Resources&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;BR&gt;    &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;local:UniversalConverter&lt;/SPAN&gt; &lt;SPAN class=attr&gt;x:Key&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="ageConverter"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;Converting&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="ConvertAge"&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;/&amp;gt;&lt;/SPAN&gt;&lt;BR&gt;    &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;local:UniversalConverter&lt;/SPAN&gt; &lt;SPAN class=attr&gt;x:Key&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="nameConverter"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;Converting&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="ConvertName"&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;/&amp;gt;&lt;/SPAN&gt;&lt;BR&gt;&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;UserControl.Resources&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;STYLE type=text/css&gt;



.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/STYLE&gt;

&lt;STYLE type=text/css&gt;



.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/STYLE&gt;

&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is the markup i used in the “First Name” column of the DataGrid.&lt;/P&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;data:DataGridTemplateColumn&lt;/SPAN&gt; &lt;SPAN class=attr&gt;Header&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="First Name"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;BR&gt;    &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;data:DataGridTemplateColumn.CellTemplate&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;BR&gt;        &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;DataTemplate&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;BR&gt;            &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;ContentControl&lt;/SPAN&gt; &lt;SPAN class=attr&gt;Content&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="{Binding Converter={StaticResource nameConverter}}"&lt;/SPAN&gt;&lt;BR&gt;                &lt;SPAN class=attr&gt;HorizontalContentAlignment&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="Stretch"&lt;/SPAN&gt;  &lt;BR&gt;                &lt;SPAN class=attr&gt;VerticalContentAlignment&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="Stretch"&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;/&amp;gt;&lt;/SPAN&gt;&lt;BR&gt;        &lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;DataTemplate&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;BR&gt;    &lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;data:DataGridTemplateColumn.CellTemplate&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;BR&gt;&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;data:DataGridTemplateColumn&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;STYLE type=text/css&gt;


.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/STYLE&gt;

&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is the “ConvertName” method I wired up from the converter defined in the resources collection.&lt;/P&gt;
&lt;DIV class=csharpcode&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;   1:  &lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;private&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;object&lt;/SPAN&gt; ConvertName(&lt;SPAN class=kwrd&gt;object&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;value&lt;/SPAN&gt;, Type targetType, &lt;BR&gt;                      &lt;SPAN class=kwrd&gt;object&lt;/SPAN&gt; parameter, CultureInfo culture) {&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;   2:  &lt;/SPAN&gt;    Employee employee = &lt;SPAN class=kwrd&gt;value&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;as&lt;/SPAN&gt; Employee;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;   3:  &lt;/SPAN&gt;    &lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt; (employee == &lt;SPAN class=kwrd&gt;null&lt;/SPAN&gt;) {&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;   4:  &lt;/SPAN&gt;        &lt;SPAN class=kwrd&gt;return&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;value&lt;/SPAN&gt;;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;   5:  &lt;/SPAN&gt;    }&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;   6:  &lt;/SPAN&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;   7:  &lt;/SPAN&gt;    &lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt; (employee.FirstName.Contains(&lt;SPAN class=str&gt;'a'&lt;/SPAN&gt;)) {&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;   8:  &lt;/SPAN&gt;        Button btn = &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; Button();&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;   9:  &lt;/SPAN&gt;        btn.Content = employee.FirstName;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  10:  &lt;/SPAN&gt;        btn.Click += ((sender, e) =&amp;gt; {&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  11:  &lt;/SPAN&gt;          HtmlPage.Window.Alert(&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  12:  &lt;/SPAN&gt;            &lt;SPAN class=kwrd&gt;string&lt;/SPAN&gt;.Format(&lt;BR&gt;                   &lt;SPAN class=str&gt;"There is a button here because \"{0}\" contains an \"a\"."&lt;/SPAN&gt;, &lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  13:  &lt;/SPAN&gt;            employee.FirstName));&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  14:  &lt;/SPAN&gt;        });&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  15:  &lt;/SPAN&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  16:  &lt;/SPAN&gt;        &lt;SPAN class=kwrd&gt;return&lt;/SPAN&gt; btn;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  17:  &lt;/SPAN&gt;    }&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  18:  &lt;/SPAN&gt;    &lt;SPAN class=kwrd&gt;return&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; TextBlock {Text = employee.FirstName};&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  19:  &lt;/SPAN&gt;}&lt;/PRE&gt;&lt;/DIV&gt;
&lt;STYLE type=text/css&gt;


.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/STYLE&gt;

&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is the IConverter class and delegate I created to handle the conversions.&lt;/P&gt;
&lt;DIV class=csharpcode&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;   1:  &lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;public&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;class&lt;/SPAN&gt; UniversalConverter : IValueConverter {&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;   2:  &lt;/SPAN&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;   3:  &lt;/SPAN&gt;    &lt;SPAN class=kwrd&gt;public&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;object&lt;/SPAN&gt; Convert(&lt;SPAN class=kwrd&gt;object&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;value&lt;/SPAN&gt;, Type targetType, &lt;BR&gt;                         &lt;SPAN class=kwrd&gt;object&lt;/SPAN&gt; parameter, CultureInfo culture) {&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;   4:  &lt;/SPAN&gt;        &lt;SPAN class=kwrd&gt;return&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;this&lt;/SPAN&gt;.OnConverting(&lt;SPAN class=kwrd&gt;value&lt;/SPAN&gt;, targetType, &lt;BR&gt;                                        parameter, culture);&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;   5:  &lt;/SPAN&gt;    }&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;   6:  &lt;/SPAN&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;   7:  &lt;/SPAN&gt;    &lt;SPAN class=kwrd&gt;public&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;object&lt;/SPAN&gt; ConvertBack(&lt;SPAN class=kwrd&gt;object&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;value&lt;/SPAN&gt;, Type targetType, &lt;BR&gt;                         &lt;SPAN class=kwrd&gt;object&lt;/SPAN&gt; parameter, CultureInfo culture) {&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;   8:  &lt;/SPAN&gt;        &lt;SPAN class=kwrd&gt;return&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;this&lt;/SPAN&gt;.OnConvertingBack(&lt;SPAN class=kwrd&gt;value&lt;/SPAN&gt;, targetType, &lt;BR&gt;                                            parameter, culture);&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;   9:  &lt;/SPAN&gt;    }&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  10:  &lt;/SPAN&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  11:  &lt;/SPAN&gt;    &lt;SPAN class=kwrd&gt;protected&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;object&lt;/SPAN&gt; OnConverting(&lt;SPAN class=kwrd&gt;object&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;value&lt;/SPAN&gt;, Type targetType, &lt;BR&gt;                            &lt;SPAN class=kwrd&gt;object&lt;/SPAN&gt; parameter, CultureInfo culture) {&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  12:  &lt;/SPAN&gt;        UniversalConverterHandler handler = &lt;SPAN class=kwrd&gt;this&lt;/SPAN&gt;.Converting;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  13:  &lt;/SPAN&gt;        &lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt; (handler != &lt;SPAN class=kwrd&gt;null&lt;/SPAN&gt;) {&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  14:  &lt;/SPAN&gt;            &lt;SPAN class=kwrd&gt;return&lt;/SPAN&gt; handler(&lt;SPAN class=kwrd&gt;value&lt;/SPAN&gt;, targetType, parameter, culture);&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  15:  &lt;/SPAN&gt;        }&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  16:  &lt;/SPAN&gt;        &lt;SPAN class=kwrd&gt;return&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;value&lt;/SPAN&gt;;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  17:  &lt;/SPAN&gt;    }&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  18:  &lt;/SPAN&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  19:  &lt;/SPAN&gt;    &lt;SPAN class=kwrd&gt;protected&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;object&lt;/SPAN&gt; OnConvertingBack(&lt;SPAN class=kwrd&gt;object&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;value&lt;/SPAN&gt;, Type targetType, &lt;BR&gt;                            &lt;SPAN class=kwrd&gt;object&lt;/SPAN&gt; parameter, CultureInfo culture) {&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  20:  &lt;/SPAN&gt;        UniversalConverterHandler handler = &lt;SPAN class=kwrd&gt;this&lt;/SPAN&gt;.ConvertingBack;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  21:  &lt;/SPAN&gt;        &lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt; (handler != &lt;SPAN class=kwrd&gt;null&lt;/SPAN&gt;) {&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  22:  &lt;/SPAN&gt;            &lt;SPAN class=kwrd&gt;return&lt;/SPAN&gt; handler(&lt;SPAN class=kwrd&gt;value&lt;/SPAN&gt;, targetType, parameter, culture);&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  23:  &lt;/SPAN&gt;        }&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  24:  &lt;/SPAN&gt;        &lt;SPAN class=kwrd&gt;return&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;value&lt;/SPAN&gt;;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  25:  &lt;/SPAN&gt;    }&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  26:  &lt;/SPAN&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  27:  &lt;/SPAN&gt;    &lt;SPAN class=kwrd&gt;public&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;event&lt;/SPAN&gt; UniversalConverterHandler Converting;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  28:  &lt;/SPAN&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  29:  &lt;/SPAN&gt;    &lt;SPAN class=kwrd&gt;public&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;event&lt;/SPAN&gt; UniversalConverterHandler ConvertingBack;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  30:  &lt;/SPAN&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  31:  &lt;/SPAN&gt;}&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  32:  &lt;/SPAN&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  33:  &lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;public&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;delegate&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;object&lt;/SPAN&gt; UniversalConverterHandler(&lt;SPAN class=kwrd&gt;object&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;value&lt;/SPAN&gt;, Type targetType, &lt;BR&gt;                              &lt;SPAN class=kwrd&gt;object&lt;/SPAN&gt; parameter, CultureInfo culture);&lt;/PRE&gt;&lt;/DIV&gt;
&lt;STYLE type=text/css&gt;


.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/STYLE&gt;

&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And finally, here is a screenshot of the DataGrid. (Ugly, I know, but it proves my point.) &lt;BR&gt;&lt;A href="http://weblogs.asp.net/blogs/joewrobel/image_6FD4DF33.png" mce_href="http://weblogs.asp.net/blogs/joewrobel/image_6FD4DF33.png"&gt;&lt;IMG title=image style="BORDER-TOP-WIDTH: 0px; DISPLAY: inline; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=233 alt=image src="http://weblogs.asp.net/blogs/joewrobel/image_thumb_73E1BDB6.png" width=434 border=0 mce_src="http://weblogs.asp.net/blogs/joewrobel/image_thumb_73E1BDB6.png"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://weblogs.asp.net/blogs/joewrobel/SlGridDemo1.zip" target=_blank mce_href="http://weblogs.asp.net/blogs/joewrobel/SlGridDemo1.zip"&gt;Here is a link to the complete solution. &lt;/A&gt;&lt;BR&gt;&lt;/P&gt;
&lt;P&gt;I hope you find this useful and I look forward to hearing feedback and suggestions.&amp;nbsp; &lt;BR&gt;Most importantly, let me know if you know of a better way to do this.&lt;/P&gt;
&lt;P&gt;Thanks &lt;BR&gt;-Joe&lt;/P&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6860520" width="1" height="1"&gt;</content><author><name>robolize</name><uri>http://weblogs.asp.net/members/robolize.aspx</uri></author><category term="C#" scheme="http://weblogs.asp.net/joewrobel/archive/tags/C_2300_/default.aspx" /><category term="Silverlight" scheme="http://weblogs.asp.net/joewrobel/archive/tags/Silverlight/default.aspx" /></entry><entry><title>Web Profile Builder 1.3</title><link rel="alternate" type="text/html" href="http://weblogs.asp.net/joewrobel/archive/2008/05/04/web-profile-builder-1-3.aspx" /><id>http://weblogs.asp.net/joewrobel/archive/2008/05/04/web-profile-builder-1-3.aspx</id><published>2008-05-05T05:33:00Z</published><updated>2008-05-05T05:33:00Z</updated><content type="html">&lt;FONT face=Calibri size=3&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;I released a new build of Web Profile Builder.&lt;BR&gt;Not much has changed for the 1.3 release.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;The focus of this release was to revert an undesirable change I made for version 1.2.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;I did however add one new feature so I changed the version to 1.3.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;What was the new feature added?&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;I changed the generated profile class to be a partial class.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Now you can easily add any custom code to the profile class (in a separate code file) without losing your changes when the profile class gets regenerated.&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;Files can be downloaded from the MSDN Code Gallery &lt;A class="" title=here href="https://code.msdn.microsoft.com/Release/ProjectReleases.aspx?ProjectName=WebProfileBuilder&amp;amp;ReleaseId=980" target=_blank mce_href="https://code.msdn.microsoft.com/Release/ProjectReleases.aspx?ProjectName=WebProfileBuilder&amp;amp;ReleaseId=980"&gt;here&lt;/A&gt;.&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;Thanks&lt;BR&gt;-Joe&lt;/P&gt;&lt;/FONT&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6158303" width="1" height="1"&gt;</content><author><name>robolize</name><uri>http://weblogs.asp.net/members/robolize.aspx</uri></author></entry><entry><title>Web Profile Builder 1.2.0.0 Released</title><link rel="alternate" type="text/html" href="http://weblogs.asp.net/joewrobel/archive/2008/04/16/web-profile-builder-1-2-0-0-released.aspx" /><id>http://weblogs.asp.net/joewrobel/archive/2008/04/16/web-profile-builder-1-2-0-0-released.aspx</id><published>2008-04-17T04:16:03Z</published><updated>2008-04-17T04:16:03Z</updated><content type="html">&lt;p&gt;Files can be downloaded from the &lt;a href="http://code.msdn.microsoft.com/WebProfileBuilder" mce_href="http://code.msdn.microsoft.com/WebProfileBuilder"&gt;Web Profile Builder&lt;/a&gt; project page.    &lt;br /&gt;If you are unfamiliar with Web Profile Builder, you can read my initial blog post about it &lt;a href="http://weblogs.asp.net/joewrobel/archive/2008/02/03/web-profile-builder-for-web-application-projects.aspx" target="_blank" mce_href="http://weblogs.asp.net/joewrobel/archive/2008/02/03/web-profile-builder-for-web-application-projects.aspx"&gt;here&lt;/a&gt;.    &lt;br /&gt;Details of this release can be found on the &lt;a href="http://code.msdn.microsoft.com/WebProfileBuilder/Release/ProjectReleases.aspx?ReleaseId=918" target="_blank"&gt;Code Gallery web site&lt;/a&gt;.    &lt;br /&gt;I had a little time to put together some basic documentation.&amp;#160; It is available from the &lt;a href="http://code.msdn.microsoft.com/WebProfileBuilder/Release/ProjectReleases.aspx?ReleaseId=918" target="_blank"&gt;release download&lt;/a&gt; section.&lt;/p&gt;  &lt;p&gt;Thanks   &lt;br /&gt;-Joe&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6104723" width="1" height="1"&gt;</content><author><name>robolize</name><uri>http://weblogs.asp.net/members/robolize.aspx</uri></author><category term="ASP.NET" scheme="http://weblogs.asp.net/joewrobel/archive/tags/ASP.NET/default.aspx" /><category term="C#" scheme="http://weblogs.asp.net/joewrobel/archive/tags/C_2300_/default.aspx" /><category term="Profile" scheme="http://weblogs.asp.net/joewrobel/archive/tags/Profile/default.aspx" /><category term="WAP" scheme="http://weblogs.asp.net/joewrobel/archive/tags/WAP/default.aspx" /><category term="Web Application Project" scheme="http://weblogs.asp.net/joewrobel/archive/tags/Web+Application+Project/default.aspx" /></entry><entry><title>Web Profile Builder 1.1.0.0 Released</title><link rel="alternate" type="text/html" href="http://weblogs.asp.net/joewrobel/archive/2008/03/17/web-profile-builder-1-1-0-0-released.aspx" /><id>http://weblogs.asp.net/joewrobel/archive/2008/03/17/web-profile-builder-1-1-0-0-released.aspx</id><published>2008-03-17T06:00:00Z</published><updated>2008-03-17T06:00:00Z</updated><content type="html">&lt;P&gt;Files can be downloaded from the &lt;A href="http://code.msdn.microsoft.com/WebProfileBuilder" mce_href="http://code.msdn.microsoft.com/WebProfileBuilder"&gt;Web Profile Builder&lt;/A&gt; project page.&lt;/P&gt;
&lt;P&gt;If you are unfamiliar with Web Profile Builder, you can read my initial blog post about it &lt;A href="http://weblogs.asp.net/joewrobel/archive/2008/02/03/web-profile-builder-for-web-application-projects.aspx" target=_blank mce_href="http://weblogs.asp.net/joewrobel/archive/2008/02/03/web-profile-builder-for-web-application-projects.aspx"&gt;here&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Changes made for release 1.1.0.0:&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Added the ability to detect changes made to the profile section of the web.config file &lt;BR&gt;and only rebuild the Profile class if changes have been made.&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Notes:&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;If you used the previous release, remember to uninstall it first.&lt;/LI&gt;
&lt;LI&gt;Also, if you used the previous release and added the customize section in the &lt;BR&gt;web.config file, remember to update the assembly reference to &lt;BR&gt;“WebProfileBuilder.WebProfileConfigurationSection, WebProfileBuilder, Version=1.1.0.0, &lt;BR&gt;Culture=neutral, PublicKeyToken=01d50f1f82943b0c”.&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;Thank you to everybody who provided me with valuable feedback.&amp;nbsp; This release should address &lt;BR&gt;all of your concerns.&lt;/P&gt;
&lt;P&gt;Thanks &lt;BR&gt;-Joe&lt;/P&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=5981513" width="1" height="1"&gt;</content><author><name>robolize</name><uri>http://weblogs.asp.net/members/robolize.aspx</uri></author><category term="ASP.NET" scheme="http://weblogs.asp.net/joewrobel/archive/tags/ASP.NET/default.aspx" /><category term="C#" scheme="http://weblogs.asp.net/joewrobel/archive/tags/C_2300_/default.aspx" /><category term="Profile" scheme="http://weblogs.asp.net/joewrobel/archive/tags/Profile/default.aspx" /><category term="WAP" scheme="http://weblogs.asp.net/joewrobel/archive/tags/WAP/default.aspx" /><category term="Web Application Project" scheme="http://weblogs.asp.net/joewrobel/archive/tags/Web+Application+Project/default.aspx" /></entry><entry><title>ClientID Problem In External JavaScript Files Solved</title><link rel="alternate" type="text/html" href="http://weblogs.asp.net/joewrobel/archive/2008/02/19/clientid-problem-in-external-javascript-files-solved.aspx" /><id>http://weblogs.asp.net/joewrobel/archive/2008/02/19/clientid-problem-in-external-javascript-files-solved.aspx</id><published>2008-02-20T06:18:00Z</published><updated>2008-02-20T06:18:00Z</updated><content type="html">&lt;P&gt;&lt;FONT face="Courier New" size=2&gt;Well, at least for me it is.&amp;nbsp; I say that because this solution might &lt;BR&gt;not appeal to the masses, but it works great for me.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=2&gt;The binary and source files can be downloaded from the MSDN Code Gallery. &lt;BR&gt;Here is the direct link. &lt;BR&gt;&lt;A title=http://code.msdn.microsoft.com/RegClientControls href="http://code.msdn.microsoft.com/RegClientControls" mce_href="http://code.msdn.microsoft.com/RegClientControls"&gt;http://code.msdn.microsoft.com/RegClientControls&lt;/A&gt; &lt;BR&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=2&gt;Up until lately, I have been writing my JavaScript in the .aspx file. &lt;BR&gt;That way I could use the ClientID trick.&amp;nbsp; &lt;STRONG&gt;&amp;lt;%=TextBox1.ClientID%&amp;gt;&lt;/STRONG&gt; &lt;BR&gt;I just began working with a team who prefers to write all JavaScript in &lt;BR&gt;external .js files.&amp;nbsp; What they had been doing is hard coding the &lt;BR&gt;ClientID prefixes caused by the container controls.&amp;nbsp; I guess this works &lt;BR&gt;fine.&amp;nbsp; It has been working for them so far.&amp;nbsp; I personally can't do this. &lt;BR&gt;It just feels wrong.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=2&gt;I took some time to figure out a better way to deal with the ClientID in &lt;BR&gt;an external JavaScript file.&amp;nbsp; I found an interesting article &lt;/FONT&gt;&lt;A href="http://www.netfxharmonics.com/2007/09/Creating-JavaScript-objects-from-ASPNET-objects" target=_blank mce_href="http://www.netfxharmonics.com/2007/09/Creating-JavaScript-objects-from-ASPNET-objects"&gt;&lt;FONT face="Courier New" size=2&gt;here&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face="Courier New" size=2&gt; about &lt;BR&gt;&lt;/FONT&gt;&lt;A href="http://www.netfxharmonics.com/2007/09/Creating-JavaScript-objects-from-ASPNET-objects" target=_blank mce_href="http://www.netfxharmonics.com/2007/09/Creating-JavaScript-objects-from-ASPNET-objects"&gt;&lt;FONT face="Courier New" size=2&gt;Creating JavaScript objects from ASP.NET objects&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face="Courier New" size=2&gt;.&amp;nbsp; I liked David's technique, &lt;BR&gt;but it still required manually writing JavaScript on the .aspx page. I wrote &lt;BR&gt;a control called "RegClient" that encapsulates and automates this technique. &lt;BR&gt;If you place this control on your page anywhere below the Script Manager, &lt;BR&gt;then all you have to do to access the controls from JavaScript is something &lt;BR&gt;like "&lt;STRONG&gt;&lt;FONT color=#0000ff&gt;var&lt;/FONT&gt; controlObj = PageControls.TextBox1;&lt;/STRONG&gt;".&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=2&gt;The RegClient control is dependant on Microsoft ASP.NET AJAX 1.0.&amp;nbsp; The &lt;BR&gt;source could easily be targeted to .NET 3.5 if you wanted.&amp;nbsp; I'm sure &lt;BR&gt;that with a little work it could even be library independent, but I &lt;BR&gt;didn't have that requirement.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=2&gt;The RegClient control has two modes, "Marked" and "All".&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN-BOTTOM: 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;FONT face="Courier New"&gt;&lt;FONT color=#000000&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: green; FONT-FAMILY: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;&lt;STRONG&gt;&lt;FONT size=3&gt;Marked:&lt;/FONT&gt;&lt;/STRONG&gt; &lt;BR&gt;With the RegClient control set to Marked, only the controls marked with &lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: green; FONT-FAMILY: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;RegClient="true" or ClientControlID="{yourClientName}" will be registered.&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;TABLE class="" cellSpacing=0 cellPadding=2 width=600 border=1&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="" vAlign=top width=598&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Robo&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;RegClient&lt;/SPAN&gt; &lt;SPAN style="COLOR: red"&gt;ID&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="RegClient1"&lt;/SPAN&gt; &lt;SPAN style="COLOR: red"&gt;runat&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="server"&lt;/SPAN&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; LINE-HEIGHT: 115%; FONT-FAMILY: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;&lt;SPAN style="COLOR: red"&gt;ClientControls&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="Marked"&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;/&amp;gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;
&lt;P class=MsoNormal style="MARGIN-BOTTOM: 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; LINE-HEIGHT: 115%; FONT-FAMILY: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;&lt;SPAN style="COLOR: blue"&gt;&lt;FONT face="Courier New" size=2&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN-BOTTOM: 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; LINE-HEIGHT: 115%; FONT-FAMILY: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;&lt;SPAN style="COLOR: blue"&gt;&lt;FONT face="Courier New" size=2&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN-BOTTOM: 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: green; FONT-FAMILY: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;&lt;FONT face="Courier New"&gt;&lt;STRONG&gt;&lt;FONT size=3&gt;All:&lt;/FONT&gt;&lt;/STRONG&gt; &lt;BR&gt;With the RegClient control set to All, every control in master &lt;BR&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: green; FONT-FAMILY: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;and content pages will &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: green; FONT-FAMILY: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;be registered unless RegClient="&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: green; FONT-FAMILY: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;false".&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;TABLE class="" cellSpacing=0 cellPadding=2 width=600 border=1&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="" vAlign=top width=600&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;Robo&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;RegClient&lt;/SPAN&gt; &lt;SPAN style="COLOR: red"&gt;ID&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="RegClient1"&lt;/SPAN&gt; &lt;SPAN style="COLOR: red"&gt;runat&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="server" &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; LINE-HEIGHT: 115%; FONT-FAMILY: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;&lt;SPAN style="COLOR: red"&gt;ClientControls&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="All"&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;/&amp;gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;
&lt;P class=MsoNormal style="MARGIN-BOTTOM: 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; LINE-HEIGHT: 115%; FONT-FAMILY: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;&lt;SPAN style="COLOR: blue"&gt;&lt;FONT face="Courier New" size=2&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN-BOTTOM: 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; LINE-HEIGHT: 115%; FONT-FAMILY: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;&lt;SPAN style="COLOR: blue"&gt;&lt;FONT face="Courier New" size=2&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN-BOTTOM: 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; LINE-HEIGHT: 115%; FONT-FAMILY: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;&lt;SPAN style="COLOR: blue"&gt;&lt;FONT face="Courier New" size=2&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;H6&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: green; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;To access the controls in the external JavaScript file, handle &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: green; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;the &lt;BR&gt;"ready" event of &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: green; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;the "PageControls" object like shown here.&lt;/SPAN&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="FONT-SIZE: 10pt; LINE-HEIGHT: 115%; FONT-FAMILY: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt; &lt;BR&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/H6&gt;
&lt;TABLE class="" cellSpacing=0 cellPadding=2 width=600 border=1&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="" vAlign=top width=598&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;&lt;FONT face="Courier New"&gt;PageControls.add_ready(&lt;SPAN style="COLOR: blue"&gt;function&lt;/SPAN&gt;(){ &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;/SPAN&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;&lt;SPAN style="COLOR: green"&gt;//Write your code here. &lt;BR&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; LINE-HEIGHT: 115%; FONT-FAMILY: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;});&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: green; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;All of the controls that have been registered will be available from &lt;BR&gt;the "PageControls" object in JavaScript.&amp;nbsp; Here is an example of accessing &lt;BR&gt;the controls. &lt;BR&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;TABLE class="" cellSpacing=0 cellPadding=2 width=600 border=1&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="" vAlign=top width=600&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;&lt;FONT face="Courier New"&gt;PageControls.add_ready(&lt;SPAN style="COLOR: blue"&gt;function&lt;/SPAN&gt;(){&amp;nbsp; &lt;BR&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $addHandler($get(&lt;SPAN style="COLOR: #a31515"&gt;'Button2'&lt;/SPAN&gt;), &lt;SPAN style="COLOR: #a31515"&gt;'click'&lt;/SPAN&gt;,&amp;nbsp; &lt;BR&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; function&lt;/SPAN&gt;() {&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; &lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;&lt;FONT face="Courier New"&gt;PageControls.Label1.innerHTML = PageControls.tbText.value;&amp;nbsp; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;&lt;FONT face="Courier New"&gt;}&amp;nbsp; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;/SPAN&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;);&amp;nbsp; &lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; LINE-HEIGHT: 115%; FONT-FAMILY: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?"&gt;});&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: green; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: green; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;FONT color=#ff0000&gt;One caution I would make for using this control is to be careful when you &lt;BR&gt;have the ClientControls setting to "All".&amp;nbsp; This control will find and &lt;BR&gt;register every control that derives from WebControl.&amp;nbsp; If you're using &lt;BR&gt;a GridView or something similar on the page, then there could be many &lt;BR&gt;extra controls that you don't want to get registered.&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: green; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;FONT color=#000000&gt;Here is a screen shot of the RegClient control.&amp;nbsp; There really is only one &lt;BR&gt;setting for this control, but I added a big blob of text as a reminder of &lt;BR&gt;how to use it with other controls.&lt;/FONT&gt; &lt;BR&gt;&lt;/SPAN&gt;&lt;A href="http://weblogs.asp.net/blogs/joewrobel/WindowsLiveWriter/ClientIDProblemInExternalJavaScriptFiles_740E/image_2.png" mce_href="http://weblogs.asp.net/blogs/joewrobel/WindowsLiveWriter/ClientIDProblemInExternalJavaScriptFiles_740E/image_2.png"&gt;&lt;IMG style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=575 alt=image src="http://weblogs.asp.net/blogs/joewrobel/WindowsLiveWriter/ClientIDProblemInExternalJavaScriptFiles_740E/image_thumb.png" width=513 border=0 mce_src="http://weblogs.asp.net/blogs/joewrobel/WindowsLiveWriter/ClientIDProblemInExternalJavaScriptFiles_740E/image_thumb.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" color=#000000 size=2&gt;When the page renders, this is what the generated output looks like at &lt;BR&gt;at the bottom of the page.&lt;/FONT&gt; &lt;BR&gt;&lt;A href="http://weblogs.asp.net/blogs/joewrobel/WindowsLiveWriter/ClientIDProblemInExternalJavaScriptFiles_740E/image_4.png" mce_href="http://weblogs.asp.net/blogs/joewrobel/WindowsLiveWriter/ClientIDProblemInExternalJavaScriptFiles_740E/image_4.png"&gt;&lt;IMG style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=195 alt=image src="http://weblogs.asp.net/blogs/joewrobel/WindowsLiveWriter/ClientIDProblemInExternalJavaScriptFiles_740E/image_thumb_1.png" width=579 border=0 mce_src="http://weblogs.asp.net/blogs/joewrobel/WindowsLiveWriter/ClientIDProblemInExternalJavaScriptFiles_740E/image_thumb_1.png"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=2&gt;So, that's it.&amp;nbsp; I hope you find this useful and if you know of any ways &lt;BR&gt;this control could be improved, please let me know.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=2&gt;Thanks &lt;BR&gt;-Joe&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=5826121" width="1" height="1"&gt;</content><author><name>robolize</name><uri>http://weblogs.asp.net/members/robolize.aspx</uri></author><category term="ASP.NET" scheme="http://weblogs.asp.net/joewrobel/archive/tags/ASP.NET/default.aspx" /><category term="C#" scheme="http://weblogs.asp.net/joewrobel/archive/tags/C_2300_/default.aspx" /><category term="ClientID" scheme="http://weblogs.asp.net/joewrobel/archive/tags/ClientID/default.aspx" /></entry><entry><title>Web Profile Builder for Web Application Projects</title><link rel="alternate" type="text/html" href="http://weblogs.asp.net/joewrobel/archive/2008/02/03/web-profile-builder-for-web-application-projects.aspx" /><id>http://weblogs.asp.net/joewrobel/archive/2008/02/03/web-profile-builder-for-web-application-projects.aspx</id><published>2008-02-03T10:21:00Z</published><updated>2008-02-03T10:21:00Z</updated><content type="html">&lt;P&gt;Files can be downloaded from the &lt;A class="" href="http://code.msdn.microsoft.com/WebProfileBuilder" target=_blank mce_href="http://code.msdn.microsoft.com/WebProfileBuilder"&gt;Web Profile Builder&lt;/A&gt; project page.&lt;/P&gt;
&lt;P&gt;If you use Web Application Projects, you have probably run into the issue of not being &lt;BR&gt;able to access the Profile at design time.&lt;/P&gt;
&lt;P&gt;Thankfully, some nice people created an Add-In for Visual Studio 2005 that will generate &lt;BR&gt;a wrapper class as a workaround.&amp;nbsp; That project can be found &lt;A href="http://www.codeplex.com/WebProfile" target=_blank mce_href="http://www.codeplex.com/WebProfile"&gt;here&lt;/A&gt;.&amp;nbsp; I wanted to contribute &lt;BR&gt;to the &lt;A href="http://www.codeplex.com/WebProfile" target=_blank mce_href="http://www.codeplex.com/WebProfile"&gt;Web Profile Generator&lt;/A&gt; project, but my emails went unanswered.&amp;nbsp; I decided to start &lt;BR&gt;a new project.&lt;/P&gt;
&lt;P&gt;This project picks up where that one left off and is based on their source code.&amp;nbsp; I started &lt;BR&gt;out rebuilding that project as it stood to add support for Visual Studio 2008.&amp;nbsp; I got it to &lt;BR&gt;work, but I wanted to do more.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;I decided to go ahead and address the issues listed on the original &lt;A href="http://www.codeplex.com/WebProfile/WorkItem/List.aspx" target=_blank mce_href="http://www.codeplex.com/WebProfile/WorkItem/List.aspx"&gt;project site&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;Here is a summary of the changes made.&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;First of all, this is no longer an Add-In.&amp;nbsp; Instead, it is a Build Task.&lt;/LI&gt;
&lt;LI&gt;Works for Visual Studio 2005 and 2008.&lt;/LI&gt;
&lt;LI&gt;Added ability to set the file name.&lt;/LI&gt;
&lt;LI&gt;Added ability to set the directory the file gets created in.&lt;/LI&gt;
&lt;LI&gt;Added ability to set the class name.&lt;/LI&gt;
&lt;LI&gt;Added ability to set the name space.&lt;/LI&gt;
&lt;LI&gt;Added an extra method as requested &lt;A href="http://www.codeplex.com/WebProfile/Thread/View.aspx?ThreadId=20291" target=_blank mce_href="http://www.codeplex.com/WebProfile/Thread/View.aspx?ThreadId=20291"&gt;here&lt;/A&gt;.&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Usage:&lt;/STRONG&gt;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Run the installer.&lt;/LI&gt;
&lt;LI&gt;Add this Import statement to your project file.&amp;nbsp; (see special notes below) &lt;BR&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; LINE-HEIGHT: 115%; FONT-FAMILY: " yes? mso-no-proof: new?; courier&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #a31515; LINE-HEIGHT: 115%; FONT-FAMILY: " yes? mso-no-proof: new?; courier&gt;Import&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; LINE-HEIGHT: 115%; FONT-FAMILY: " yes? mso-no-proof: new?; courier&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: red; LINE-HEIGHT: 115%; FONT-FAMILY: " yes? mso-no-proof: new?; courier&gt;Project&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; LINE-HEIGHT: 115%; FONT-FAMILY: " yes? mso-no-proof: new?; courier&gt;=&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; LINE-HEIGHT: 115%; FONT-FAMILY: " yes? mso-no-proof: new?; courier&gt;"&lt;SPAN style="COLOR: blue"&gt;$(MSBuildExtensionsPath)\WebProfileBuilder\WebProfileBuilder.targets&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; /&amp;gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN style="FONT-SIZE: 10pt; LINE-HEIGHT: 115%; FONT-FAMILY: " yes? mso-no-proof: new?; courier&gt;&lt;SPAN style="COLOR: blue"&gt;&lt;FONT face=Arial color=#000000&gt;Done.&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; LINE-HEIGHT: 115%; FONT-FAMILY: " yes? mso-no-proof: new?; courier&gt;&lt;SPAN style="COLOR: blue"&gt;&lt;FONT face=Arial color=#000000&gt;The profile will get generated every time you build the project.&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; LINE-HEIGHT: 115%; FONT-FAMILY: " yes? mso-no-proof: new?; courier&gt;&lt;SPAN style="COLOR: blue"&gt;&lt;FONT face=Arial color=#000000&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; LINE-HEIGHT: 115%; FONT-FAMILY: " yes? mso-no-proof: new?; courier&gt;&lt;SPAN style="COLOR: blue"&gt;&lt;FONT face=Arial color=#000000&gt;&lt;STRONG&gt;Special Notes:&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; LINE-HEIGHT: 115%; FONT-FAMILY: " yes? mso-no-proof: new?; courier&gt;&lt;SPAN style="COLOR: blue"&gt;&lt;FONT face=Arial color=#000000&gt;After you modify the project file by adding the import statement, you will get this security &lt;BR&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; LINE-HEIGHT: 115%; FONT-FAMILY: " yes? mso-no-proof: new?; courier&gt;&lt;SPAN style="COLOR: blue"&gt;&lt;FONT face=Arial color=#000000&gt;warning when the project loads.&amp;nbsp; Choose the "Load project normally" option and press OK. &lt;BR&gt;&lt;A href="http://weblogs.asp.net/blogs/joewrobel/WindowsLiveWriter/WebProfileBuilderforWebApplicationProjec_1891/image_2.png" mce_href="http://weblogs.asp.net/blogs/joewrobel/WindowsLiveWriter/WebProfileBuilderforWebApplicationProjec_1891/image_2.png"&gt;&lt;IMG style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=440 alt=image src="http://weblogs.asp.net/blogs/joewrobel/WindowsLiveWriter/WebProfileBuilderforWebApplicationProjec_1891/image_thumb.png" width=655 border=0 mce_src="http://weblogs.asp.net/blogs/joewrobel/WindowsLiveWriter/WebProfileBuilderforWebApplicationProjec_1891/image_thumb.png"&gt;&lt;/A&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; LINE-HEIGHT: 115%; FONT-FAMILY: " yes? mso-no-proof: new?; courier&gt;&lt;SPAN style="COLOR: blue"&gt;&lt;FONT face=Arial color=#000000&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; LINE-HEIGHT: 115%; FONT-FAMILY: " yes? mso-no-proof: new?; courier&gt;&lt;SPAN style="COLOR: blue"&gt;&lt;FONT face=Arial color=#000000&gt;&lt;STRONG&gt;Extended Usage:&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; LINE-HEIGHT: 115%; FONT-FAMILY: " yes? mso-no-proof: new?; courier&gt;&lt;SPAN style="COLOR: blue"&gt;&lt;FONT face=Arial color=#000000&gt;If you want to customize the web profile, you can add the following sections to your web.config.&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; LINE-HEIGHT: 115%; FONT-FAMILY: " yes? mso-no-proof: new?; courier&gt;&lt;SPAN style="COLOR: blue"&gt;&lt;FONT face=Arial color=#000000&gt;This section needs to be at the top of the file just under the opening configuration tag. &lt;BR&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: " yes? mso-no-proof: new?; courier&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #a31515; FONT-FAMILY: " yes? mso-no-proof: new?; courier&gt;configSections&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: " yes? mso-no-proof: new?; courier&gt;&amp;gt; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: " yes? mso-no-proof: new?; courier&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #a31515; FONT-FAMILY: " yes? mso-no-proof: new?; courier&gt;sectionGroup&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: " yes? mso-no-proof: new?; courier&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: " yes? mso-no-proof: new?; courier&gt;name&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: " yes? mso-no-proof: new?; courier&gt;=&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: " yes? mso-no-proof: new?; courier&gt;"&lt;SPAN style="COLOR: blue"&gt;robo.webProfile&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;&amp;gt; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: " yes? mso-no-proof: new?; courier&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #a31515; FONT-FAMILY: " yes? mso-no-proof: new?; courier&gt;section&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: " yes? mso-no-proof: new?; courier&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: " yes? mso-no-proof: new?; courier&gt;name&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: " yes? mso-no-proof: new?; courier&gt;=&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: " yes? mso-no-proof: new?; courier&gt;"&lt;SPAN style="COLOR: blue"&gt;webProfileSettings&lt;/SPAN&gt;"&lt;FONT color=#0000ff&gt; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: " yes? mso-no-proof: new?; courier&gt;type&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: " yes? mso-no-proof: new?; courier&gt;=&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: " yes? mso-no-proof: new?; courier&gt;"&lt;SPAN style="COLOR: blue"&gt;WebProfileBuilder.WebProfileConfigurationSection, WebProfileBuilder, Version=1.0.0.0, Culture=neutral, PublicKeyToken=01d50f1f82943b0c&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: " yes? mso-no-proof: new?; courier&gt;allowLocation&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: " yes? mso-no-proof: new?; courier&gt;=&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: " yes? mso-no-proof: new?; courier&gt;"&lt;SPAN style="COLOR: blue"&gt;true&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: " yes? mso-no-proof: new?; courier&gt;allowDefinition&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: " yes? mso-no-proof: new?; courier&gt;=&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: " yes? mso-no-proof: new?; courier&gt;"&lt;SPAN style="COLOR: blue"&gt;Everywhere&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;/&amp;gt; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: " yes? mso-no-proof: new?; courier&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #a31515; FONT-FAMILY: " yes? mso-no-proof: new?; courier&gt;sectionGroup&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: " yes? mso-no-proof: new?; courier&gt;&amp;gt; &lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; LINE-HEIGHT: 115%; FONT-FAMILY: " yes? mso-no-proof: new?; courier&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #a31515; LINE-HEIGHT: 115%; FONT-FAMILY: " yes? mso-no-proof: new?; courier&gt;configSections&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; LINE-HEIGHT: 115%; FONT-FAMILY: " yes? mso-no-proof: new?; courier&gt;&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="COLOR: blue"&gt;&lt;FONT face=Arial color=#000000&gt;This section can be anywhere under the configuration section. &lt;BR&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: " yes? mso-no-proof: new?; courier&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #a31515; FONT-FAMILY: " yes? mso-no-proof: new?; courier&gt;robo.webProfile&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: " yes? mso-no-proof: new?; courier&gt;&amp;gt; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: " yes? mso-no-proof: new?; courier&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #a31515; FONT-FAMILY: " yes? mso-no-proof: new?; courier&gt;webProfileSettings&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: " yes? mso-no-proof: new?; courier&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: " yes? mso-no-proof: new?; courier&gt;className&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: " yes? mso-no-proof: new?; courier&gt;=&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: " yes? mso-no-proof: new?; courier&gt;"&lt;SPAN style="COLOR: blue"&gt;MyWebProfile&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: " yes? mso-no-proof: new?; courier&gt;&lt;SPAN style="COLOR: red"&gt;nameSpace&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;CustomNameSpace&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;&amp;nbsp; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: " yes? mso-no-proof: new?; courier&gt;&lt;SPAN style="COLOR: red"&gt;directory&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;CodeFiles&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;fileName&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;MyWebProfile&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; /&amp;gt; &lt;BR&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; LINE-HEIGHT: 115%; FONT-FAMILY: " yes? mso-no-proof: new?; courier&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #a31515; LINE-HEIGHT: 115%; FONT-FAMILY: " yes? mso-no-proof: new?; courier&gt;robo.webProfile&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; LINE-HEIGHT: 115%; FONT-FAMILY: " yes? mso-no-proof: new?; courier&gt;&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="COLOR: blue"&gt;&lt;FONT face=Arial color=#000000&gt;The directory name is not a virtual directory, but is in reference to the root of the Web Application. &lt;BR&gt;The fileName is just the name of the file and should not include an extension. &lt;BR&gt;The className and nameSpace are as you would expect. &lt;BR&gt;None of these settings are required.&amp;nbsp; You don't even need to define this section at all.&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="COLOR: blue"&gt;&lt;FONT face=Arial color=#000000&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="COLOR: blue"&gt;&lt;FONT face=Arial color=#000000&gt;If you would like to use Web Profile Builder, it can be downloaded &lt;A href="http://code.msdn.microsoft.com/WebProfileBuilder" mce_href="http://code.msdn.microsoft.com/WebProfileBuilder"&gt;here&lt;/A&gt;. &lt;BR&gt;Also available is the complete source code and examples in VB and C#.&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="COLOR: blue"&gt;&lt;FONT face=Arial color=#000000&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="COLOR: blue"&gt;&lt;FONT face=Arial color=#000000&gt;Thanks &lt;BR&gt;-Joe&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=5699163" width="1" height="1"&gt;</content><author><name>robolize</name><uri>http://weblogs.asp.net/members/robolize.aspx</uri></author><category term="ASP.NET" scheme="http://weblogs.asp.net/joewrobel/archive/tags/ASP.NET/default.aspx" /><category term="Profile" scheme="http://weblogs.asp.net/joewrobel/archive/tags/Profile/default.aspx" /><category term="WAP" scheme="http://weblogs.asp.net/joewrobel/archive/tags/WAP/default.aspx" /><category term="Web Application Project" scheme="http://weblogs.asp.net/joewrobel/archive/tags/Web+Application+Project/default.aspx" /></entry><entry><title>A more elegant solution to display GridView header and footer when the data source is empty.</title><link rel="alternate" type="text/html" href="http://weblogs.asp.net/joewrobel/archive/2008/01/30/a-more-elegant-solution-to-display-gridview-header-and-footer-when-the-data-source-is-empty.aspx" /><id>http://weblogs.asp.net/joewrobel/archive/2008/01/30/a-more-elegant-solution-to-display-gridview-header-and-footer-when-the-data-source-is-empty.aspx</id><published>2008-01-31T00:47:00Z</published><updated>2008-01-31T00:47:00Z</updated><content type="html">&lt;P&gt;I think the need to always show the header and footer of a GridView is pretty common. &lt;BR&gt;When I first ran into this problem, I went to Google and found lots of content about this. &lt;BR&gt;Some suggest tampering with the data source to add an extra row if it’s empty.&amp;nbsp; &lt;BR&gt;Others show overriding the CreateChildControls method.&lt;/P&gt;
&lt;P&gt;I was not satisfied with either of these solutions. I didn’t like that dirty feeling I had by tampering &lt;BR&gt;with the data source.&amp;nbsp; And I didn’t like overriding the CreateChildControls method because it &lt;BR&gt;simply didn’t work of me anyway.&amp;nbsp; This solution only gave the appearance of the header and &lt;BR&gt;footer existing.&amp;nbsp; I ran into issues because I was programmatically adding controls to the header.&amp;nbsp; &lt;BR&gt;Upon postback, if the data source was empty, the control hierarchy would not be the same as &lt;BR&gt;before thus causing an error.&lt;/P&gt;
&lt;P&gt;So here is my solution.&amp;nbsp; I'll cover the main points of interest and if you want to see more, I have &lt;BR&gt;uploaded all the source and example to the new MSDN Code Gallery. &lt;BR&gt;&lt;A title=http://code.msdn.microsoft.com/AlwaysShowHeaderFoot href="http://code.msdn.microsoft.com/AlwaysShowHeaderFoot" mce_href="http://code.msdn.microsoft.com/AlwaysShowHeaderFoot"&gt;http://code.msdn.microsoft.com/AlwaysShowHeaderFoot&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Start out by extending the GridView control and add the following structure.&amp;nbsp; &lt;BR&gt;The most important part here is to override the PerformDataBinding method. &lt;BR&gt;&amp;nbsp;&lt;A href="http://weblogs.asp.net/blogs/joewrobel/WindowsLiveWriter/AmoreelegantsolutiontodisplayGridViewhe_E5CF/ClassStructure_2.png" mce_href="http://weblogs.asp.net/blogs/joewrobel/WindowsLiveWriter/AmoreelegantsolutiontodisplayGridViewhe_E5CF/ClassStructure_2.png"&gt;&lt;IMG style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=458 alt=ClassStructure src="http://weblogs.asp.net/blogs/joewrobel/WindowsLiveWriter/AmoreelegantsolutiontodisplayGridViewhe_E5CF/ClassStructure_thumb.png" width=677 border=0 mce_src="http://weblogs.asp.net/blogs/joewrobel/WindowsLiveWriter/AmoreelegantsolutiontodisplayGridViewhe_E5CF/ClassStructure_thumb.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;As you can see here.&amp;nbsp; I am intercepting the data and making sure there is at lease one row.&amp;nbsp; &lt;BR&gt;If there is, the control behaves normally. &lt;BR&gt;On the line with the red arrow, I am checking if the binding source is a DataView.&amp;nbsp; &lt;BR&gt;If it is, I can just add a row here and be done with it. &lt;BR&gt;If the binding source is not a DataView (or DataSet), then I fire an event that will need to be handled. &lt;BR&gt;&amp;nbsp;&lt;A href="http://weblogs.asp.net/blogs/joewrobel/WindowsLiveWriter/AmoreelegantsolutiontodisplayGridViewhe_E5CF/image_14.png" mce_href="http://weblogs.asp.net/blogs/joewrobel/WindowsLiveWriter/AmoreelegantsolutiontodisplayGridViewhe_E5CF/image_14.png"&gt;&lt;IMG style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=678 alt=image src="http://weblogs.asp.net/blogs/joewrobel/WindowsLiveWriter/AmoreelegantsolutiontodisplayGridViewhe_E5CF/image_thumb_6.png" width=720 border=0 mce_src="http://weblogs.asp.net/blogs/joewrobel/WindowsLiveWriter/AmoreelegantsolutiontodisplayGridViewhe_E5CF/image_thumb_6.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;The event "MustAddARow", as seen here, will provide access to the binding data and allow you to add a row. &lt;BR&gt;&amp;nbsp;&lt;A href="http://weblogs.asp.net/blogs/joewrobel/WindowsLiveWriter/AmoreelegantsolutiontodisplayGridViewhe_E5CF/image_16.png" mce_href="http://weblogs.asp.net/blogs/joewrobel/WindowsLiveWriter/AmoreelegantsolutiontodisplayGridViewhe_E5CF/image_16.png"&gt;&lt;IMG style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=195 alt=image src="http://weblogs.asp.net/blogs/joewrobel/WindowsLiveWriter/AmoreelegantsolutiontodisplayGridViewhe_E5CF/image_thumb_7.png" width=730 border=0 mce_src="http://weblogs.asp.net/blogs/joewrobel/WindowsLiveWriter/AmoreelegantsolutiontodisplayGridViewhe_E5CF/image_thumb_7.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;Here is a snippet from a page where I handle the MustAddARow event. &lt;BR&gt;In this case, I am binding a List of Products to the GridView. &lt;BR&gt;As you can see, I'm just adding a new Product to the list.&amp;nbsp; It doesn't matter what data you add here &lt;BR&gt;because it will get hidden in back in the GridView. &lt;BR&gt;&lt;A href="http://weblogs.asp.net/blogs/joewrobel/WindowsLiveWriter/AmoreelegantsolutiontodisplayGridViewhe_E5CF/image_10.png" mce_href="http://weblogs.asp.net/blogs/joewrobel/WindowsLiveWriter/AmoreelegantsolutiontodisplayGridViewhe_E5CF/image_10.png"&gt;&lt;IMG style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=165 alt=image src="http://weblogs.asp.net/blogs/joewrobel/WindowsLiveWriter/AmoreelegantsolutiontodisplayGridViewhe_E5CF/image_thumb_4.png" width=600 border=0 mce_src="http://weblogs.asp.net/blogs/joewrobel/WindowsLiveWriter/AmoreelegantsolutiontodisplayGridViewhe_E5CF/image_thumb_4.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;And finally back in the GridView, I override the OnDataBound method so I can hide that extra row. &lt;BR&gt;&lt;A href="http://weblogs.asp.net/blogs/joewrobel/WindowsLiveWriter/AmoreelegantsolutiontodisplayGridViewhe_E5CF/image_18.png" mce_href="http://weblogs.asp.net/blogs/joewrobel/WindowsLiveWriter/AmoreelegantsolutiontodisplayGridViewhe_E5CF/image_18.png"&gt;&lt;IMG style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=276 alt=image src="http://weblogs.asp.net/blogs/joewrobel/WindowsLiveWriter/AmoreelegantsolutiontodisplayGridViewhe_E5CF/image_thumb_8.png" width=658 border=0 mce_src="http://weblogs.asp.net/blogs/joewrobel/WindowsLiveWriter/AmoreelegantsolutiontodisplayGridViewhe_E5CF/image_thumb_8.png"&gt;&lt;/A&gt;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;So there you have it.&amp;nbsp; This is my first blog post ever.&amp;nbsp;&lt;BR&gt;Hopefully someone will get some use out of this. &lt;/P&gt;
&lt;P&gt;Thanks &lt;BR&gt;-Joe&lt;/P&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=5678649" width="1" height="1"&gt;</content><author><name>robolize</name><uri>http://weblogs.asp.net/members/robolize.aspx</uri></author><category term="GridView" scheme="http://weblogs.asp.net/joewrobel/archive/tags/GridView/default.aspx" /><category term="ASP.NET" scheme="http://weblogs.asp.net/joewrobel/archive/tags/ASP.NET/default.aspx" /><category term="C#" scheme="http://weblogs.asp.net/joewrobel/archive/tags/C_2300_/default.aspx" /></entry></feed>