<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-3640193678274960191</id><updated>2011-10-08T15:04:38.325+13:00</updated><category term='asp.net'/><category term='interop'/><category term='checkbox'/><category term='Resolving errors'/><category term='Add-ins'/><category term='databinding'/><title type='text'>Mostly .NET</title><subtitle type='html'>Jottings about what I'm learning in programming and system development using Microsoft Visual Studio .NET (mostly VB.NET and ASP.NET)</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://trevsdev.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3640193678274960191/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://trevsdev.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>TrevDev</name><uri>http://www.blogger.com/profile/07875646655407335207</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://1.bp.blogspot.com/-eSkrPjS7Zxc/TaURWPp1QzI/AAAAAAAAABM/5KMM3WiyG5A/s220/Trevor.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>7</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-3640193678274960191.post-2017983578691094429</id><published>2011-10-08T14:57:00.002+13:00</published><updated>2011-10-08T15:04:38.377+13:00</updated><title type='text'>Completely off-topic: Confronting the Malefactors</title><content type='html'>&lt;div&gt;A friend on Facebook drew attention to an article by Paul Krugman, "Confronting the Malefactors" (http://www.nytimes.com/2011/10/07/opinion/krugman-confronting-the-malefactors.html?scp=3&amp;amp;sq=krugman&amp;amp;st=cse). I decided that the comment I wanted to make was too long for Facebook, so I would post my thoughts on my own blog, instead.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;It's a good article whose sentiment I support in its essence, but Krugman misses an important point when he seeks to identify the malefactors. What he should have said and didn't is, "We have seen the malefactor, and he is us."&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The politico-economic spectrum comprises capitalists, socialists and centrists. From that spectrum, we have to choose whom to support and vote for. Conservative Christians are sensitive to the right to private property as implied by the 8th commandment, "Thou shall not steal," and so many vote on the right. Other Christians have thrown in their lot with the left, correctly motivated by compassion for the down-trodden but naive in their belief that socialism can provide an economically-sustainable solution to the problem. And the centrists try to provide room for the capitalists to keep the economy working while throwing sufficient sops to the masses to stave off the revolution.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;What all these options miss is the genius of sin to subvert any of them. If Christians vote simplistically on the right in this day and age, they are not supporting the godly kind of capitalism called for by Biblical ethics. The people who had the 10 Commandments proclaimed to them also heard this,  “Is not this the kind of fasting I have chosen: to loose the chains of injustice and untie the cords of the yoke, to set the oppressed free and break every yoke? Is it not to share your food with the hungry and to provide the poor wanderer with shelter— when you see the naked, to clothe them, and not to turn away from your own flesh and blood?" (Isaiah 58:6,7). Adam Smith thought that the invisible hand of the market alone would keep capitalism just, but it is not true. We all need to be confronted repeatedly with God's ethical demands or we will pervert capitalism into oppression.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Krugman is in step with the Bible when he repeats Theodore Roosevelt's condemnation of the "malefactors of great wealth," but he is naive and - like every sinner - self-serving when he thinks that mere policy changes will turn the tide. He is right when he lists the excesses of greed that have so angered the Wall Street protesters, but he does not take into account that the protesters will want a solution that requires others to repent of their sins but not they of their own. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I began my working career at a time when trades unions had enormous power in the New Zealand workplace, and I saw at first hard the featherbedding, waste and inefficiency that therefore resulted. The "people" when in a place of power had no less a tendency to corruption than the wealthy. Human sin subverted the aims of socialism; "Animal Farm" is trenchantly true.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The government at that time was nominally right-wing but actually centrist and its ineffectual policies meant that by 1984 New Zealand's rate of inflation was 18%. To everyone's surprise, the Labour government that won the 1984 election gave New Zealand one of the freest, most deregulated economies in the world and curbed the power of the unions. All New Zealanders did indeed benefit from the immediate reduction in the inflation rate, and the "trickle down" theory promised that much of the newly unshackled wealth would ultimately find its way into the pockets of all. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Hurrah, I thought, only to see many at the top levels of business behaving in an economically destructive way. Murky schemes and complex patterns of company inter-ownership replaced actual productivity with a trade in illusions, and there was a transfer of wealth upwards as middle-income New Zealanders put money into companies that within a year or two failed. Human sin had subverted the potential of capitalism.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;There are two kinds of capitalism - secular, Darwinian capitalism and Biblical capitalism. A Christian therefore has a problem at the ballot box. A vote for socialism is a vote against the 8th Commandment, but a vote for a right-wing party in our secular society is  de facto a vote in support of the oppressive Darwinian version of capitalism, a state of affairs equally displeasing to God.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Faced with that kind of dilemma, many Christians choose to opt out altogether from the political process. I don't believe that is the right decision. Instead, the decision has to be, which of the two systems will give me the greatest freedom to preach Jesus Christ and therefore bring his ethical suasion to bear on the economic decisions made by those around us?&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;And, if throwing your lot in with a political party (not merely choosing one to vote for on election day), ask which party might embrace a set of policies that honour the 8th Commandment and also encourage social concern and a flood-down rather than trickle-down  theory of wealth transfer; a party where the "malefactors of great wealth" are seen as pariahs instead of patrons. Can't find one? -  perhaps start one!&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3640193678274960191-2017983578691094429?l=trevsdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://trevsdev.blogspot.com/feeds/2017983578691094429/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3640193678274960191&amp;postID=2017983578691094429' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3640193678274960191/posts/default/2017983578691094429'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3640193678274960191/posts/default/2017983578691094429'/><link rel='alternate' type='text/html' href='http://trevsdev.blogspot.com/2011/10/completely-off-topic-confronting.html' title='Completely off-topic: Confronting the Malefactors'/><author><name>TrevDev</name><uri>http://www.blogger.com/profile/07875646655407335207</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://1.bp.blogspot.com/-eSkrPjS7Zxc/TaURWPp1QzI/AAAAAAAAABM/5KMM3WiyG5A/s220/Trevor.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3640193678274960191.post-8164195244348150976</id><published>2010-04-19T16:42:00.003+12:00</published><updated>2010-04-19T16:51:48.010+12:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Add-ins'/><title type='text'>Configuring SmartPaster VS Addin for All Users</title><content type='html'>&lt;span style="font-family: trebuchet ms;"&gt;Here is a re-post of a comment I just added to page &lt;/span&gt;&lt;br /&gt;&lt;a href="http://weblogs.asp.net/alex_papadimoulis/archive/2004/05/25/Smart-Paster-1.1-Add-In---StringBuilder-and-Better-C_2300_-Handling.aspx"&gt;&lt;span style="font-family: trebuchet ms;"&gt;http://weblogs.asp.net/alex_papadimoulis/archive/2004/05/25/Smart-Paster-1.1-Add-In---StringBuilder-and-Better-C_2300_-Handling.aspx&lt;/span&gt;&lt;/a&gt; &lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: trebuchet ms;"&gt;I needed to get Smart Paster 2005 configured for All Users on a PC running Windows 7. Here are the instructions for the steps I took:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: trebuchet ms;"&gt;1) Unzip the &lt;span style="color: rgb(0, 0, 153);"&gt;SmartPaster2005&lt;/span&gt; download&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: trebuchet ms;"&gt;2) Copy the &lt;span style="color: rgb(0, 0, 153);"&gt;SmartPaster2005.dll&lt;/span&gt; &amp;amp; &lt;span style="color: rgb(0, 0, 153);"&gt;.xml&lt;/span&gt; files from the&lt;span style="color: rgb(0, 0, 153);"&gt; SmartPaster2005\bin&lt;/span&gt; folder to a suitable (e.g., &lt;span style="color: rgb(0, 102, 0);"&gt;C:\Program Files\SmartPaster2005&lt;/span&gt;).&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: trebuchet ms;"&gt;3) Edit the &lt;assembly&gt; data in the &lt;span style="color: rgb(0, 0, 153);"&gt;SmartPaster2005.addin&lt;/span&gt; file (in the top level folder of the unzipped SmartPaster2005 project) so that it includes the folder path you used at step (2).&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: trebuchet ms;"&gt;4) Copy the edited .addin file to folder &lt;span style="color: rgb(153, 51, 0);"&gt;%VSCOMMONAPPDATA%\AddIns&lt;/span&gt;.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: trebuchet ms;"&gt;In Windows 7, if Visual Studio 2005 has been installed in the standard location, this folder is &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: trebuchet ms;"&gt;"&lt;span style="color: rgb(102, 0, 0);"&gt;C:\ProgramData\Microsoft\VisualStudio\8.0\Addins&lt;/span&gt;" (9.0 for VS 2008, 10.0 for VS 2010)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: trebuchet ms;"&gt;[If you wanted to install the addin for just a single user, you would put the .addin file into &lt;span style="color: rgb(0, 0, 153);"&gt;%APPDATA%\Microsoft\MSEnvShared\AddIns&lt;/span&gt; instead]&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: trebuchet ms;"&gt;Visual Studio should find the addin next time it starts. To check, go to &lt;span style="color: rgb(0, 0, 153);"&gt;Tools &gt; Add-in Manager&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: trebuchet ms;"&gt;Thanks to Carlos J. Quintero for his useful page on default.addin file locations (http://www.mztools.com/articles/2008/MZ2008001.aspx)&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3640193678274960191-8164195244348150976?l=trevsdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://trevsdev.blogspot.com/feeds/8164195244348150976/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3640193678274960191&amp;postID=8164195244348150976' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3640193678274960191/posts/default/8164195244348150976'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3640193678274960191/posts/default/8164195244348150976'/><link rel='alternate' type='text/html' href='http://trevsdev.blogspot.com/2010/04/configuring-smartpaster-vs-addin-for.html' title='Configuring SmartPaster VS Addin for All Users'/><author><name>TrevDev</name><uri>http://www.blogger.com/profile/07875646655407335207</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://1.bp.blogspot.com/-eSkrPjS7Zxc/TaURWPp1QzI/AAAAAAAAABM/5KMM3WiyG5A/s220/Trevor.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3640193678274960191.post-6055477103414517615</id><published>2008-03-18T15:20:00.004+13:00</published><updated>2008-03-18T15:36:12.478+13:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='interop'/><title type='text'>Driving Microsoft Office from VS.NET</title><content type='html'>&lt;p class="MsoNormal"&gt;&lt;b style=""&gt;&lt;span style="line-height: 115%;font-size:12;" &gt;In theory…&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;To read the rather disjointed documentation that MS publishes, you’d think that all you needed to do is:&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 14.2pt; text-indent: -14.2pt;"&gt;1) Download the Primary Interop assembly installer appropriate to your version of Office. - e.g., O2003PIA.EXE from &lt;a href="http://www.microsoft.com/downloads/details.aspx?familyid=3c9a983a-ac14-4125-8ba0-d36d67e0f4ad&amp;amp;displaylang=en"&gt;http://www.microsoft.com/downloads/details.aspx?familyid=3c9a983a-ac14-4125-8ba0-d36d67e0f4ad&amp;amp;displaylang=en&lt;/a&gt;)&lt;/p&gt;  &lt;p class="MsoNormal"&gt;2) Install the download&lt;/p&gt;  &lt;p class="MsoNormal"&gt;3) Start VS and, in your project, go to Add Reference, COM tab and set a reference to the particular Office application you need to interface with – e.g., Microsoft Word 11.0 Object Library&lt;/p&gt;  &lt;p class="MsoNormal"&gt;4) At the beginning of the code file for your class, insert a corresponding “Imports” statement – e.g.,&lt;br /&gt;Imports Microsoft.office.Interop.Word&lt;/p&gt;  &lt;p class="MsoNormal"&gt;5) … and program happily ever after.&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b style=""&gt;&lt;span style="line-height: 115%;font-size:12;" &gt;‘T’aint necessarily so!&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;If you do steps 1-3, but step 4 results in a green squiggle under Microsoft.office.Interop.Word, you might have run into the problem – or something very like it - described on page &lt;a href="http://support.microsoft.com/kb/823996"&gt;http://support.microsoft.com/kb/823996&lt;/a&gt;, though the symptom described at the top of that page is probably not at all what you would notice first (“…you notice that Visual Studio .NET 2003 creates an Interop Assembly (IA) for the library instead of referencing the Primary Interop Assembly (PIA).” Yeah, right; this symptom just leaps to the eye!) &lt;/p&gt;  &lt;p class="MsoNormal"&gt;To check if you indeed have this problem, right-click and open &lt;b style=""&gt;My Project&lt;/b&gt; in Solution Explorer for your project, click the References tab (at the left hand side of the window) and widen the Path column so you can see the full paths associated with each reference.&lt;/p&gt;  &lt;p class="MsoNormal"&gt;If the Microsoft Office references are correct, they will have paths that begin&lt;br /&gt;C:\Windows\assembly\GAC\&lt;/p&gt;  &lt;p class="MsoNormal"&gt;If the references are not correct, the paths will point to a location within the project’ own folder structure – e.g., to a sub-folder of %My Documents%\Visual Studio 2005\Projects\.&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;If the referenced path is wrong, close VS and do the resolution step as described at &lt;a href="http://support.microsoft.com/kb/823996"&gt;http://support.microsoft.com/kb/823996&lt;/a&gt; - “To resolve this problem, Microsoft recommends that you run Office Setup from &lt;b&gt;Add or Remove Programs&lt;/b&gt; in Control Panel:&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;•If the PIA does not appear in the GAC, run Office Setup and then mark the PIA for the application as &lt;strong&gt;&lt;span style=""&gt;Run from My Computer&lt;/span&gt;&lt;/strong&gt;. Each Office PIA appears as a &lt;strong&gt;&lt;span style=""&gt;.NET Programmability Support&lt;/span&gt;&lt;/strong&gt; feature for the corresponding Office application or for the corresponding Office component.&lt;/p&gt;  &lt;p class="MsoNormal"&gt;•If the PIA does appear in the GAC, run Office Setup and then select the option to repair your Office installation.”&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;That is, for each Office application, click the drop-down list beside &lt;strong&gt;&lt;span style=""&gt;.NET Programmability Support&lt;/span&gt;&lt;/strong&gt;&lt;span style=""&gt; and set it to “Run from My Computer”. (The picture here shows that option selected for Word).&lt;/span&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp2.blogger.com/_4qcHslt6GoI/R98oUesAdBI/AAAAAAAAAAw/NuQiD69ImsI/s1600-h/Enabling+PIAs+via+Office+Setup.JPG"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer;" src="http://bp2.blogger.com/_4qcHslt6GoI/R98oUesAdBI/AAAAAAAAAAw/NuQiD69ImsI/s320/Enabling+PIAs+via+Office+Setup.JPG" alt="Enabling PIAs via Office Setup" id="BLOGGER_PHOTO_ID_5178902428799497234" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin: 12pt 0cm 0.0001pt;"&gt;After that, there are another couple of steps that the Microsoft KB article does not cover, but which I was alerted to be a post at &lt;a href="http://www.vbforums.com/showthread.php?t=510713"&gt;http://www.vbforums.com/showthread.php?t=510713&lt;/a&gt;. (Thanks, &lt;a href="http://www.vbforums.com/member.php?u=68359"&gt;masfenix&lt;/a&gt;)&lt;/p&gt;  &lt;p class="MsoListParagraphCxSpFirst" style="margin-bottom: 0.0001pt; text-indent: -18pt;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-family:Symbol;"&gt;&lt;span style=""&gt;·&lt;span style=""&gt;         &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;Reopen your project and go to My project &gt; References&lt;/p&gt;  &lt;p class="MsoListParagraphCxSpMiddle" style="margin-bottom: 0.0001pt; text-indent: -18pt;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-family:Symbol;"&gt;&lt;span style=""&gt;·&lt;span style=""&gt;         &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;Remove the incorrect references and save the project.&lt;/p&gt;  &lt;p class="MsoListParagraphCxSpMiddle" style="margin-bottom: 0.0001pt; text-indent: -18pt;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-family:Symbol;"&gt;&lt;span style=""&gt;·&lt;span style=""&gt;         &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;Add once more a reference to the Office application you need to work with –&lt;br /&gt;e.g., Microsoft Word 11.0 Object Library&lt;/p&gt;  &lt;p class="MsoListParagraphCxSpMiddle" style="margin-bottom: 0.0001pt; text-indent: -18pt;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-family:Symbol;"&gt;&lt;span style=""&gt;·&lt;span style=""&gt;         &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;Note that a corresponding reference to (e.g.) the Microsoft Object 11.0 Object Library has also been automatically added, along with a reference to the Visual Basic for Applications Extensibility Library.&lt;/p&gt;  &lt;p class="MsoListParagraphCxSpLast" style="margin-bottom: 0.0001pt; text-indent: -18pt;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-family:Symbol;"&gt;&lt;span style=""&gt;·&lt;span style=""&gt;         &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;Confirm that the paths now point to locations in C:\Windows\assembly\GAC\&lt;br /&gt;(if they don’t, you will have to Google further – sorry!).&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3640193678274960191-6055477103414517615?l=trevsdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://trevsdev.blogspot.com/feeds/6055477103414517615/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3640193678274960191&amp;postID=6055477103414517615' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3640193678274960191/posts/default/6055477103414517615'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3640193678274960191/posts/default/6055477103414517615'/><link rel='alternate' type='text/html' href='http://trevsdev.blogspot.com/2008/03/driving-microsoft-office-from-vsnet.html' title='Driving Microsoft Office from VS.NET'/><author><name>TrevDev</name><uri>http://www.blogger.com/profile/07875646655407335207</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://1.bp.blogspot.com/-eSkrPjS7Zxc/TaURWPp1QzI/AAAAAAAAABM/5KMM3WiyG5A/s220/Trevor.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://bp2.blogger.com/_4qcHslt6GoI/R98oUesAdBI/AAAAAAAAAAw/NuQiD69ImsI/s72-c/Enabling+PIAs+via+Office+Setup.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3640193678274960191.post-3333700938621611148</id><published>2008-03-12T13:29:00.007+13:00</published><updated>2008-03-12T14:29:02.008+13:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='checkbox'/><category scheme='http://www.blogger.com/atom/ns#' term='asp.net'/><category scheme='http://www.blogger.com/atom/ns#' term='databinding'/><title type='text'>Binding an asp:checkbox  to a Boolean but Nulls-permitted Field</title><content type='html'>I needed to bind a check box to a database field whose data type is boolean (bit), but nulls are also permitted.&lt;br /&gt;&lt;br /&gt;If nulls were not permitted, the control could be declared like this:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);font-family:courier new;" &gt;&lt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color: rgb(153, 51, 0);"&gt;asp&lt;/span&gt;:&lt;span style="color: rgb(153, 51, 0);"&gt;CheckBox &lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;ID&lt;/span&gt;="CheckBox1" &lt;span style="color: rgb(255, 0, 0);"&gt;runat&lt;/span&gt;="Server" &lt;span style="color: rgb(255, 0, 0);"&gt;&lt;br /&gt;Checked&lt;/span&gt;=&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;'&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);font-family:courier new;" &gt;&lt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;%# Eval("MyBooleanField") %&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);font-family:courier new;" &gt;&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;'&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);font-family:courier new;" &gt;/&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;However, the Eval throws an error when the supposedly Boolean field contains a null value. Therefore, I adapted an idea from Jason Kester that I found at&lt;br /&gt;&lt;a href="http://www.velocityreviews.com/forums/t93739-checkbox-databind-does-not-work.html"&gt;http://www.velocityreviews.com/forums/t93739-checkbox-databind-does-not-work.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The binding container from which the checkbox gets its data is a FormView control, so I created the following function in the page's code-behind:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;Public Function &lt;/span&gt;fbool(&lt;span style="color: rgb(51, 51, 255);"&gt;ByVal&lt;/span&gt; o &lt;span style="color: rgb(51, 51, 255);"&gt;As Object&lt;/span&gt;, _&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    &lt;span style="color: rgb(51, 51, 255);"&gt;        ByVal &lt;/span&gt;ColName &lt;span style="color: rgb(51, 51, 255);"&gt;As String&lt;/span&gt;) &lt;span style="color: rgb(51, 51, 255);"&gt;As Boolean&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    &lt;span style="color: rgb(51, 51, 255);"&gt;    Try&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;        &lt;span style="color: rgb(51, 51, 255);"&gt;        Dim &lt;/span&gt;fv &lt;span style="color: rgb(51, 51, 255);"&gt;As FormView&lt;/span&gt; = _&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;            &lt;span style="color: rgb(51, 51, 255);"&gt;        CType&lt;/span&gt;(o, FormView)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;        &lt;span style="color: rgb(51, 51, 255);"&gt;        With &lt;/span&gt;fv&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;            &lt;span style="color: rgb(51, 51, 255);"&gt;            Dim &lt;/span&gt;di &lt;span style="color: rgb(51, 51, 255);"&gt;As &lt;span style="color: rgb(0, 0, 0);"&gt;System.Data.DataRowView&lt;/span&gt;&lt;/span&gt; = _&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;            &lt;span style="color: rgb(51, 51, 255);"&gt;            CType&lt;/span&gt;(.DataItem, System.Data.DataRowView)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;            &lt;span style="color: rgb(51, 51, 255);"&gt;            Return &lt;/span&gt;CBool(di.Item(ColName))&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;        &lt;span style="color: rgb(51, 51, 255);"&gt;        End With&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    &lt;span style="color: rgb(51, 51, 255);"&gt;Catch &lt;/span&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;' to catch the null data case&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;        &lt;span style="color: rgb(51, 51, 255);"&gt;        Return False&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);font-family:courier new;" &gt;    End Try&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);font-family:courier new;" &gt;End Function&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The checkbox declaration now looks like this:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);font-family:courier new;" &gt;&lt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color: rgb(153, 51, 0);"&gt;asp&lt;/span&gt;:&lt;span style="color: rgb(153, 51, 0);"&gt;CheckBox &lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;ID&lt;/span&gt;="CheckBox1" &lt;span style="color: rgb(255, 0, 0);"&gt;runat&lt;/span&gt;="Server" &lt;span style="color: rgb(255, 0, 0);"&gt;&lt;br /&gt;Checked&lt;/span&gt;=&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;  '&lt;%# fbool(BindingContainer, "MyBooleanField") %&gt;' &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);font-family:courier new;" &gt; /&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;So far, no problems - handles nulls ok. I'll update the post if any gotcha's arise.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3640193678274960191-3333700938621611148?l=trevsdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://trevsdev.blogspot.com/feeds/3333700938621611148/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3640193678274960191&amp;postID=3333700938621611148' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3640193678274960191/posts/default/3333700938621611148'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3640193678274960191/posts/default/3333700938621611148'/><link rel='alternate' type='text/html' href='http://trevsdev.blogspot.com/2008/03/binding-aspcheckbox-to-boolean-but.html' title='Binding an asp:checkbox  to a Boolean but Nulls-permitted Field'/><author><name>TrevDev</name><uri>http://www.blogger.com/profile/07875646655407335207</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://1.bp.blogspot.com/-eSkrPjS7Zxc/TaURWPp1QzI/AAAAAAAAABM/5KMM3WiyG5A/s220/Trevor.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3640193678274960191.post-3201456822262838207</id><published>2008-03-12T12:38:00.006+13:00</published><updated>2008-03-12T13:12:43.707+13:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Resolving errors'/><title type='text'>The Single Most Important Thing for ASP.NET Developers to Know</title><content type='html'>&lt;span style="font-family:trebuchet ms;"&gt;Imho, it is this:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;"&gt;"Close Visual Studio and delete all contents of C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files"&lt;br /&gt;&lt;br /&gt;Do this whenever you see error message BC30456 ("'&lt;span style="font-style: italic;"&gt;some_object_name&lt;/span&gt;' is not a member of..."), or error BC30554 ("'&lt;/span&gt;&lt;span style="font-family:trebuchet ms;"&gt;&lt;span style="font-style: italic;"&gt;some_object_name&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:trebuchet ms;"&gt;' is ambiguous"), or a compilation error message about a missing resource.&lt;br /&gt;&lt;br /&gt;Restart Visual Studio.&lt;br /&gt;&lt;br /&gt;8 times out of 10 the problem has gone away. The other two times, it genuinely is your fault - e.g., you have got two code-behind classes that have the same name.&lt;br /&gt;&lt;br /&gt;I have a VB script file on my desktop to automate deleting the temporary folder:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;Option &lt;/span&gt;explicit&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:trebuchet ms;"&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;Const &lt;/span&gt;sFolderName = _&lt;br /&gt;"&lt;/span&gt;&lt;span style="font-style: italic;font-family:courier new;" &gt;[your website's name]&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;" &lt;span style="color: rgb(0, 102, 0);"&gt;' &lt;==== ### Customize this ####&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:trebuchet ms;"&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;Const &lt;/span&gt;sFolderPath = _&lt;br /&gt;"C:\WINDOWS\Microsoft.NET\Framework\" &amp;amp; _&lt;br /&gt;"v2.0.50727\Temporary ASP.NET Files\&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;"&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;Const &lt;/span&gt;sBoxTitle = "Delete Web Site's Temporary folder from Server"&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;Dim &lt;/span&gt;sMsg &lt;span style="color: rgb(0, 102, 0);"&gt;' as string&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;Dim &lt;/span&gt;ofs &lt;span style="color: rgb(0, 102, 0);"&gt;'as  Scripting.FileSystemObject&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;Dim &lt;/span&gt;fol &lt;span style="color: rgb(0, 102, 0);"&gt;'as Scripting.folder&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;sMsg = "If the application is running, please close it." &amp;amp; _&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    vbNewLine &amp;amp; "Click OK when ready to continue."&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    &lt;span style="color: rgb(51, 51, 255);"&gt;if &lt;/span&gt;msgbox(sMsg, vbOKCancel, sBoxTitle) = vbCancel &lt;span style="color: rgb(51, 51, 255);"&gt;then &lt;/span&gt;wscript.quit&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    &lt;span style="color: rgb(0, 102, 0);"&gt;'Else&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    &lt;span style="color: rgb(51, 51, 255);"&gt;set &lt;/span&gt;ofs = CreateObject("Scripting.FileSystemObject")&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    &lt;span style="color: rgb(51, 51, 255);"&gt;set &lt;/span&gt;fol = ofs.getfolder(&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:trebuchet ms;"&gt;&lt;span style="font-family:courier new;"&gt;sFolderName &amp;amp; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:trebuchet ms;"&gt;&lt;span style="font-family:courier new;"&gt;sFolderName)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    &lt;span style="color: rgb(51, 51, 255);"&gt;on error resume next&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    fol.Delete&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    &lt;span style="color: rgb(51, 51, 255);"&gt;if &lt;/span&gt;err.number &gt; 0 &lt;span style="color: rgb(51, 51, 255);"&gt;then&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;        sMsg = "You didn't shut down the application!"&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;        msgbox sMsg, vbexclamation, sBoxTitle&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    &lt;span style="color: rgb(51, 51, 255);"&gt;end if&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    &lt;span style="color: rgb(51, 51, 255);"&gt;set&lt;/span&gt; fol = &lt;span style="color: rgb(51, 51, 255);"&gt;nothing&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    &lt;span style="color: rgb(51, 51, 255);"&gt;set &lt;/span&gt;ofs = &lt;span style="color: rgb(51, 51, 255);"&gt;nothing&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3640193678274960191-3201456822262838207?l=trevsdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://trevsdev.blogspot.com/feeds/3201456822262838207/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3640193678274960191&amp;postID=3201456822262838207' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3640193678274960191/posts/default/3201456822262838207'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3640193678274960191/posts/default/3201456822262838207'/><link rel='alternate' type='text/html' href='http://trevsdev.blogspot.com/2008/03/single-most-important-thing-for-aspnet.html' title='The Single Most Important Thing for ASP.NET Developers to Know'/><author><name>TrevDev</name><uri>http://www.blogger.com/profile/07875646655407335207</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://1.bp.blogspot.com/-eSkrPjS7Zxc/TaURWPp1QzI/AAAAAAAAABM/5KMM3WiyG5A/s220/Trevor.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3640193678274960191.post-4847366867765677286</id><published>2008-02-23T16:48:00.003+13:00</published><updated>2008-02-23T16:59:32.272+13:00</updated><title type='text'>Truly Understanding...</title><content type='html'>Before I could solve the problem described in my previous post, I had to understand why my page wasn't working as originally written. The information I found in Dave Reed's blog on the topic "&lt;a href="http://weblogs.asp.net/infinitiesloop/archive/2006/08/03/Truly-Understanding-Viewstate.aspx"&gt;Truly Understanding ViewState&lt;/a&gt;" proved vital. I can't recommend his article (and others by him) too highly.&lt;br /&gt;&lt;br /&gt;Once I understood why my page wasn't working (my FormView needed rebinding), I could then go about finding how to achieve that result, as described in the earlier post. But I couldn't even start looking for the solution until I understood the problem, and that's where Dave's article was essential.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3640193678274960191-4847366867765677286?l=trevsdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://trevsdev.blogspot.com/feeds/4847366867765677286/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3640193678274960191&amp;postID=4847366867765677286' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3640193678274960191/posts/default/4847366867765677286'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3640193678274960191/posts/default/4847366867765677286'/><link rel='alternate' type='text/html' href='http://trevsdev.blogspot.com/2008/02/truly-understanding.html' title='Truly Understanding...'/><author><name>TrevDev</name><uri>http://www.blogger.com/profile/07875646655407335207</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://1.bp.blogspot.com/-eSkrPjS7Zxc/TaURWPp1QzI/AAAAAAAAABM/5KMM3WiyG5A/s220/Trevor.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3640193678274960191.post-3250724793610281600</id><published>2008-02-23T14:33:00.004+13:00</published><updated>2008-02-23T16:45:44.650+13:00</updated><title type='text'>Using RaiseBubbleEvent to Tell a Parent ASP.NET Control to Rebind</title><content type='html'>I am developing a web page  that has a MultiView control whose Views each contain  a  FormView control.  The FormView  controls are bound to an SQLDataSource that is declared in the page (.aspx) that contains the MultiView control.  &lt;span style="font-style: italic;"&gt;Listing 1&lt;/span&gt; shows the structure of the code.&lt;br /&gt;&lt;br /&gt;I discovered that, when switching FormView mode (e.g., from the default read-only mode to Edit mode, I needed to get the SQLDataSource to rebind, so my problem was, how to make that happen? The FormView was the object that knew it was changing mode, but the SQLDataSource was an object on the parent page. How could I get them talking to each other, so to speak?&lt;br /&gt;&lt;br /&gt;My first thought was to create a rebinding method on the parent page and find a way to call that method from the FormView's ItemCommand event handler. (The ItemCommand event is triggered when  any mode-change button is clicked within the FormView). A little research showed that it wasn't feasible to directly call a method belonging to the parent, and, in any case, I should have known better.&lt;br /&gt;&lt;br /&gt;The correct strategy was (1) to raise a "BubbleEvent" that would carry the message up the hierarchy, then (2) to trap the event at the page level and rebind in response to it.&lt;br /&gt;&lt;br /&gt;In order to raise a BubbleEvent that could be recognized as carrying the "RebindNeeded" message, I had to write a new class and save it into my App_Code folder. &lt;span style="font-style: italic;"&gt;Listing 2&lt;/span&gt; shows the code. I named the class "RebindNeededEventArgs" and saved the code as "RebindNeededEventArgs.vb", but those names were arbitrary. The class could have been "Jane" and the code file "Jim.vb" and everything would have worked just the same - it just would have been harder to make sense of later.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;Listing 3&lt;/span&gt; shows how the ItemCommand event handler for one of the FormView controls creates a "RebindNeededEventArgs" object and passes it as a parameter to "RaiseBubbleEvent".&lt;br /&gt;&lt;br /&gt;The parent object may receive bubbled events for more than one reason. It is the EventArgs parameter that allows it to recognize what kind of event this is that has been bubbled to it, so it can react accordingly. &lt;span style="font-style: italic;"&gt;Listing 4&lt;/span&gt; shows the OnBubbleEvent handler for the parent page in my project. Note how ElseIfs could be inserted to handle other kinds of bubbled events, if neccessary.&lt;br /&gt;&lt;br /&gt;I hope these notes provide a useful summary of this design pattern. The particular context here is a FormView within a MultiView within a Page that also holds the FormView's datasource control, but the same pattern should apply in any situation when a child control needs to notify its parent that a rebinding is required.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Listing 1&lt;/span&gt;&lt;br /&gt;&lt;table bg border="1" cellpadding="16" style="color:#dddddd;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;&lt;pre&gt;&lt;span style="font-family:Courier New;font-size:85%;color:black;"&gt;&amp;lt;%@ Page Language="VB" MasterPageFile="~/masters/Initial.master"&lt;br /&gt;   AutoEventWireup="&lt;span style="color:blue;"&gt;false&lt;/span&gt;" CodeFile="BlogDemos.aspx.vb"&lt;br /&gt;   Inherits="pages_BlogDemos" title="Demo Code &lt;span style="color:blue;"&gt;for&lt;/span&gt; Posting to Blog" %&amp;gt;&lt;br /&gt;&amp;lt;asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"&amp;gt;&lt;br /&gt;   &amp;lt;asp:SqlDataSource ID="SqlDataSource1" runat="server"&lt;br /&gt;       ConnectionString= "[connection &lt;span style="color:blue;"&gt;string&lt;/span&gt; declared here]"&lt;br /&gt;       ProviderName="[provider declared here]"&lt;br /&gt;       SelectCommand= " "&lt;br /&gt;   /&amp;gt; &amp;lt;%-- Note: the SelectCommand &lt;span style="color:blue;"&gt;for&lt;/span&gt; the SQLDataSource gets &lt;span style="color:blue;"&gt;set&lt;/span&gt;&lt;br /&gt;           dynamically &lt;span style="color:blue;"&gt;in&lt;/span&gt; code that need not concern us here. --%&amp;gt;&lt;br /&gt;          &lt;br /&gt;   &amp;lt;asp:MultiView ID="MultiView1" runat="server" EnableViewState="True" &amp;gt;&lt;br /&gt;   &amp;lt;asp:View ID="View1" runat="server"&amp;gt;&lt;br /&gt;   &amp;lt;asp:FormView ID="FormView1" runat="server" DataSourceID="SqlDataSource1"&lt;br /&gt;       ... &amp;gt;&lt;br /&gt;  &lt;br /&gt;       &amp;lt;ItemTemplate&amp;gt;&lt;br /&gt;           &amp;lt;%-- ItemTemplate contents, + a user control&lt;br /&gt;               that adds the row of command buttons--%&amp;gt;&lt;br /&gt;       &amp;lt;/ItemTemplate&amp;gt;&lt;br /&gt;&lt;br /&gt;       &amp;lt;EditItemTemplate&amp;gt;&lt;br /&gt;           &amp;lt;%-- EdItemTemplate contents, + a user control&lt;br /&gt;               that adds the row of command buttons--%&amp;gt;&lt;br /&gt;       &amp;lt;/EditItemTemplate&amp;gt;&lt;br /&gt;      &lt;br /&gt;       &amp;lt;InsertItemTemplate&amp;gt;&lt;br /&gt;           &amp;lt;%-- InsertItemTemplate contents, + a user control&lt;br /&gt;               that adds the row of command buttons--%&amp;gt;&lt;br /&gt;   &amp;lt;/InsertItemTemplate&amp;gt;&lt;br /&gt;   &amp;lt;/asp:FormView&amp;gt;&lt;br /&gt;   &amp;lt;/asp:View&amp;gt;&lt;br /&gt;  &lt;br /&gt;   &amp;lt;asp:View ID="View2" runat="server"&amp;gt;&lt;br /&gt;   &amp;lt;asp:FormView ID="FormView2" runat="server"&lt;br /&gt;       DataSourceID="SqlDataSource1" ... &amp;gt;   &lt;br /&gt;       &amp;lt;ItemTemplate&amp;gt;...&amp;lt;/ItemTemplate&amp;gt;&lt;br /&gt;       &amp;lt;EditItemTemplate&amp;gt;...&amp;lt;/EditItemTemplate&amp;gt;       &lt;br /&gt;       &amp;lt;InsertItemTemplate&amp;gt;...&amp;lt;/InsertItemTemplate&amp;gt;&lt;br /&gt;   &amp;lt;/asp:FormView&amp;gt;&lt;br /&gt;   &amp;lt;/asp:View&amp;gt;   &lt;br /&gt;   &amp;lt;/asp:MultiView&amp;gt;   &lt;br /&gt;&amp;lt;/asp:Content&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Listing 2&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;Imports &lt;/span&gt;Microsoft.VisualBasic&lt;br /&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;' Objects of this class provided the RebindNeededEventArgs object for events &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;' bubbled from a child control within a databound control to its parent.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;' Its particular use is for when a FormView within a MultiView changes mode.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;Public Class&lt;/span&gt; RebindNeededEventArgs&lt;br /&gt;    &lt;span style="color: rgb(51, 51, 255);"&gt;Inherits&lt;/span&gt; System.EventArgs&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: rgb(51, 51, 255);"&gt;Public Sub New&lt;/span&gt;()&lt;br /&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;        ' No action needed&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: rgb(51, 51, 255);"&gt;End Sub&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;End Class&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Listing 3&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: rgb(51, 51, 255);"&gt;Protected Sub &lt;/span&gt;FormView2_ItemCommand(&lt;span style="color: rgb(51, 51, 255);"&gt;ByVal&lt;/span&gt; sender &lt;span style="color: rgb(51, 51, 255);"&gt;As Object&lt;/span&gt;, _&lt;br /&gt;            &lt;span style="color: rgb(51, 51, 255);"&gt;ByVal &lt;/span&gt;e &lt;span style="color: rgb(51, 51, 255);"&gt;As&lt;/span&gt; System.Web.UI.WebControls.FormViewCommandEventArgs) _&lt;br /&gt;        &lt;span style="color: rgb(51, 51, 255);"&gt;Handles &lt;/span&gt;FormView2.ItemCommand&lt;br /&gt;        &lt;span style="color: rgb(51, 51, 255);"&gt;Try&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;            ' Create a RebindNeededEventArgs object&lt;/span&gt;&lt;br /&gt;            &lt;span style="color: rgb(51, 51, 255);"&gt;Dim &lt;/span&gt;RebindNeededArgs &lt;span style="color: rgb(51, 51, 255);"&gt;As New &lt;/span&gt;RebindNeededEventArgs()&lt;br /&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;            ' Call RaiseBubbleEvent, passing the RebindNeededArgs object&lt;/span&gt;&lt;br /&gt;            RaiseBubbleEvent(&lt;span style="color: rgb(51, 51, 255);"&gt;Me&lt;/span&gt;, RebindNeededArgs)&lt;br /&gt;        &lt;span style="color: rgb(51, 51, 255);"&gt;Catch &lt;/span&gt;e2 &lt;span style="color: rgb(51, 51, 255);"&gt;As &lt;/span&gt;Exception&lt;br /&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;            'add error-handling code here, if appropriate&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: rgb(51, 51, 255);"&gt;End Try&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;    End Sub&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Listing 4&lt;br /&gt;    &lt;span style="color: rgb(51, 51, 255);"&gt;Protected Overrides Function&lt;/span&gt; OnBubbleEvent( _&lt;br /&gt;        &lt;span style="color: rgb(51, 51, 255);"&gt;ByVal &lt;/span&gt;source &lt;span style="color: rgb(51, 51, 255);"&gt;As &lt;/span&gt;Object, &lt;span style="color: rgb(51, 51, 255);"&gt;ByVal &lt;/span&gt;args &lt;span style="color: rgb(51, 51, 255);"&gt;As &lt;/span&gt;EventArgs) &lt;span style="color: rgb(51, 51, 255);"&gt;As Boolean&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: rgb(51, 51, 255);"&gt;If TypeOf&lt;/span&gt; args &lt;span style="color: rgb(51, 51, 255);"&gt;Is &lt;/span&gt;RebindNeededEventArgs &lt;span style="color: rgb(51, 51, 255);"&gt;Then&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(0, 153, 0);"&gt;           ' [Insert code here to implement the rebinding]&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 153, 0);"&gt; &lt;/span&gt;           &lt;span style="color: rgb(51, 51, 255);"&gt;Return True&lt;/span&gt; ' Stop the bubbling of the event&lt;br /&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;            'ElseIf TypeOf args Is [some other kind] Then&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;            '   insert appropriate code here to handle the other event&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: rgb(51, 51, 255);"&gt;Else&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;            Return MyBase&lt;/span&gt;.OnBubbleEvent(source, args)&lt;br /&gt;        &lt;span style="color: rgb(51, 51, 255);"&gt;End If&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;    End Function&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3640193678274960191-3250724793610281600?l=trevsdev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://trevsdev.blogspot.com/feeds/3250724793610281600/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3640193678274960191&amp;postID=3250724793610281600' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3640193678274960191/posts/default/3250724793610281600'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3640193678274960191/posts/default/3250724793610281600'/><link rel='alternate' type='text/html' href='http://trevsdev.blogspot.com/2008/02/using-raisebubbleevent-to-tell-parent.html' title='Using RaiseBubbleEvent to Tell a Parent ASP.NET Control to Rebind'/><author><name>TrevDev</name><uri>http://www.blogger.com/profile/07875646655407335207</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://1.bp.blogspot.com/-eSkrPjS7Zxc/TaURWPp1QzI/AAAAAAAAABM/5KMM3WiyG5A/s220/Trevor.jpg'/></author><thr:total>1</thr:total></entry></feed>
