<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>PeterKellner.net &#187; .Net 2.0</title>
	<atom:link href="http://peterkellner.net/category/net-20/feed/" rel="self" type="application/rss+xml" />
	<link>http://peterkellner.net</link>
	<description>Microsoft Focussed, JavaScript (ExtJS, SenchaTouch &#38; Windows 8 Metro)</description>
	<lastBuildDate>Tue, 07 Feb 2012 21:14:45 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Silicon Valley Code Camp Login Failing with IE10 (Fixed Now)</title>
		<link>http://peterkellner.net/2011/09/20/silicon-valley-code-camp-login-failing-with-ie10-fixed-now/</link>
		<comments>http://peterkellner.net/2011/09/20/silicon-valley-code-camp-login-failing-with-ie10-fixed-now/#comments</comments>
		<pubDate>Tue, 20 Sep 2011 17:10:29 +0000</pubDate>
		<dc:creator>Peter Kellner</dc:creator>
				<category><![CDATA[.NET 4.0]]></category>
		<category><![CDATA[.Net 2.0]]></category>
		<category><![CDATA[ASP.NET 2.0]]></category>
		<category><![CDATA[ASP.NET 4.0]]></category>

		<guid isPermaLink="false">http://peterkellner.net/2011/09/20/silicon-valley-code-camp-login-failing-with-ie10-fixed-now/</guid>
		<description><![CDATA[&#160;  Scott Hanselman posted a while back about a browsers definition problem with some ASP.NET sites that causes problems.&#160; Microsoft has articles on this also.&#160; Having just received my BUILD tablet that includes IE10, I tested the Silicon Valley Code Camp web site and discovered that when you login, then switch to another page, [...]]]></description>
			<content:encoded><![CDATA[<p>&#160;</p>  <p><a href="http://www.hanselman.com/blog/BugAndFixASPNETFailsToDetectIE10CausingDoPostBackIsUndefinedJavaScriptErrorOrMaintainFF5ScrollbarPosition.aspx">Scott Hanselman posted</a> a while back about a browsers definition problem with some ASP.NET sites that causes problems.&#160; Microsoft has <a href="http://support.microsoft.com/kb/2600088">articles</a> on this also.&#160; Having just received my <a href="http://www.buildwindows.com/">BUILD</a> tablet that includes IE10, I tested the <a href="http://www.siliconvalley-codecamp.com/">Silicon Valley Code Camp web site</a> and discovered that when you login, then switch to another page, the login did not stick.&#160; After uploading the two files Scott mentions (<a href="http://msdn.microsoft.com/en-us/library/ms228122.aspx">firefox.browser and ie.browser</a>), the problem goes away.</p>  <p>Thanks Scott for the heads up.</p>  <p>&#160;</p>  <p><a href="http://peterkellner.net/wp/wp/wp-content/uploads/2011/09/image3.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://peterkellner.net/wp/wp/wp-content/uploads/2011/09/image_thumb2.png" width="657" height="350" /></a></p>]]></content:encoded>
			<wfw:commentRss>http://peterkellner.net/2011/09/20/silicon-valley-code-camp-login-failing-with-ie10-fixed-now/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>With ASP.NET WebForms, How to Keep / Stop a Data Control Like GridView From Retrieving Data</title>
		<link>http://peterkellner.net/2011/08/01/with-asp-net-webforms-how-to-keep-stop-a-data-control-like-gridview-from-retrieving-data/</link>
		<comments>http://peterkellner.net/2011/08/01/with-asp-net-webforms-how-to-keep-stop-a-data-control-like-gridview-from-retrieving-data/#comments</comments>
		<pubDate>Mon, 01 Aug 2011 21:35:00 +0000</pubDate>
		<dc:creator>Peter Kellner</dc:creator>
				<category><![CDATA[ASP.NET 2.0]]></category>
		<category><![CDATA[ASP.NET 3.5]]></category>
		<category><![CDATA[ASP.NET 4.0]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[ObjectDataSource]]></category>
		<category><![CDATA[WebForms]]></category>

		<guid isPermaLink="false">http://peterkellner.net/2011/08/01/with-asp-net-webforms-how-to-keep-stop-a-data-control-like-gridview-from-retrieving-data/</guid>
		<description><![CDATA[The What and Where  Something that may not be obvious is if are creating an asp.net WebForms project and you put a datasource such as SqlDataSource or ObjectDataSource for example on the page, how can you prevent the SqlSelect associated with that datasource from being triggered.  The answer is to set the control’s [...]]]></description>
			<content:encoded><![CDATA[<h2>The What and Where</h2>  <p>Something that may not be obvious is if are creating an asp.net <a href="http://msdn.microsoft.com/en-us/library/ms973868.aspx">WebForms</a> project and you put a datasource such as <a href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.sqldatasource.aspx">SqlDataSource</a> or <a href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.objectdatasource.aspx">ObjectDataSource</a> for example on the page, how can you prevent the SqlSelect associated with that datasource from being triggered.</p>  <p>The answer is to set the control’s visible property to false.&#160; That’s it!</p>  <span id="more-1529"></span>  <p>&#160;</p>  <h2>The Why</h2>  <p>The reason you might want to do this is for a case where you have a public facing web page that might be easily subjected to a denial of service attach.&#160; If that web page is always causing some SqlDataSource to fire, you could easily find your <a href="http://www.microsoft.com/sqlserver/en/us/default.aspx">SqlServer</a> overloaded.&#160; At least by checking to see a user is logged in before firing the sql statement, you buy yourself a little bit of protection.</p>  <p>&#160;</p>  <h2>The Code</h2>  <pre class="csharpcode"><span class="asp">&lt;%@ Page Language=&quot;C#&quot; %&gt;</span>

<span class="kwrd">&lt;!</span><span class="html">DOCTYPE</span> <span class="attr">html</span> <span class="attr">PUBLIC</span> <span class="kwrd">&quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot;</span> 
<span class="kwrd">&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;</span><span class="kwrd">&gt;</span>

<span class="kwrd">&lt;</span><span class="html">script</span> <span class="attr">runat</span><span class="kwrd">=&quot;server&quot;</span><span class="kwrd">&gt;</span>

    <span class="kwrd">protected</span> <span class="kwrd">void</span> 
        GridView1_SelectedIndexChanged(<span class="kwrd">object</span> sender, EventArgs e)
    {

    }

    <span class="kwrd">protected</span> <span class="kwrd">void</span> Page_Init(<span class="kwrd">object</span> sender, EventArgs e)
    {
        <span class="kwrd">if</span> (!Context.User.Identity.IsAuthenticated)
        {
            GridView1.Visible = <span class="kwrd">false</span>;
        }
    }
<span class="kwrd">&lt;/</span><span class="html">script</span><span class="kwrd">&gt;</span>

<span class="kwrd">&lt;</span><span class="html">html</span> <span class="attr">xmlns</span><span class="kwrd">=&quot;http://www.w3.org/1999/xhtml&quot;</span><span class="kwrd">&gt;</span>
<span class="kwrd">&lt;</span><span class="html">head</span> <span class="attr">runat</span><span class="kwrd">=&quot;server&quot;</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;</span><span class="html">title</span><span class="kwrd">&gt;&lt;/</span><span class="html">title</span><span class="kwrd">&gt;</span>
<span class="kwrd">&lt;/</span><span class="html">head</span><span class="kwrd">&gt;</span>
<span class="kwrd">&lt;</span><span class="html">body</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;</span><span class="html">form</span> <span class="attr">id</span><span class="kwrd">=&quot;form1&quot;</span> <span class="attr">runat</span><span class="kwrd">=&quot;server&quot;</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;</span><span class="html">div</span><span class="kwrd">&gt;</span>
        <span class="kwrd">&lt;</span><span class="html">asp:SqlDataSource</span> <span class="attr">ID</span><span class="kwrd">=&quot;SqlDataSource1&quot;</span> <span class="attr">runat</span><span class="kwrd">=&quot;server&quot;</span> 
            <span class="attr">ConnectionString</span><span class="kwrd">=&quot;&lt;%$ ConnectionStrings:CodeCampSV06 %&gt;&quot;</span> 
            <span class="attr">SelectCommand</span>=
            <span class="kwrd">&quot;SELECT [Id], [Username], [Email] FROM [Attendees] ORDER BY [Id] DESC&quot;</span><span class="kwrd">&gt;</span>
            <span class="kwrd">&lt;/</span><span class="html">asp:SqlDataSource</span><span class="kwrd">&gt;</span>
        <span class="kwrd">&lt;</span><span class="html">asp:GridView</span> <span class="attr">ID</span><span class="kwrd">=&quot;GridView1&quot;</span> <span class="attr">runat</span><span class="kwrd">=&quot;server&quot;</span> <span class="attr">AutoGenerateColumns</span><span class="kwrd">=&quot;False&quot;</span> 
            <span class="attr">DataKeyNames</span><span class="kwrd">=&quot;Id&quot;</span> <span class="attr">DataSourceID</span><span class="kwrd">=&quot;SqlDataSource1&quot;</span> 
            <span class="attr">onselectedindexchanged</span><span class="kwrd">=&quot;GridView1_SelectedIndexChanged&quot;</span><span class="kwrd">&gt;</span>
            <span class="kwrd">&lt;</span><span class="html">Columns</span><span class="kwrd">&gt;</span>
                <span class="kwrd">&lt;</span><span class="html">asp:BoundField</span> <span class="attr">DataField</span><span class="kwrd">=&quot;Id&quot;</span> <span class="attr">HeaderText</span><span class="kwrd">=&quot;Id&quot;</span> <span class="attr">InsertVisible</span><span class="kwrd">=&quot;False&quot;</span> 
                    <span class="attr">ReadOnly</span><span class="kwrd">=&quot;True&quot;</span> <span class="attr">SortExpression</span><span class="kwrd">=&quot;Id&quot;</span> <span class="kwrd">/&gt;</span>
                <span class="kwrd">&lt;</span><span class="html">asp:BoundField</span> <span class="attr">DataField</span><span class="kwrd">=&quot;Username&quot;</span> <span class="attr">HeaderText</span><span class="kwrd">=&quot;Username&quot;</span> 
                    <span class="attr">SortExpression</span><span class="kwrd">=&quot;Username&quot;</span> <span class="kwrd">/&gt;</span>
                <span class="kwrd">&lt;</span><span class="html">asp:BoundField</span> <span class="attr">DataField</span><span class="kwrd">=&quot;Email&quot;</span> <span class="attr">HeaderText</span><span class="kwrd">=&quot;Email&quot;</span> 
                <span class="attr">SortExpression</span><span class="kwrd">=&quot;Email&quot;</span> <span class="kwrd">/&gt;</span>
            <span class="kwrd">&lt;/</span><span class="html">Columns</span><span class="kwrd">&gt;</span>
        <span class="kwrd">&lt;/</span><span class="html">asp:GridView</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;/</span><span class="html">div</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;/</span><span class="html">form</span><span class="kwrd">&gt;</span>
<span class="kwrd">&lt;/</span><span class="html">body</span><span class="kwrd">&gt;</span>
<span class="kwrd">&lt;/</span><span class="html">html</span><span class="kwrd">&gt;</span></pre>
<style type="text/css">
.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; }</style>]]></content:encoded>
			<wfw:commentRss>http://peterkellner.net/2011/08/01/with-asp-net-webforms-how-to-keep-stop-a-data-control-like-gridview-from-retrieving-data/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adding a List of Recent Posts To The Silicon Valley Code Camp Home Page (From RSS Feed)</title>
		<link>http://peterkellner.net/2010/09/12/simplerssreader-in-silicon-valley-code-camp-objectdatasource-repeater-aspnet/</link>
		<comments>http://peterkellner.net/2010/09/12/simplerssreader-in-silicon-valley-code-camp-objectdatasource-repeater-aspnet/#comments</comments>
		<pubDate>Sun, 12 Sep 2010 21:44:26 +0000</pubDate>
		<dc:creator>Peter Kellner</dc:creator>
				<category><![CDATA[.NET 4.0]]></category>
		<category><![CDATA[ObjectDataSource]]></category>
		<category><![CDATA[RSS]]></category>
		<category><![CDATA[Repeater]]></category>

		<guid isPermaLink="false">http://peterkellner.net/2010/09/12/simplerssreader-in-silicon-valley-code-camp-objectdatasource-repeater-aspnet/</guid>
		<description><![CDATA[There are 10,000 ways to do this.&#160; Back way back when (ASP.NET 1.1) days, we would have created either a custom control to do this, then added a Repeater control on the page to display it.&#160; Well, the Silicon Valley Code Camp Website was started back in those days and since what I want is [...]]]></description>
			<content:encoded><![CDATA[<p>There are 10,000 ways to do this.&#160; Back way back when (<a href="http://www.asp.net/">ASP.NET</a> 1.1) days, we would have created either a custom control to do this, then added a Repeater control on the page to display it.&#160; Well, the <a href="http://siliconvalley-codecamp.com/">Silicon Valley Code Camp</a> Website was started back in those days and since what I want is so simple, I decided to do just that (minus the custom control).&#160; I really only wanted to spend about 10 minutes doing this, and as it turned out, it took about 30.&#160; Oh well, 3x plan verses execution.&#160; Could do better next time.</p>  <p>So, here is basically what I want on the left side bar of the home page of Silicon Valley Code Camp:</p> <span id="more-1366"></span>  <p><a href="http://blog.siliconvalley-codecamp.com/"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="RSS Feed Look" border="0" alt="RSS Feed Look" src="http://peterkellner.net/FilesForWebDownload/AddingaListofRecentPostsToTheSiliconVall_CF44/image.png" width="177" height="346" /></a> </p>  <p>&#160;</p>  <p>First, I’ll attach my simple project I build to do this standalone so you can run it yourself, then, I’ll do a quick step through of the key code.&#160; </p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:8eb9d37f-1541-4f29-b6f4-1eea890d4876:a42e11ac-159d-4bc9-8e14-637ad835e07b" class="wlWriterEditableSmartContent"><p><div><a href="http://peterkellner.net/FilesForWebDownload/AddingaListofRecentPostsToTheSiliconVall_CF44/SimpleRSSReaderJustTitleAndLink.zip" target="_self">SimpleRSSReaderJustTitleAndLink.zip</a></div></p></div>  <p>All that is really in this project is a simple c# class file that contains a business object and one get method to retrieve the list.&#160; That file is called RSSFeed.cs.&#160; I’ve pasted all the code of that class below:</p>  <div id="codeSnippetWrapper">   <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"><span style="color: #0000ff">using</span> System.Collections.Generic;<br /><span style="color: #0000ff">using</span> System.ComponentModel;<br /><span style="color: #0000ff">using</span> System.Linq;<br /><span style="color: #0000ff">using</span> System.Xml.Linq;<br /><br /><span style="color: #0000ff">namespace</span> App_Code<br />{<br />    [DataObject(<span style="color: #0000ff">true</span>)]<br />    <span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span> RSSFeedObject<br />    {<br /><br />        [DataObjectMethod(DataObjectMethodType.Select, <span style="color: #0000ff">true</span>)]<br />        <span style="color: #0000ff">public</span> List&lt;RSSItem&gt; Get(<span style="color: #0000ff">int</span> numberToGet)<br />        {<br />            XDocument feedXML = XDocument.Load<br />              (<span style="color: #006080">&quot;http://blog.siliconvalley-codecamp.com/feed/&quot;</span>);<br /><br />            var feeds = feedXML.Descendants(<span style="color: #006080">&quot;item&quot;</span>).<br />                Select(feed =&gt; <span style="color: #0000ff">new</span><br />                   {<br />                       PostTitle = feed.Element(<span style="color: #006080">&quot;title&quot;</span>).Value,<br />                       PostURL = feed.Element(<span style="color: #006080">&quot;link&quot;</span>).Value<br />                   });<br />            var rssItems = <span style="color: #0000ff">new</span> List&lt;RSSItem&gt;();<br />            <span style="color: #0000ff">int</span> id = 0;<br />            <span style="color: #0000ff">foreach</span> (var rec <span style="color: #0000ff">in</span> feeds)<br />            {<br />                rssItems.Add(<span style="color: #0000ff">new</span> RSSItem<br />                                (id,rec.PostTitle,rec.PostURL));<br />                id++;<br />                <span style="color: #0000ff">if</span> (id &gt;= numberToGet)<br />                {<br />                    <span style="color: #0000ff">break</span>;<br />                }<br />            }<br />            <span style="color: #0000ff">return</span> rssItems;                    <br />        }<br /><br />    }<br /><br />    <span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span> RSSItem<br />    {<br />        [DataObjectField(<span style="color: #0000ff">true</span>)]<br />        <span style="color: #0000ff">public</span> <span style="color: #0000ff">int</span> Id { get; set; }<br /><br />        [DataObjectField(<span style="color: #0000ff">false</span>)]<br />        <span style="color: #0000ff">public</span> <span style="color: #0000ff">string</span> PostTitle { get; set; }<br /><br />        [DataObjectField(<span style="color: #0000ff">false</span>)]<br />        <span style="color: #0000ff">public</span> <span style="color: #0000ff">string</span> PostURL { get; set; }<br /><br />        <span style="color: #0000ff">public</span> RSSItem(<span style="color: #0000ff">int</span> id, <span style="color: #0000ff">string</span> postTitle, <br />                       <span style="color: #0000ff">string</span> postURL)<br />        {<br />            Id = id;<br />            PostTitle = postTitle;<br />            PostURL = postURL;<br />        }<br />    }<br />}</pre>

  <br /></div>

<p>Then, in the Default.aspx page, you can simply reference this object with a <a href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.repeater.aspx">Repeater</a> and an <a href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.objectdatasource.aspx">ObjectDataSource</a> and you are done!&#160; That is it, very simple.&#160; Below is the page code.</p>

<div id="codeSnippetWrapper">
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"><span style="color: #0000ff">&lt;</span><span style="color: #800000">asp:ObjectDataSource</span> <span style="color: #ff0000">ID</span><span style="color: #0000ff">=&quot;ObjectDataSourceRSS&quot;</span> <span style="color: #ff0000">runat</span><span style="color: #0000ff">=&quot;server&quot;</span><br />   <span style="color: #ff0000">SelectMethod</span><span style="color: #0000ff">=&quot;Get&quot;</span> <span style="color: #ff0000">TypeName</span><span style="color: #0000ff">=&quot;App_Code.RSSFeedObject&quot;</span><span style="color: #0000ff">&gt;</span><br />   <span style="color: #0000ff">&lt;</span><span style="color: #800000">SelectParameters</span><span style="color: #0000ff">&gt;</span><br />       <span style="color: #0000ff">&lt;</span><span style="color: #800000">asp:Parameter</span> <span style="color: #ff0000">DefaultValue</span><span style="color: #0000ff">=&quot;5&quot;</span> <span style="color: #ff0000">Name</span><span style="color: #0000ff">=&quot;numberToGet&quot;</span> <span style="color: #ff0000">Type</span><span style="color: #0000ff">=&quot;Int32&quot;</span> <span style="color: #0000ff">/&gt;</span><br />   <span style="color: #0000ff">&lt;/</span><span style="color: #800000">SelectParameters</span><span style="color: #0000ff">&gt;</span><br /><span style="color: #0000ff">&lt;/</span><span style="color: #800000">asp:ObjectDataSource</span><span style="color: #0000ff">&gt;</span><br /><span style="color: #0000ff">&lt;</span><span style="color: #800000">asp:Repeater</span> <span style="color: #ff0000">ID</span><span style="color: #0000ff">=&quot;RepeaterRSS&quot;</span> <span style="color: #ff0000">runat</span><span style="color: #0000ff">=&quot;server&quot;</span> <span style="color: #ff0000">DataSourceID</span><span style="color: #0000ff">=&quot;ObjectDataSourceRSS&quot;</span><span style="color: #0000ff">&gt;</span><br />   <span style="color: #0000ff">&lt;</span><span style="color: #800000">HeaderTemplate</span><span style="color: #0000ff">&gt;</span><br />       <span style="color: #0000ff">&lt;</span><span style="color: #800000">ul</span><span style="color: #0000ff">&gt;</span><br />   <span style="color: #0000ff">&lt;/</span><span style="color: #800000">HeaderTemplate</span><span style="color: #0000ff">&gt;</span><br />   <span style="color: #0000ff">&lt;</span><span style="color: #800000">FooterTemplate</span><span style="color: #0000ff">&gt;</span><br />       <span style="color: #0000ff">&lt;/</span><span style="color: #800000">ul</span><span style="color: #0000ff">&gt;</span><br />   <span style="color: #0000ff">&lt;/</span><span style="color: #800000">FooterTemplate</span><span style="color: #0000ff">&gt;</span><br />   <span style="color: #0000ff">&lt;</span><span style="color: #800000">ItemTemplate</span><span style="color: #0000ff">&gt;</span><br />       <span style="color: #0000ff">&lt;</span><span style="color: #800000">li</span><span style="color: #0000ff">&gt;</span><br />           <span style="color: #0000ff">&lt;</span><span style="color: #800000">asp:HyperLink</span> <span style="color: #ff0000">ID</span><span style="color: #0000ff">=&quot;HyperLinkURL&quot;</span> <span style="color: #ff0000">runat</span><span style="color: #0000ff">=&quot;server&quot;</span> <br />               <span style="color: #ff0000">NavigateUrl</span><span style="color: #0000ff">='&lt;%# Eval(&quot;PostURL&quot;) %&gt;'</span><br />               <span style="color: #ff0000">Text</span><span style="color: #0000ff">='&lt;%# Eval(&quot;PostTitle&quot;) %&gt;'</span><span style="color: #0000ff">&gt;&lt;/</span><span style="color: #800000">asp:HyperLink</span><span style="color: #0000ff">&gt;</span><br />       <span style="color: #0000ff">&lt;/</span><span style="color: #800000">li</span><span style="color: #0000ff">&gt;</span><br />   <span style="color: #0000ff">&lt;/</span><span style="color: #800000">ItemTemplate</span><span style="color: #0000ff">&gt;</span><br /><span style="color: #0000ff">&lt;/</span><span style="color: #800000">asp:Repeater</span><span style="color: #0000ff">&gt;</span></pre>

  <br /></div>

<p>I’m sure someone is going to point out how this could have been done in three lines of code.&#160; Until then, I’ll keep this in the Silicon Valley Code Camp site.</p>

<p>BTW, if the site looks different, it’s because a wizard html/css guy has come by and cleaned it up to look good. What you see in the top screen shot is what it looks like without any formatting.&#160; Just unordered list and listitems with no formatting.</p>

<p>HTH’s!</p>]]></content:encoded>
			<wfw:commentRss>http://peterkellner.net/2010/09/12/simplerssreader-in-silicon-valley-code-camp-objectdatasource-repeater-aspnet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ReSharper 5.0 Adds New &#8220;Add Parameter&#8221; Refactoring</title>
		<link>http://peterkellner.net/2010/04/26/resharper-refactor-add-parameter/</link>
		<comments>http://peterkellner.net/2010/04/26/resharper-refactor-add-parameter/#comments</comments>
		<pubDate>Mon, 26 Apr 2010 18:38:40 +0000</pubDate>
		<dc:creator>Peter Kellner</dc:creator>
				<category><![CDATA[.Net 2.0]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Refactor]]></category>

		<guid isPermaLink="false">http://peterkellner.net/2010/04/26/resharper-refactor-add-parameter/</guid>
		<description><![CDATA[In this post, I’ll show a simple example of how when you add a parameter to C# method, ReSharper gives you a simple prompting to ask if you want to add a parameter to your method, or create an overloaded method that gives you the flexibility to maintain the old method signature and have the [...]]]></description>
			<content:encoded><![CDATA[<p>In this post, I’ll show a simple example of how when you add a parameter to C# method, <a href="http://www.jetbrains.com/resharper/whatsnew/">ReSharper</a> gives you a simple prompting to ask if you want to add a parameter to your method, or create an overloaded method that gives you the flexibility to maintain the old method signature and have the new method.</p> <span id="more-1281"></span>  <p>In my original code, I had the following code that called the method GetLoadResultsFromInterval.</p>  <p>&#160;</p>  <div id="codeSnippetWrapper">   <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">List<span style="color: #0000ff">&lt;</span><span style="color: #800000">LoadResult</span><span style="color: #0000ff">&gt;</span> loadResultsForInterval =<br />    GetLoadResultsForInterval(rec.TimePoint,<br />                              rec.IntervalLengthInMs);</pre>

  <br /></div>

<p>Then, I simply added one more parameter (loadFtpArrivalTimeDictionary) and ReSharper prompted me with the following:</p>

<p>&#160;</p>

<p><a href="http://peterkellner.net/FilesForWebDownload/ReSharpe.0AddsNewAddParameterRefactoring_A3A1/image.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://peterkellner.net/FilesForWebDownload/ReSharpe.0AddsNewAddParameterRefactoring_A3A1/image_thumb.png" width="627" height="203" /></a> </p>

<p>If I choose the first “Add Parameter, I get what I would expect, which is just the method with an extra parameter.</p>

<div id="codeSnippetWrapper">
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">/// <span style="color: #0000ff">&lt;/</span><span style="color: #800000">summary</span><span style="color: #0000ff">&gt;</span><br />/// <span style="color: #0000ff">&lt;</span><span style="color: #800000">param</span> <span style="color: #ff0000">name</span><span style="color: #0000ff">=&quot;timePoint&quot;</span><span style="color: #0000ff">&gt;&lt;/</span><span style="color: #800000">param</span><span style="color: #0000ff">&gt;</span><br />/// <span style="color: #0000ff">&lt;</span><span style="color: #800000">param</span> <span style="color: #ff0000">name</span><span style="color: #0000ff">=&quot;intervalLengthInMs&quot;</span><span style="color: #0000ff">&gt;&lt;/</span><span style="color: #800000">param</span><span style="color: #0000ff">&gt;</span><br />/// <span style="color: #0000ff">&lt;</span><span style="color: #800000">param</span> <span style="color: #ff0000">name</span><span style="color: #0000ff">=&quot;loadFtpArrivalTimeDictionary&quot;</span><span style="color: #0000ff">&gt;&lt;/</span><span style="color: #800000">param</span><span style="color: #0000ff">&gt;</span><br />/// <span style="color: #0000ff">&lt;</span><span style="color: #800000">returns</span><span style="color: #0000ff">&gt;&lt;/</span><span style="color: #800000">returns</span><span style="color: #0000ff">&gt;</span><br />private static List<span style="color: #0000ff">&lt;</span><span style="color: #800000">LoadResult</span><span style="color: #0000ff">&gt;</span> <br />   GetLoadResultsForInterval(DateTime timePoint, <br />   int intervalLengthInMs, <br />   Dictionary<span style="color: #0000ff">&lt;</span><span style="color: #800000">string</span>, <span style="color: #ff0000">DateTime</span><span style="color: #0000ff">&gt;</span> loadFtpArrivalTimeDictionary)<br />{<br />   throw new NotImplementedException();<br />}</pre>

  <br /></div>

<p>It even adds the param xml definition automatically.</p>

<p>However, I’m not quite as pleased with the second refactoring, that is, “Create Overload”.&#160; It does almost everything I would expect, but does not implement the method, which I think it could.&#160; Or, at least it could give it a try.&#160; What it does implement is the following:</p>

<p><a href="http://peterkellner.net/FilesForWebDownload/ReSharpe.0AddsNewAddParameterRefactoring_A3A1/image_3.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://peterkellner.net/FilesForWebDownload/ReSharpe.0AddsNewAddParameterRefactoring_A3A1/image_thumb_3.png" width="652" height="141" /></a> </p>

<p>I’m actually including a picture of it rather than the actual code because it created an error.&#160; It should have said DateTime instead of loadFtpArrivalTimeDictionary.&#160; Two other things of interest.</p>

<p>First, it did not add xml comments (which is probably because of the syntax error), and second, I would have expected it to have called the overloaded method as follows instead of what it did.</p>

<p>&#160;</p>

<div>
  <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">private static List<span style="color: #0000ff">&lt;</span><span style="color: #800000">LoadResult</span><span style="color: #0000ff">&gt;</span> GetLoadResultsForInterval(DateTime timePoint,<br />    int intervalLengthInMs, <br />    Dictionary<span style="color: #0000ff">&lt;</span><span style="color: #800000">string</span>, <span style="color: #ff0000">DateTime</span><span style="color: #0000ff">&gt;</span> loadFtpArrivalTimeDictionary)<br />{<br />    // - put additional code here<br />    return GetLoadResultsForInterval(timePoint, intervalLengthInMs);<br />}</pre>
</div>

<div>&#160;</div>

<div>(before anyone points out this is the opposite of how you would normally overload a method call, I do know that.&#160; That is, typically, you would have a method with 2 incoming parameters that internally would call a method with 3 internal parameters, and you would simply default the third parameter.&#160; In my case, I’m going the other way, which is unusual, but not unheard of.)</div>

<div>
  <br /></div>

<p>I began this post to brag about yet another awesome ReSharper refactoring because I really just wanted to add a parameter to an existing method call and it worked perfect.&#160; It was not until I decided to show the other refactoring for this blog post did I run into the problem.&#160; </p>

<p>I’m going to post this to the refactor dev’s and see if they can let me know where either I’ve gone astray, or there is a problem in their code.&#160; At any rate, I’m running this on vs2008 and have not tried it on vs2010.</p>

<p>Hope this helps!</p>]]></content:encoded>
			<wfw:commentRss>http://peterkellner.net/2010/04/26/resharper-refactor-add-parameter/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>OData Query Option top Forces Data To Be Sorted By Primary Key</title>
		<link>http://peterkellner.net/2010/03/31/odata-wcfdataservice-top-orderby-default-sort/</link>
		<comments>http://peterkellner.net/2010/03/31/odata-wcfdataservice-top-orderby-default-sort/#comments</comments>
		<pubDate>Wed, 31 Mar 2010 18:24:31 +0000</pubDate>
		<dc:creator>Peter Kellner</dc:creator>
				<category><![CDATA[.Net 2.0]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[OData]]></category>
		<category><![CDATA[WCF Data Services]]></category>

		<guid isPermaLink="false">http://peterkellner.net/2010/03/31/odata-wcfdataservice-top-orderby-default-sort/</guid>
		<description><![CDATA[This post show a simple WCF Data Service (Formerly known as ADO.NET Data Services) project that retrieves data using the Reflection Provider for accessing data.  It goes on to show that using $top forces a server side sort of the data by the data's primary key before sending the data out to the client program.]]></description>
			<content:encoded><![CDATA[<p>I’ve recently started using <a href="http://msdn.microsoft.com/en-us/data/aa937697.aspx">Microsoft’s WCF Data Services</a> which supports <a href="http://www.odata.org/developers">OData Services</a>.&#160; What this means is that we can access resources by simply specifying a <a href="http://en.wikipedia.org/wiki/Uniform_Resource_Identifier">URI</a>.&#160; This concept greatly simplified building an ORM layer on a web site, as well as creating the linkage between the server side data and the client side application, which in my case is usually a browser.</p>  <p>So, the issue this blog addresses is that if you form a URI with the parameter $top={anything}, your data will automatically be sorted.&#160; The documentation for OData on top basically says that, but it could be clearer.&#160; It says the following:</p>  <blockquote>   <p><a href="http://www.odata.org/developers/protocols/uri-conventions#TopSystemQueryOption">“If the data service URI contains a $top query option, but does not contain a $orderby option, then the Entries in the set needs to first be fully ordered by the data service.”</a></p> </blockquote>  <p>What actually happens is when you use the orderby clause, the data will be sorted 100% of the time for you, whether you do it or not.</p> <span id="more-1165"></span>  <p>I put a small example together that shows that.&#160; I’ll briefly step through the parts of the code attached to this post that show that happening.&#160; First, the results:</p>  <p><a href="http://peterkellner.net/FilesForWebDownload/ODataQueryOptiontopForcesDataToBeSortedB_9CBC/image.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://peterkellner.net/FilesForWebDownload/ODataQueryOptiontopForcesDataToBeSortedB_9CBC/image_thumb.png" width="411" height="202" /></a></p>  <p>Here is the actual Visual Studio 2010 RC project you can run yourself:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:8eb9d37f-1541-4f29-b6f4-1eea890d4876:3b91b815-24f9-4c84-aa5e-cf26654049f6" class="wlWriterSmartContent">   <div>Solution: <a href="http://peterkellner.net/FilesForWebDownload/ODataQueryOptiontopForcesDataToBeSortedB_9CBC/WCFServicesWithODataExample.zip" target="_self">WCFServicesWithODataExample.zip</a></div> </div>  <p>Notice that when $top=5 is called, the data returned is sorted by the primary key.</p>  <p>Now, here are the details of the project that shows this happening.</p>  <p>Below is the complete code for the WcfDataService.svc.&#160; Notice that the data is created in the SampleDataSource constructor and is created in non-key order.</p>  <div class="csharpcode">   <pre class="alt"><span class="kwrd">using</span> System;</pre>

  <pre><span class="kwrd">using</span> System.Collections.Generic;</pre>

  <pre class="alt"><span class="kwrd">using</span> System.Data.Services;</pre>

  <pre><span class="kwrd">using</span> System.Data.Services.Common;</pre>

  <pre class="alt"><span class="kwrd">using</span> System.Linq;</pre>

  <pre><span class="kwrd">using</span> System.ServiceModel.Web;</pre>

  <pre class="alt"><span class="kwrd">using</span> System.Web;</pre>

  <pre>&#160;</pre>

  <pre class="alt"><span class="kwrd">namespace</span> WebApp</pre>

  <pre>{</pre>

  <pre class="alt">    [EntityPropertyMappingAttribute(</pre>

  <pre>        <span class="str">&quot;Title&quot;</span>, SyndicationItemProperty.Title,</pre>

  <pre class="alt">        SyndicationTextContentKind.Plaintext, <span class="kwrd">true</span>)]</pre>

  <pre>    [DataServiceKey(<span class="str">&quot;Id&quot;</span>)]</pre>

  <pre class="alt">    <span class="kwrd">public</span> <span class="kwrd">class</span> SampleInfo</pre>

  <pre>    {</pre>

  <pre class="alt">        <span class="rem">// The DataServiceKey attribute is necessary unless you name </span></pre>

  <pre>        <span class="rem">// this ID</span></pre>

  <pre class="alt">        <span class="kwrd">public</span> <span class="kwrd">int</span> Id { get; set; } </pre>

  <pre>        <span class="kwrd">public</span> <span class="kwrd">string</span> Title { get; set; }</pre>

  <pre class="alt">    }</pre>

  <pre>&#160;</pre>

  <pre class="alt">    <span class="kwrd">public</span> <span class="kwrd">class</span> SampleDataSource</pre>

  <pre>    {</pre>

  <pre class="alt">        <span class="kwrd">private</span> <span class="kwrd">readonly</span> List&lt;SampleInfo&gt; _sampleInfoList;</pre>

  <pre>&#160;</pre>

  <pre class="alt">        <span class="kwrd">public</span> SampleDataSource()</pre>

  <pre>        {</pre>

  <pre class="alt">            _sampleInfoList =</pre>

  <pre>                <span class="kwrd">new</span> List&lt;SampleInfo&gt;()</pre>

  <pre class="alt">                    {</pre>

  <pre>                        <span class="kwrd">new</span> SampleInfo {Id = 3, Title = <span class="str">&quot;3&quot;</span>},</pre>

  <pre class="alt">                        <span class="kwrd">new</span> SampleInfo {Id = 4, Title = <span class="str">&quot;4&quot;</span>},</pre>

  <pre>                        <span class="kwrd">new</span> SampleInfo {Id = 1, Title = <span class="str">&quot;1&quot;</span>},</pre>

  <pre class="alt">                        <span class="kwrd">new</span> SampleInfo {Id = 5, Title = <span class="str">&quot;5&quot;</span>},</pre>

  <pre>                        <span class="kwrd">new</span> SampleInfo {Id = 2, Title = <span class="str">&quot;2&quot;</span>}</pre>

  <pre class="alt">                    };</pre>

  <pre>        }</pre>

  <pre class="alt">&#160;</pre>

  <pre>        <span class="kwrd">public</span> IQueryable&lt;SampleInfo&gt; SampleInfoData</pre>

  <pre class="alt">        {</pre>

  <pre>            get { <span class="kwrd">return</span> _sampleInfoList.AsQueryable(); }</pre>

  <pre class="alt">        }</pre>

  <pre>    }</pre>

  <pre class="alt">&#160;</pre>

  <pre>    <span class="kwrd">public</span> <span class="kwrd">class</span> WcfDataService : DataService&lt;SampleDataSource&gt;</pre>

  <pre class="alt">    {</pre>

  <pre>        <span class="rem">// This method is called only once to initialize service-wide policies.</span></pre>

  <pre class="alt">        <span class="kwrd">public</span> <span class="kwrd">static</span> <span class="kwrd">void</span> InitializeService(DataServiceConfiguration config)</pre>

  <pre>        {</pre>

  <pre class="alt">            config.SetEntitySetAccessRule(<span class="str">&quot;*&quot;</span>, EntitySetRights.AllRead);</pre>

  <pre>            config.SetServiceOperationAccessRule(<span class="str">&quot;*&quot;</span>, ServiceOperationRights.All);</pre>

  <pre class="alt">            config.DataServiceBehavior.MaxProtocolVersion = </pre>

  <pre>                DataServiceProtocolVersion.V2;</pre>

  <pre class="alt">        }</pre>

  <pre>    }</pre>

  <pre class="alt">}</pre>
</div>

<div class="csharpcode">&#160;</div>

<div class="csharpcode">I’ve created a very simple web page that includes some simple JavaScript to display the results of calling this WCF DataService with and without $top.&#160; The page code is below.</div>

<div class="csharpcode">&#160;</div>

<div class="csharpcode">
  <pre class="alt"><span class="kwrd">&lt;</span><span class="html">head</span> <span class="attr">runat</span><span class="kwrd">=&quot;server&quot;</span><span class="kwrd">&gt;</span></pre>

  <pre>    <span class="kwrd">&lt;</span><span class="html">title</span><span class="kwrd">&gt;</span>Demonstration of OData Sort Based on Using $top<span class="kwrd">&lt;/</span><span class="html">title</span><span class="kwrd">&gt;</span></pre>

  <pre class="alt">&#160;</pre>

  <pre>     <span class="kwrd">&lt;</span><span class="html">script</span> <span class="attr">src</span><span class="kwrd">=&quot;http://ajax.microsoft.com/ajax/jquery/jquery-1.3.2.min.js&quot;</span>    </pre>

  <pre class="alt">        <span class="attr">type</span><span class="kwrd">=&quot;text/javascript&quot;</span><span class="kwrd">&gt;&lt;/</span><span class="html">script</span><span class="kwrd">&gt;</span>  </pre>

  <pre>&#160;</pre>

  <pre class="alt">&#160;</pre>

  <pre>    &lt;script type=<span class="str">&quot;text/javascript&quot;</span> &gt;</pre>

  <pre class="alt">        <span class="rem">// Display the data with and without $top with OData</span></pre>

  <pre>        $(document).ready(<span class="kwrd">function</span> () {</pre>

  <pre class="alt">            loadData(<span class="str">&quot;/WcfDataService.svc/SampleInfoData&quot;</span>,<span class="str">&quot;#resultTableNoODataParms&quot;</span>);</pre>

  <pre>            loadData(<span class="str">&quot;/WcfDataService.svc/SampleInfoData?$top=5&quot;</span>, <span class="str">&quot;#resultTableWithODataParms&quot;</span>);</pre>

  <pre class="alt">        });</pre>

  <pre>&#160;</pre>

  <pre class="alt">        <span class="rem">// Called after DOM is ready to call service and display table data</span></pre>

  <pre>        <span class="kwrd">function</span> loadData(urlString,divName) {</pre>

  <pre class="alt">            <span class="kwrd">var</span> url = urlString; <span class="rem">// &quot;/WcfDataService.svc/SampleInfoData&quot;;</span></pre>

  <pre>            $.ajax({</pre>

  <pre class="alt">                type: <span class="str">&quot;GET&quot;</span>,</pre>

  <pre>                url: url,</pre>

  <pre class="alt">                contentType: <span class="str">&quot;application/json; charset=utf-8&quot;</span>,</pre>

  <pre>                dataType: <span class="str">&quot;json&quot;</span>,</pre>

  <pre class="alt">                success: <span class="kwrd">function</span> (msg) {</pre>

  <pre>                    loadTable(msg.d,divName);</pre>

  <pre class="alt">                }</pre>

  <pre>            });</pre>

  <pre class="alt">        }</pre>

  <pre>&#160;</pre>

  <pre class="alt">        <span class="rem">// display data at a given ID</span></pre>

  <pre>        <span class="kwrd">function</span> loadTable(results,divName) {</pre>

  <pre class="alt">            <span class="kwrd">var</span> table = <span class="str">'&lt;table border=1&gt;&lt;tbody&gt;&lt;tr&gt;'</span>;</pre>

  <pre>            <span class="kwrd">for</span> (<span class="kwrd">var</span> post <span class="kwrd">in</span> results) {</pre>

  <pre class="alt">                <span class="kwrd">var</span> row = <span class="str">''</span>;</pre>

  <pre>                row += <span class="str">'&lt;td&gt;'</span> + results[post].Id + <span class="str">'&lt;/td&gt;'</span>;</pre>

  <pre class="alt">                table += row;</pre>

  <pre>            }</pre>

  <pre class="alt">            table += <span class="str">'&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;'</span>;</pre>

  <pre>            $(divName).html(table);</pre>

  <pre class="alt">        }</pre>

  <pre>    <span class="kwrd">&lt;/</span><span class="html">script</span><span class="kwrd">&gt;</span></pre>

  <pre class="alt">&#160;</pre>

  <pre><span class="kwrd">&lt;/</span><span class="html">head</span><span class="kwrd">&gt;</span></pre>

  <pre class="alt"><span class="kwrd">&lt;</span><span class="html">body</span><span class="kwrd">&gt;</span></pre>

  <pre>    <span class="kwrd">&lt;</span><span class="html">form</span> <span class="attr">id</span><span class="kwrd">=&quot;form1&quot;</span> <span class="attr">runat</span><span class="kwrd">=&quot;server&quot;</span><span class="kwrd">&gt;</span></pre>

  <pre class="alt">    <span class="kwrd">&lt;</span><span class="html">div</span><span class="kwrd">&gt;</span></pre>

  <pre>    <span class="kwrd">&lt;</span><span class="html">h2</span><span class="kwrd">&gt;</span>/WcfDataService.svc/SampleInfoData<span class="kwrd">&lt;/</span><span class="html">h2</span><span class="kwrd">&gt;</span></pre>

  <pre class="alt">    <span class="kwrd">&lt;</span><span class="html">div</span> <span class="attr">id</span><span class="kwrd">=&quot;resultTableNoODataParms&quot;</span> <span class="kwrd">/&gt;</span></pre>

  <pre>    <span class="kwrd">&lt;/</span><span class="html">div</span><span class="kwrd">&gt;</span></pre>

  <pre class="alt">    <span class="kwrd">&lt;</span><span class="html">hr</span> <span class="kwrd">/&gt;</span></pre>

  <pre>     <span class="kwrd">&lt;</span><span class="html">div</span><span class="kwrd">&gt;</span></pre>

  <pre class="alt">    <span class="kwrd">&lt;</span><span class="html">h2</span><span class="kwrd">&gt;</span>/WcfDataService.svc/SampleInfoData?$top=5<span class="kwrd">&lt;/</span><span class="html">h2</span><span class="kwrd">&gt;</span></pre>

  <pre>    <span class="kwrd">&lt;</span><span class="html">div</span> <span class="attr">id</span><span class="kwrd">=&quot;resultTableWithODataParms&quot;</span> <span class="kwrd">/&gt;</span></pre>

  <pre class="alt">    <span class="kwrd">&lt;/</span><span class="html">div</span><span class="kwrd">&gt;</span></pre>

  <pre>&#160;</pre>

  <pre class="alt">    <span class="kwrd">&lt;/</span><span class="html">form</span><span class="kwrd">&gt;</span></pre>

  <pre><span class="kwrd">&lt;/</span><span class="html">body</span><span class="kwrd">&gt;</span></pre>

  <pre class="alt"><span class="kwrd">&lt;/</span><span class="html">html</span><span class="kwrd">&gt;</span></pre>
</div>
<style type="text/css">



.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; }</style><style type="text/css">



.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; }</style>

<p>As you can see, adding the $top=5 causes the data to be sorted.</p>

<p>Hope this helps!</p>]]></content:encoded>
			<wfw:commentRss>http://peterkellner.net/2010/03/31/odata-wcfdataservice-top-orderby-default-sort/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>ExtJS Meetup Tonight in San Francisco, Sample URLs of Running Code Here</title>
		<link>http://peterkellner.net/2009/05/14/extjs-meetup-aspnet-code-samples/</link>
		<comments>http://peterkellner.net/2009/05/14/extjs-meetup-aspnet-code-samples/#comments</comments>
		<pubDate>Thu, 14 May 2009 14:47:59 +0000</pubDate>
		<dc:creator>Peter Kellner</dc:creator>
				<category><![CDATA[ASP.NET 2.0]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Community]]></category>
		<category><![CDATA[ExtJS]]></category>
		<category><![CDATA[ObjectDataSource]]></category>
		<category><![CDATA[Speaking]]></category>

		<guid isPermaLink="false">http://peterkellner.net/2009/05/14/extjs-meetup-aspnet-code-samples/</guid>
		<description><![CDATA[ At tonight&#8217;s meet up, we will be having several short presentations on the new features in ExtJS version 3.0.&#160; For my short presentation, I will be showing how to build a simple asp.net application that lets you Create, Update, Delete and Edit Membership data using the ASP.NET built in membership providers.&#160; I will be [...]]]></description>
			<content:encoded><![CDATA[<p> At tonight&#8217;s meet up, we will be having several short presentations on the new features in <a href="http://extjs.com">ExtJS</a> version 3.0.&#160; For my short presentation, I will be showing how to build a simple asp.net application that lets you Create, Update, Delete and Edit Membership data using the ASP.NET built in membership providers.&#160; I will be leverage code from an MSDN article I wrote a while back here along with the URL to the meetup location.</p>  <p><a title="http://www.meetup.com/The-San-Francisco-ExtJS-Meetup-Group/calendar/10302891/" href="http://www.meetup.com/The-San-Francisco-ExtJS-Meetup-Group/calendar/10302891/">http://www.meetup.com/The-San-Francisco-ExtJS-Meetup-Group/calendar/10302891/</a></p>  <p><a title="http://msdn.microsoft.com/en-us/library/aa478947.aspx" href="http://msdn.microsoft.com/en-us/library/aa478947.aspx">http://msdn.microsoft.com/en-us/library/aa478947.aspx</a></p>  <p>My plan is to do a progression where I start with a trivial GridPanel, then work myself in 5 steps to a full working membership editor that looks like this:</p> <span id="more-308"></span>  <p><a href="http://peterkellner.net/FilesForWebDownload/ExtJSMeetupTonightinSanFranciscoHereisas_6DA2/image.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://peterkellner.net/FilesForWebDownload/ExtJSMeetupTonightinSanFranciscoHereisas_6DA2/image_thumb.png" width="392" height="425" /></a></p>  <p>&#160;</p>  <p>If you want to to run the code I will be explaining tonight, here are some links:</p>  <p><a title="http://aspnetextjsdemo.peterkellner.net/ExtJSProfileEditorASimpleGrid.html" href="http://aspnetextjsdemo.peterkellner.net/ExtJSProfileEditorASimpleGrid.html">http://aspnetextjsdemo.peterkellner.net/ExtJSProfileEditorASimpleGrid.html</a></p>  <p><a title="http://aspnetextjsdemo.peterkellner.net/ExtJSProfileEditorBMoreGrid.html" href="http://aspnetextjsdemo.peterkellner.net/ExtJSProfileEditorBMoreGrid.html">http://aspnetextjsdemo.peterkellner.net/ExtJSProfileEditorBMoreGrid.html</a></p>  <p><a title="http://aspnetextjsdemo.peterkellner.net/ExtJSProfileEditorCMoreGridWithPaging.html" href="http://aspnetextjsdemo.peterkellner.net/ExtJSProfileEditorCMoreGridWithPaging.html">http://aspnetextjsdemo.peterkellner.net/ExtJSProfileEditorCMoreGridWithPaging.html</a></p>  <p><a title="http://aspnetextjsdemo.peterkellner.net/ExtJSProfileEditorDMoreGridEditing.html" href="http://aspnetextjsdemo.peterkellner.net/ExtJSProfileEditorDMoreGridEditing.html">http://aspnetextjsdemo.peterkellner.net/ExtJSProfileEditorDMoreGridEditing.html</a></p>  <p><a title="http://aspnetextjsdemo.peterkellner.net/ExtJSProfileEditorEAddDeleteToolbar.html" href="http://aspnetextjsdemo.peterkellner.net/ExtJSProfileEditorEAddDeleteToolbar.html">http://aspnetextjsdemo.peterkellner.net/ExtJSProfileEditorEAddDeleteToolbar.html</a></p>  <p>If you want a more complete demonstration of ExtJS in general along with more details of the code, I’m presenting a full length version of this at he Bay.Net Meeting in Microsoft next Wednesday evening.&#160; Here are the full details.&#160; These events are both community events are free.</p>  <p><a title="http://www.baynetug.org/DesktopModules/DetailXEvents.aspx?ItemID=378&amp;mid=49" href="http://www.baynetug.org/DesktopModules/DetailXEvents.aspx?ItemID=378&amp;mid=49">http://www.baynetug.org/DesktopModules/DetailXEvents.aspx?ItemID=378&amp;mid=49</a></p>  <p>Hope to see you at one of the events!</p>]]></content:encoded>
			<wfw:commentRss>http://peterkellner.net/2009/05/14/extjs-meetup-aspnet-code-samples/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>How to Retrieve a GridView Based on a CheckBoxList of Items with Asp.Net using ObjectDataSource with a little LINQ Thrown In</title>
		<link>http://peterkellner.net/2008/12/07/checkboxlist-gridview-aspnet-howto-mutiple-selections/</link>
		<comments>http://peterkellner.net/2008/12/07/checkboxlist-gridview-aspnet-howto-mutiple-selections/#comments</comments>
		<pubDate>Sun, 07 Dec 2008 06:08:02 +0000</pubDate>
		<dc:creator>Peter Kellner</dc:creator>
				<category><![CDATA[ASP.NET 2.0]]></category>
		<category><![CDATA[ASP.NET 3.5]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[GridView]]></category>
		<category><![CDATA[ObjectDataSource]]></category>

		<guid isPermaLink="false">http://peterkellner.net/?p=210</guid>
		<description><![CDATA[So, the problem is you have a list that you want to retrieve from that contains multiple values.&#160; Say for example, you have a list of 5 cities and you want to retrieve a list of people in some combination of those cities.&#160; If you use the class SelectValue method with GridView you run out [...]]]></description>
			<content:encoded><![CDATA[<p>So, the problem is you have a list that you want to retrieve from that contains multiple values.&#160; Say for example, you have a list of 5 cities and you want to retrieve a list of people in some combination of those cities.&#160; If you use the class SelectValue method with <a href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.aspx">GridView</a> you run out of steam because it&#8217;s only one value.&#160; What you&#8217;d really like to do is pass the <a href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.checkboxlist.aspx">CheckBoxList</a> into the GridView as a selection parameter, but unfortunately, when you do that, you just get the one selected value from the CheckBoxList, not all the values.</p>  <p>I&#8217;m sure you can make a custom <a href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.controlparameter.aspx">ControlParameter</a> in <a href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.objectdatasource.aspx">ObjectDataSource</a> to solve this, but I really don&#8217;t have time for that.&#160; I just wanted something quick (which I now have and thought I&#8217;d share).</p> <span id="more-210"></span>  <p>Basically, what I did was create an invisible label on my GridView that will get the string of values I want to retrieve, then, my ObjectDataSource gets one value (the string) and parses it into small values.&#160; My plan is to do a quick run through of the code here, but then also post the project so you can see for yourself how it works.</p>  <p>Here we go.</p>  <p>First, let&#8217;s make a simple BusinessObject class that returns to us some data.&#160; The basic object that will be returned is the Person defined as follows:</p>  <div class="csharpcode">   <pre class="alt"> <span class="kwrd">public</span> <span class="kwrd">class</span> Person</pre>

  <pre>    {</pre>

  <pre class="alt">        <span class="kwrd">public</span> Person()</pre>

  <pre>        {</pre>

  <pre class="alt">        }</pre>

  <pre>&#160;</pre>

  <pre class="alt">        <span class="kwrd">public</span> Person(<span class="kwrd">string</span> _name, <span class="kwrd">int</span> _id)</pre>

  <pre>        {</pre>

  <pre class="alt">            <span class="kwrd">this</span>._name = _name;</pre>

  <pre>            <span class="kwrd">this</span>._id = _id;</pre>

  <pre class="alt">        }</pre>

  <pre>&#160;</pre>

  <pre class="alt">        <span class="kwrd">private</span> <span class="kwrd">string</span> _name;</pre>

  <pre>        <span class="kwrd">private</span> <span class="kwrd">int</span> _id;</pre>

  <pre class="alt">&#160;</pre>

  <pre>        <span class="kwrd">public</span> <span class="kwrd">string</span> name</pre>

  <pre class="alt">        {</pre>

  <pre>            get { <span class="kwrd">return</span> _name; }</pre>

  <pre class="alt">            set { _name = <span class="kwrd">value</span>; }</pre>

  <pre>        }</pre>

  <pre class="alt">&#160;</pre>

  <pre>        <span class="kwrd">public</span> <span class="kwrd">int</span> id</pre>

  <pre class="alt">        {</pre>

  <pre>            get { <span class="kwrd">return</span> _id; }</pre>

  <pre class="alt">            set { _id = <span class="kwrd">value</span>; }</pre>

  <pre>        }</pre>

  <pre class="alt">    }</pre>
</div>
<style type="text/css">



.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; }</style>

<p><!-- .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; } --></p>

<p>Next, we need two methods, the first is the method that does the heavy lifting (that is, takes a list of integers and returns the final list of people who have those cities in them, then, we need the method that polymorphically calls (did I spell that wrong, live writer thinks so&#8230; sorry) that method whose input is a single string.&#160; That method parses the string (which was assembled in page_load of the calling page) and calls the first one.</p>

<p>So, here is the method ObjectDataSource actually calls to get it&#8217;s view of the data (remember, ObjectDataSource only returns one view).</p>

<div class="csharpcode">
  <pre class="alt"> <span class="kwrd">public</span> List&lt;Person&gt; GetPeopleByCityList(List&lt;<span class="kwrd">int</span>&gt; cityList)</pre>

  <pre>        {</pre>

  <pre class="alt">            List&lt;Person&gt; personList = <span class="kwrd">new</span> List&lt;Person&gt;</pre>

  <pre>                                          {</pre>

  <pre class="alt">                                              <span class="kwrd">new</span> Person(<span class="str">&quot;Peter_SanJose&quot;</span>, 1),</pre>

  <pre>                                              <span class="kwrd">new</span> Person(<span class="str">&quot;Tom_Hartsdale&quot;</span>, 2),</pre>

  <pre class="alt">                                              <span class="kwrd">new</span> Person(<span class="str">&quot;Eric_Chicago&quot;</span>, 3),</pre>

  <pre>                                              <span class="kwrd">new</span> Person(<span class="str">&quot;Ron_SanJose&quot;</span>, 1),</pre>

  <pre class="alt">                                              <span class="kwrd">new</span> Person(<span class="str">&quot;John_Chicago&quot;</span>, 3),</pre>

  <pre>                                              <span class="kwrd">new</span> Person(<span class="str">&quot;Charly_Scarsdale&quot;</span>, 4)</pre>

  <pre class="alt">                                          };</pre>

  <pre>&#160;</pre>

  <pre class="alt">            var personResult = from p <span class="kwrd">in</span> personList</pre>

  <pre>                               <span class="kwrd">where</span> cityList.Contains(p.id)</pre>

  <pre class="alt">                               orderby p.name</pre>

  <pre>                               select p;</pre>

  <pre class="alt">&#160;</pre>

  <pre>            <span class="kwrd">return</span> personResult.ToList();</pre>

  <pre class="alt">        }</pre>

  <pre>&#160;</pre>

  <pre class="alt">        <span class="kwrd">public</span> List&lt;Person&gt; GetPeopleByCityListString(<span class="kwrd">string</span> cityListString)</pre>

  <pre>        {</pre>

  <pre class="alt">            <span class="kwrd">if</span> (!String.IsNullOrEmpty(cityListString))</pre>

  <pre>            {</pre>

  <pre class="alt">                var values = cityListString.Split(<span class="str">';'</span>);</pre>

  <pre>                var cityList = <span class="kwrd">new</span> List&lt;<span class="kwrd">int</span>&gt;();</pre>

  <pre class="alt">                <span class="kwrd">foreach</span> (<span class="kwrd">string</span> s <span class="kwrd">in</span> values)</pre>

  <pre>                {</pre>

  <pre class="alt">                    cityList.Add(Convert.ToInt32(s));</pre>

  <pre>                }</pre>

  <pre class="alt">&#160;</pre>

  <pre>                <span class="kwrd">return</span> GetPeopleByCityList(cityList);</pre>

  <pre class="alt">            }</pre>

  <pre>            <span class="kwrd">return</span> <span class="kwrd">null</span>;</pre>

  <pre class="alt">        }</pre>

  <pre>&#160;</pre>

  <pre class="alt">    }</pre>
</div>
<style type="text/css">


.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; }</style>

<p>Now, the method that actually does the work.&#160; Notice I&#8217;m using the C# 3.0 object initializer syntax to build it, but normally, you&#8217;d be calling a database or something like that here.&#160; Also notice the clever <a href="http://msdn.microsoft.com/en-us/library/bb308959.aspx">LINQ</a> that does the equivalent of an SQL IN clause.&#160; That is, we&#8217;d normally be doing something like &quot;Select .. From Person Where CityId IN (1,3..)).&#160; It seems a little backwards to me, but it does the job.</p>

<p>So, now we have the business object, let&#8217;s put it to work.&#160; Let&#8217;s build a simple aspx page that has a CheckBoxList, GridView,Label and a Button.&#160; I&#8217;ll pre-populate the CheckBoxList just to keep my example simple.&#160; Normally, you&#8217;d be getting that data from another data source like a database.</p>

<p>So, Here is the aspx file we built.</p>

<div class="csharpcode">
  <pre class="alt">&lt;%@ Page Language=<span class="str">&quot;C#&quot;</span> AutoEventWireup=<span class="str">&quot;true&quot;</span> CodeFile=<span class="str">&quot;Default.aspx.cs&quot;</span> Inherits=<span class="str">&quot;_Default&quot;</span> %&gt;</pre>

  <pre>&lt;html xmlns=<span class="str">&quot;http://www.w3.org/1999/xhtml&quot;</span>&gt;</pre>

  <pre class="alt">&lt;head runat=<span class="str">&quot;server&quot;</span>&gt;</pre>

  <pre>    &lt;title&gt;&lt;/title&gt;</pre>

  <pre class="alt">&lt;/head&gt;</pre>

  <pre>&lt;body bgcolor=<span class="str">&quot;#00ccff&quot;</span>&gt;</pre>

  <pre class="alt">    &lt;form id=<span class="str">&quot;form1&quot;</span> runat=<span class="str">&quot;server&quot;</span>&gt;</pre>

  <pre>    &lt;div&gt;</pre>

  <pre class="alt">        &lt;asp:Button ID=<span class="str">&quot;ButtonSearch&quot;</span> runat=<span class="str">&quot;server&quot;</span> Text=<span class="str">&quot;Retrieve&quot;</span> </pre>

  <pre>            onclick=<span class="str">&quot;ButtonSearch_Click&quot;</span> /&gt;</pre>

  <pre class="alt">        &lt;asp:Label ID=<span class="str">&quot;Label1&quot;</span> runat=<span class="str">&quot;server&quot;</span> Visible=<span class="str">&quot;false&quot;</span> Text=<span class="str">&quot;Label&quot;</span>&gt;&lt;/asp:Label&gt;</pre>

  <pre>        &lt;asp:CheckBoxList ID=<span class="str">&quot;CheckBoxList1&quot;</span> runat=<span class="str">&quot;server&quot;</span>&gt;</pre>

  <pre class="alt">            &lt;asp:ListItem Value=<span class="str">&quot;2&quot;</span>&gt;Hartsdale&lt;/asp:ListItem&gt;</pre>

  <pre>            &lt;asp:ListItem Value=<span class="str">&quot;4&quot;</span>&gt;Scarsdale&lt;/asp:ListItem&gt;</pre>

  <pre class="alt">            &lt;asp:ListItem Value=<span class="str">&quot;3&quot;</span>&gt;Chicago&lt;/asp:ListItem&gt;</pre>

  <pre>            &lt;asp:ListItem Value=<span class="str">&quot;1&quot;</span>&gt;San Jose&lt;/asp:ListItem&gt;</pre>

  <pre class="alt">        &lt;/asp:CheckBoxList&gt;</pre>

  <pre>        &lt;asp:ObjectDataSource ID=<span class="str">&quot;ObjectDataSource1&quot;</span> runat=<span class="str">&quot;server&quot;</span> SelectMethod=<span class="str">&quot;GetPeopleByCityListString&quot;</span></pre>

  <pre class="alt">            TypeName=<span class="str">&quot;BO.BusinessObject&quot;</span>&gt;</pre>

  <pre>            &lt;SelectParameters&gt;</pre>

  <pre class="alt">                &lt;asp:ControlParameter ControlID=<span class="str">&quot;Label1&quot;</span> Name=<span class="str">&quot;cityListString&quot;</span> PropertyName=<span class="str">&quot;Text&quot;</span></pre>

  <pre>                    Type=<span class="str">&quot;String&quot;</span> /&gt;</pre>

  <pre class="alt">            &lt;/SelectParameters&gt;</pre>

  <pre>        &lt;/asp:ObjectDataSource&gt;</pre>

  <pre class="alt">        &lt;asp:GridView ID=<span class="str">&quot;GridView1&quot;</span> runat=<span class="str">&quot;server&quot;</span> AutoGenerateColumns=<span class="str">&quot;False&quot;</span> </pre>

  <pre>            DataSourceID=<span class="str">&quot;ObjectDataSource1&quot;</span>&gt;</pre>

  <pre class="alt">            &lt;Columns&gt;</pre>

  <pre>                &lt;asp:BoundField DataField=<span class="str">&quot;name&quot;</span> HeaderText=<span class="str">&quot;name&quot;</span> SortExpression=<span class="str">&quot;name&quot;</span> /&gt;</pre>

  <pre class="alt">                &lt;asp:BoundField DataField=<span class="str">&quot;id&quot;</span> HeaderText=<span class="str">&quot;id&quot;</span> SortExpression=<span class="str">&quot;id&quot;</span> /&gt;</pre>

  <pre>            &lt;/Columns&gt;</pre>

  <pre class="alt">        &lt;/asp:GridView&gt;</pre>

  <pre>    &lt;/div&gt;</pre>

  <pre class="alt">    &lt;/form&gt;</pre>

  <pre>&lt;/body&gt;</pre>

  <pre class="alt">&lt;/html&gt;</pre>
</div>
<style type="text/css">


.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; }</style>

<p>Notice that the asp controlparameter is passing the Label1 contents to the ObjectDataSource.&#160; To load that, we need to put some code in the Page_Load event that will set that line.&#160; Here is that code.&#160; It simply reads the checkboxlist and builds the string of numbers (3,5,7,9.).</p>

<p>I&#8217;m pretty sure that is it.&#160; Now, when you run the web site, you&#8217;ll get a screen that you can click multiple checkboxes on and get all the results that correspond with that checkbox.&#160; Here is what it should look like:</p>

<p><a href="http://peterkellner.net/blogimages/How.NetusingObjectDataSourcewithalittleL_13393/image_thumb1.png"><img border="0" alt="image_thumb1" src="http://peterkellner.net/blogimages/How.NetusingObjectDataSourcewithalittleL_13393/image_thumb1_thumb.png" width="166" height="244" /></a></p>

<p>Hope this Helps!&#160; And, if you it the better way by making a custom ControlParameter, post it here and we can all ignore this article.&#160; <img alt="Smile" src="http://messenger.msn.com/MMM2006-04-19_17.00/Resource/emoticons/regular_smile.gif" /></p>

<p>&#160;</p>

<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px" id="scid:fb3a1972-4489-4e52-abe7-25a00bb07fdf:cce21702-3bbb-4f92-b1fd-70d9beb3879d" class="wlWriterSmartContent">
  <p>The Code <a href="http://peterkellner.net/blogimages/TEST_1370C/GridViewCheckBoxListExample1.zip" target="_blank">GridViewCheckBoxListExample1.zip</a></p>
</div>]]></content:encoded>
			<wfw:commentRss>http://peterkellner.net/2008/12/07/checkboxlist-gridview-aspnet-howto-mutiple-selections/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Assigning a Custom Label Value in a ASP.NET GridView Using ObjectDataSource</title>
		<link>http://peterkellner.net/2008/08/06/assign-label-in-aspdotnet-to-gridview-in-objectdatasource/</link>
		<comments>http://peterkellner.net/2008/08/06/assign-label-in-aspdotnet-to-gridview-in-objectdatasource/#comments</comments>
		<pubDate>Wed, 06 Aug 2008 14:10:07 +0000</pubDate>
		<dc:creator>Peter Kellner</dc:creator>
				<category><![CDATA[ASP.NET 2.0]]></category>
		<category><![CDATA[GridView]]></category>
		<category><![CDATA[ObjectDataSource]]></category>

		<guid isPermaLink="false">http://peterkellner.net/2008/08/06/assign-label-in-aspdotnet-to-gridview-in-objectdatasource/</guid>
		<description><![CDATA[In my previous post, Assigning a DropDownList Value in a ASP.NET GridView Using ObjectDataSource, I discussed how to put a DropDownList value in a GridView.&#160; As I explained, my motivation was to answer a common question that appears on often on the forums.&#160; If you are wondering what my process is for deciding what to [...]]]></description>
			<content:encoded><![CDATA[<p>In my previous post, <a href="http://peterkellner.net/2008/08/05/assign-dropdownlist-in-aspdotnet-to-gridview-in-objectdatasource/">Assigning a DropDownList Value in a ASP.NET GridView Using ObjectDataSource</a>, I discussed how to put a <a href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.dropdownlist(VS.80).aspx">DropDownList</a> value in a <a href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview(VS.80).aspx">GridView</a>.&#160; As I explained, my motivation was to answer a common question that appears on often on the forums.&#160; If you are wondering what my process is for deciding what to answer, there really is no process besides I see yet another question on the forum about this, and rather than answer it again, I write a post explaining it, then point my answer to the question at the post.&#160; This is what I did yesterday and below is the response to this <a href="http://forums.asp.net/p/1300497/2540027.aspx#2540027">forum post</a>.</p>  <p><a href="http://peterkellner.net/wp/wp-content/uploads/2008/08/x2.png"><img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="x" src="http://peterkellner.net/wp/wp-content/uploads/2008/08/x-thumb2.png" width="540" height="208" /></a></p> <span id="more-129"></span>  <p>So, I have to say one of my main motivations for doing posts is I enjoy helping others through problems.&#160; It gives me a certain satisfaction to know that I have knowledge others may not at any give time and I have a great way to share that knowledge.&#160; It also makes me feel good when others go out of their way to appreciate the effort.&#160; I know when I post questions on forums and get good answers how happy I am, it&#8217;s good to know others appreciate my efforts.</p>  <p>So, continuing down that path, Here is the code necessary to answer Zimbran&#8217;s last question.</p> <!-- code formatted by http://manoli.net/csharpformat/ --><style type="text/css">

.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; }</style>  <div class="csharpcode">   <pre class="alt"><span class="asp">&lt;%@ Page Language=&quot;C#&quot; %&gt;</span></pre>

  <pre><span class="kwrd">&lt;!</span><span class="html">DOCTYPE</span> <span class="attr">html</span> <span class="attr">PUBLIC</span> <span class="kwrd">&quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot;</span> </pre>

  <pre class="alt"><span class="kwrd">&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;</span><span class="kwrd">&gt;</span></pre>

  <pre><span class="kwrd">&lt;</span><span class="html">script</span> <span class="attr">runat</span><span class="kwrd">=&quot;server&quot;</span><span class="kwrd">&gt;</span></pre>

  <pre class="alt"><span class="kwrd">&lt;/</span><span class="html">script</span><span class="kwrd">&gt;</span></pre>

  <pre><span class="kwrd">&lt;</span><span class="html">html</span> <span class="attr">xmlns</span><span class="kwrd">=&quot;http://www.w3.org/1999/xhtml&quot;</span><span class="kwrd">&gt;</span></pre>

  <pre class="alt"><span class="kwrd">&lt;</span><span class="html">head</span> <span class="attr">runat</span><span class="kwrd">=&quot;server&quot;</span><span class="kwrd">&gt;</span></pre>

  <pre>    <span class="kwrd">&lt;</span><span class="html">title</span><span class="kwrd">&gt;</span>ODS DDL Example<span class="kwrd">&lt;/</span><span class="html">title</span><span class="kwrd">&gt;</span></pre>

  <pre class="alt"><span class="kwrd">&lt;/</span><span class="html">head</span><span class="kwrd">&gt;</span></pre>

  <pre><span class="kwrd">&lt;</span><span class="html">body</span><span class="kwrd">&gt;</span></pre>

  <pre class="alt">    <span class="kwrd">&lt;</span><span class="html">form</span> <span class="attr">id</span><span class="kwrd">=&quot;form1&quot;</span> <span class="attr">runat</span><span class="kwrd">=&quot;server&quot;</span><span class="kwrd">&gt;</span></pre>

  <pre>    <span class="kwrd">&lt;</span><span class="html">div</span><span class="kwrd">&gt;</span></pre>

  <pre class="alt">        <span class="kwrd">&lt;</span><span class="html">asp:ObjectDataSource</span> <span class="attr">ID</span><span class="kwrd">=&quot;ObjectDataSource1&quot;</span> <span class="attr">runat</span><span class="kwrd">=&quot;server&quot;</span> </pre>

  <pre>            <span class="attr">SelectMethod</span><span class="kwrd">=&quot;GetMembers&quot;</span></pre>

  <pre class="alt">            <span class="attr">TypeName</span><span class="kwrd">=&quot;BusinessObject&quot;</span><span class="kwrd">&gt;&lt;/</span><span class="html">asp:ObjectDataSource</span><span class="kwrd">&gt;</span></pre>

  <pre>        <span class="kwrd">&lt;</span><span class="html">asp:GridView</span> <span class="attr">ID</span><span class="kwrd">=&quot;GridView1&quot;</span> <span class="attr">runat</span><span class="kwrd">=&quot;server&quot;</span> <span class="attr">AutoGenerateColumns</span><span class="kwrd">=&quot;False&quot;</span> </pre>

  <pre class="alt">               <span class="attr">DataKeyNames</span><span class="kwrd">=&quot;Id&quot;</span></pre>

  <pre>            <span class="attr">DataSourceID</span><span class="kwrd">=&quot;ObjectDataSource1&quot;</span><span class="kwrd">&gt;</span></pre>

  <pre class="alt">            <span class="kwrd">&lt;</span><span class="html">Columns</span><span class="kwrd">&gt;</span></pre>

  <pre>                <span class="kwrd">&lt;</span><span class="html">asp:BoundField</span> <span class="attr">DataField</span><span class="kwrd">=&quot;Id&quot;</span> <span class="attr">HeaderText</span><span class="kwrd">=&quot;Id&quot;</span> <span class="attr">ReadOnly</span><span class="kwrd">=&quot;True&quot;</span> </pre>

  <pre class="alt">                   <span class="attr">SortExpression</span><span class="kwrd">=&quot;Id&quot;</span> <span class="kwrd">/&gt;</span></pre>

  <pre>                <span class="kwrd">&lt;</span><span class="html">asp:BoundField</span> <span class="attr">DataField</span><span class="kwrd">=&quot;Name&quot;</span> <span class="attr">HeaderText</span><span class="kwrd">=&quot;Name&quot;</span> <span class="attr">SortExpression</span><span class="kwrd">=&quot;Name&quot;</span> <span class="kwrd">/&gt;</span></pre>

  <pre class="alt">                <span class="kwrd">&lt;</span><span class="html">asp:BoundField</span> <span class="attr">DataField</span><span class="kwrd">=&quot;Email&quot;</span> <span class="attr">HeaderText</span><span class="kwrd">=&quot;Email&quot;</span> <span class="attr">SortExpression</span><span class="kwrd">=&quot;Email&quot;</span> <span class="kwrd">/&gt;</span></pre>

  <pre>                <span class="kwrd">&lt;</span><span class="html">asp:TemplateField</span> <span class="attr">HeaderText</span><span class="kwrd">=&quot;Approved&quot;</span> <span class="attr">SortExpression</span><span class="kwrd">=&quot;Approved&quot;</span><span class="kwrd">&gt;</span></pre>

  <pre class="alt">                    <span class="kwrd">&lt;</span><span class="html">ItemTemplate</span><span class="kwrd">&gt;</span></pre>

  <pre>                        <span class="kwrd">&lt;</span><span class="html">asp:Label</span> <span class="attr">ID</span><span class="kwrd">=&quot;LabelYesOrNo&quot;</span> <span class="attr">runat</span><span class="kwrd">=&quot;server&quot;</span> </pre>

  <pre class="alt">                           <span class="attr">Text</span><span class="kwrd">='&lt;%# (bool) Eval(&quot;Approved&quot;) ? &quot;Yes&quot; : &quot;No&quot;  %&gt;'</span><span class="kwrd">&gt;&lt;/</span><span class="html">asp:Label</span><span class="kwrd">&gt;</span></pre>

  <pre>                    <span class="kwrd">&lt;/</span><span class="html">ItemTemplate</span><span class="kwrd">&gt;</span></pre>

  <pre class="alt">                <span class="kwrd">&lt;/</span><span class="html">asp:TemplateField</span><span class="kwrd">&gt;</span></pre>

  <pre>            <span class="kwrd">&lt;/</span><span class="html">Columns</span><span class="kwrd">&gt;</span></pre>

  <pre class="alt">        <span class="kwrd">&lt;/</span><span class="html">asp:GridView</span><span class="kwrd">&gt;</span></pre>

  <pre>    <span class="kwrd">&lt;/</span><span class="html">div</span><span class="kwrd">&gt;</span></pre>

  <pre class="alt">    <span class="kwrd">&lt;/</span><span class="html">form</span><span class="kwrd">&gt;</span></pre>

  <pre><span class="kwrd">&lt;/</span><span class="html">body</span><span class="kwrd">&gt;</span></pre>

  <pre class="alt"><span class="kwrd">&lt;/</span><span class="html">html</span><span class="kwrd">&gt;</span></pre>
</div>]]></content:encoded>
			<wfw:commentRss>http://peterkellner.net/2008/08/06/assign-label-in-aspdotnet-to-gridview-in-objectdatasource/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Assigning a DropDownList Value in a ASP.NET GridView Using ObjectDataSource</title>
		<link>http://peterkellner.net/2008/08/05/assign-dropdownlist-in-aspdotnet-to-gridview-in-objectdatasource/</link>
		<comments>http://peterkellner.net/2008/08/05/assign-dropdownlist-in-aspdotnet-to-gridview-in-objectdatasource/#comments</comments>
		<pubDate>Tue, 05 Aug 2008 23:57:14 +0000</pubDate>
		<dc:creator>Peter Kellner</dc:creator>
				<category><![CDATA[ASP.NET 3.5]]></category>
		<category><![CDATA[GridView]]></category>
		<category><![CDATA[ObjectDataSource]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://peterkellner.net/2008/08/05/assign-dropdownlist-in-aspdotnet-to-gridview-in-objectdatasource/</guid>
		<description><![CDATA[As a moderator in the asp.net forums, I often see the same or similar questions.&#160; The answer to this question is pretty straight forward but not 100% obvious so I thought I&#8217;d do a post about in the hopes that with a couple key words, people will find the answer.&#160; The title basically says it [...]]]></description>
			<content:encoded><![CDATA[<p>As a moderator in the <a href="http://forums.asp.net/">asp.net forums</a>, I often see the same or similar questions.&nbsp; The answer to this question is pretty straight forward but not 100% obvious so I thought I&#8217;d do a post about in the hopes that with a couple key words, people will find the answer.&nbsp; The title basically says it all.&nbsp; We have a GridView that has a data column of type bool.&nbsp; We want to display in the GridView Yes or No depending on whether the data value is true or false.&nbsp; The example I&#8217;m showing does not help with making this an editable field (maybe a theme for another post if this one is popular) but simply shows yes or no.</p> <p>The solution involves first dropping a <a href="http://msdn.microsoft.com/en-us/library/aa479339.aspx">GridView</a> and ObjectDataSource onto your design surface in Visual Studio.&nbsp; Then, using the little chevron on the GridView, choose edit columns and convert the column you are interested in making a <a href="http://www.w3schools.com/aspnet/control_dropdownlist.asp">DropDownList</a> into a template.&nbsp; From there replace the <a href="http://msdn.microsoft.com/en-us/library/aa479353.aspx">ItemTemplate</a> with the DropDownList code below.&nbsp; You get the code below.</p> <p>&nbsp;</p> <div class="csharpcode"><pre class="alt"><span class="asp">&lt;%@ Page Language="C#" %&gt;</span></pre><pre>&nbsp;</pre><pre class="alt"><span class="kwrd">&lt;!</span><span class="html">DOCTYPE</span> <span class="attr">html</span> <span class="attr">PUBLIC</span> <span class="kwrd">"-//W3C//DTD XHTML 1.0 Transitional//EN"</span> </pre><pre><span class="kwrd">"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"</span><span class="kwrd">&gt;</span></pre><pre class="alt">&nbsp;</pre><pre><span class="kwrd">&lt;</span><span class="html">script</span> <span class="attr">runat</span><span class="kwrd">="server"</span><span class="kwrd">&gt;</span></pre><pre class="alt">&nbsp;</pre><pre><span class="kwrd">&lt;/</span><span class="html">script</span><span class="kwrd">&gt;</span></pre><pre class="alt">&nbsp;</pre><pre><span class="kwrd">&lt;</span><span class="html">html</span> <span class="attr">xmlns</span><span class="kwrd">="http://www.w3.org/1999/xhtml"</span><span class="kwrd">&gt;</span></pre><pre class="alt"><span class="kwrd">&lt;</span><span class="html">head</span> <span class="attr">runat</span><span class="kwrd">="server"</span><span class="kwrd">&gt;</span></pre><pre>    <span class="kwrd">&lt;</span><span class="html">title</span><span class="kwrd">&gt;</span>ODS DDL Example<span class="kwrd">&lt;/</span><span class="html">title</span><span class="kwrd">&gt;</span></pre><pre class="alt"><span class="kwrd">&lt;/</span><span class="html">head</span><span class="kwrd">&gt;</span></pre><pre><span class="kwrd">&lt;</span><span class="html">body</span><span class="kwrd">&gt;</span></pre><pre class="alt">    <span class="kwrd">&lt;</span><span class="html">form</span> <span class="attr">id</span><span class="kwrd">="form1"</span> <span class="attr">runat</span><span class="kwrd">="server"</span><span class="kwrd">&gt;</span></pre><pre>    <span class="kwrd">&lt;</span><span class="html">div</span><span class="kwrd">&gt;</span></pre><pre class="alt">        <span class="kwrd">&lt;</span><span class="html">asp:ObjectDataSource</span> <span class="attr">ID</span><span class="kwrd">="ObjectDataSource1"</span> <span class="attr">runat</span><span class="kwrd">="server"</span> <span class="attr">SelectMethod</span><span class="kwrd">="GetMembers"</span></pre><pre>            <span class="attr">TypeName</span><span class="kwrd">="BusinessObject"</span><span class="kwrd">&gt;&lt;/</span><span class="html">asp:ObjectDataSource</span><span class="kwrd">&gt;</span></pre><pre class="alt">        <span class="kwrd">&lt;</span><span class="html">asp:GridView</span> <span class="attr">ID</span><span class="kwrd">="GridView1"</span> <span class="attr">runat</span><span class="kwrd">="server"</span> <span class="attr">AutoGenerateColumns</span><span class="kwrd">="False"</span> <span class="attr">DataKeyNames</span><span class="kwrd">="Id"</span></pre><pre>            <span class="attr">DataSourceID</span><span class="kwrd">="ObjectDataSource1"</span><span class="kwrd">&gt;</span></pre><pre class="alt">            <span class="kwrd">&lt;</span><span class="html">Columns</span><span class="kwrd">&gt;</span></pre><pre>                <span class="kwrd">&lt;</span><span class="html">asp:BoundField</span> <span class="attr">DataField</span><span class="kwrd">="Id"</span> <span class="attr">HeaderText</span><span class="kwrd">="Id"</span> <span class="attr">ReadOnly</span><span class="kwrd">="True"</span> <span class="attr">SortExpression</span><span class="kwrd">="Id"</span> <span class="kwrd">/&gt;</span></pre><pre class="alt">                <span class="kwrd">&lt;</span><span class="html">asp:BoundField</span> <span class="attr">DataField</span><span class="kwrd">="Name"</span> <span class="attr">HeaderText</span><span class="kwrd">="Name"</span> <span class="attr">SortExpression</span><span class="kwrd">="Name"</span> <span class="kwrd">/&gt;</span></pre><pre>                <span class="kwrd">&lt;</span><span class="html">asp:BoundField</span> <span class="attr">DataField</span><span class="kwrd">="Email"</span> <span class="attr">HeaderText</span><span class="kwrd">="Email"</span> <span class="attr">SortExpression</span><span class="kwrd">="Email"</span> <span class="kwrd">/&gt;</span></pre><pre class="alt">                <span class="kwrd">&lt;</span><span class="html">asp:TemplateField</span> <span class="attr">HeaderText</span><span class="kwrd">="Approved"</span> <span class="attr">SortExpression</span><span class="kwrd">="Approved"</span><span class="kwrd">&gt;</span></pre><pre>                    <span class="kwrd">&lt;</span><span class="html">ItemTemplate</span><span class="kwrd">&gt;</span></pre><pre class="alt">                        <span class="kwrd">&lt;</span><span class="html">asp:DropDownList</span> <span class="attr">ID</span><span class="kwrd">="DropDownListUser"</span> <span class="attr">runat</span><span class="kwrd">="server"</span> <span class="attr">AutoPostBack</span><span class="kwrd">="False"</span> </pre><pre>                            <span class="attr">SelectedValue</span><span class="kwrd">='&lt;%# Bind("Approved") %&gt;'</span><span class="kwrd">&gt;</span></pre><pre class="alt">                            <span class="kwrd">&lt;</span><span class="html">asp:ListItem</span> <span class="attr">Text</span><span class="kwrd">="Yes"</span> <span class="attr">Value</span><span class="kwrd">="True"</span><span class="kwrd">&gt;&lt;/</span><span class="html">asp:ListItem</span><span class="kwrd">&gt;</span></pre><pre>                            <span class="kwrd">&lt;</span><span class="html">asp:ListItem</span> <span class="attr">Text</span><span class="kwrd">="No"</span> <span class="attr">Value</span><span class="kwrd">="False"</span><span class="kwrd">&gt;&lt;/</span><span class="html">asp:ListItem</span><span class="kwrd">&gt;</span></pre><pre class="alt">                        <span class="kwrd">&lt;/</span><span class="html">asp:DropDownList</span><span class="kwrd">&gt;</span></pre><pre>                    <span class="kwrd">&lt;/</span><span class="html">ItemTemplate</span><span class="kwrd">&gt;</span></pre><pre class="alt">                <span class="kwrd">&lt;/</span><span class="html">asp:TemplateField</span><span class="kwrd">&gt;</span></pre><pre>            <span class="kwrd">&lt;/</span><span class="html">Columns</span><span class="kwrd">&gt;</span></pre><pre class="alt">        <span class="kwrd">&lt;/</span><span class="html">asp:GridView</span><span class="kwrd">&gt;</span></pre><pre>    <span class="kwrd">&lt;/</span><span class="html">div</span><span class="kwrd">&gt;</span></pre><pre class="alt">    <span class="kwrd">&lt;/</span><span class="html">form</span><span class="kwrd">&gt;</span></pre><pre><span class="kwrd">&lt;/</span><span class="html">body</span><span class="kwrd">&gt;</span></pre><pre class="
alt"><span class="kwrd">&lt;/</span><span class="html">html</span><span class="kwrd">&gt;</span></pre></div>
<style type="text/css">.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; }
</style>

<p>&nbsp;</p>
<p>And, when you run this code (assuming you have a simple business object that returns some data), you get this:</p>
<p>&nbsp;</p>
<p><a href="http://peterkellner.net/wp/wp-content/uploads/2008/08/x1.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="92" alt="x" src="http://peterkellner.net/wp/wp-content/uploads/2008/08/x-thumb1.png" width="314" border="0"/></a> </p>
<p>Hope this helps!</p>]]></content:encoded>
			<wfw:commentRss>http://peterkellner.net/2008/08/05/assign-dropdownlist-in-aspdotnet-to-gridview-in-objectdatasource/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>A Book Review of Manning&#8217;s Windows PowerShell In Action by Bruce Payette</title>
		<link>http://peterkellner.net/2008/04/07/windowspowershellbookreview/</link>
		<comments>http://peterkellner.net/2008/04/07/windowspowershellbookreview/#comments</comments>
		<pubDate>Mon, 07 Apr 2008 18:24:32 +0000</pubDate>
		<dc:creator>Peter Kellner</dc:creator>
				<category><![CDATA[.Net 2.0]]></category>
		<category><![CDATA[ASP.NET 3.5]]></category>
		<category><![CDATA[Book Reviews]]></category>

		<guid isPermaLink="false">http://peterkellner.net/2008/04/07/windowspowershellbookreview/</guid>
		<description><![CDATA[<p>A book review of Windows PowerShell in action by Bruce Payette</p>]]></description>
			<content:encoded><![CDATA[<p>Windows Powershell is something I&#8217;ve been meaning to learn for quite some time.&#160; It started out as the Monad Project at Microsoft and I remember seeing it discussed at Code Camps but never spending the time to go.&#160; I thought it was just another command.com with special commands.</p>  <p>Turns out, I was very wrong.&#160; As far as I&#8217;m concerned, it&#8217;s strength is that you can reference .net assemblies directly.&#160; That means, you can access everything in .Net just like a first class language.&#160; Be that C# or VB, you can get to all of it.&#160; You can write your own assemblies and reference them as well!&#160; It of course if fully object oriented, very rich, and full error handling.&#160; Very cool</p> <span id="more-108"></span>  <p>So, back to the book.&#160; Bruce Payett does a great job of introducing Windows Power Shell (aka Monad) and taking you step by step through the process of using it.&#160; He has lots of great examples and the book, as you would expect from a Manning book, is well indexed and well illustrated.&#160; I highly recommend getting it if you have not used Power Shell before.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:7dc1bd33-94bd-46fd-a20b-0131235bcd47:4b453b0a-941b-4fa3-8b07-226f562bbcab" class="wlWriterSmartContent">   <table border="0" cellspacing="0" cellpadding="2" width="400"><tbody>       <tr>         <td valign="top" width="400">           <p><a title="Windows PowerShell in Action" href="http://www.amazon.com/exec/obidos/ASIN/1932394907/petkelsblo-20"><img style="float: left" border="0" align="left" src="http://images.amazon.com/images/P/1932394907.01.MZZZZZZZ.jpg" />Windows PowerShell in Action</a></p>         </td>       </tr>     </tbody></table> </div>]]></content:encoded>
			<wfw:commentRss>http://peterkellner.net/2008/04/07/windowspowershellbookreview/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>In C#, When to use String verses string</title>
		<link>http://peterkellner.net/2007/12/29/incsharpwhentousestringversesstring/</link>
		<comments>http://peterkellner.net/2007/12/29/incsharpwhentousestringversesstring/#comments</comments>
		<pubDate>Sat, 29 Dec 2007 18:12:41 +0000</pubDate>
		<dc:creator>Peter Kellner</dc:creator>
				<category><![CDATA[.Net 2.0]]></category>
		<category><![CDATA[Best Practices]]></category>

		<guid isPermaLink="false">http://peterkellner.net/2007/12/29/incsharpwhentousestringversesstring/</guid>
		<description><![CDATA[<p>Just a short ramble on when to use string verses use String in C#.  Basically they compile to the same IL code</p>]]></description>
			<content:encoded><![CDATA[<p>So, technically, String and string mean exactly the same thing in C#.&#160; string, is an alias for String (aka a shorthand) for System.String.&#160; So, when should use which?&#160; It seems that the convention is to use string when you are referring to an object and String when you are referring specifically to the string class.</p> <p>This is basically what is said at this URL:&#160; <a title="http://en.csharp-online.net/CSharp_String_Theory%E2%80%94string_versus_String" href="http://en.csharp-online.net/CSharp_String_Theory%E2%80%94string_versus_String">http://en.csharp-online.net/CSharp_String_Theory%E2%80%94string_versus_String</a></p> <p>Juval Lowy has some coding standards at <a href="http://www.idesign.net">http://www.idesign.net</a> that says basically the same thing.&#160; From the document on IDesign&#8217;s web site the following examples show what is best practices (which I completely agree with).</p> <p><a href="/wp/wp-content/uploads/2007/12/idesign1.jpg"><img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="96" alt="idesign1" src="/wp/wp-content/uploads/2007/12/idesign1-thumb.jpg" width="244" border="0" /></a>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <a href="/wp/wp-content/uploads/2007/12/idesign2.jpg"><img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="144" alt="idesign2" src="/wp/wp-content/uploads/2007/12/idesign2-thumb.jpg" width="244" border="0" /></a></p> <p>That&#8217;s it for now.&#160;</p>]]></content:encoded>
			<wfw:commentRss>http://peterkellner.net/2007/12/29/incsharpwhentousestringversesstring/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Using Using in c# ado.net business classes used with ObjectDataSource in ASP.NET 2.0</title>
		<link>http://peterkellner.net/2007/10/29/usingusinghowto/</link>
		<comments>http://peterkellner.net/2007/10/29/usingusinghowto/#comments</comments>
		<pubDate>Tue, 30 Oct 2007 01:28:57 +0000</pubDate>
		<dc:creator>Peter Kellner</dc:creator>
				<category><![CDATA[.Net 2.0]]></category>
		<category><![CDATA[ASP.NET 2.0]]></category>
		<category><![CDATA[ObjectDataSource]]></category>

		<guid isPermaLink="false">http://peterkellner.net/2007/10/29/usingusinghowto/</guid>
		<description><![CDATA[A short post and example on how to use the C# syntax Using.  The example is for an ado.net business object that can be used with an ObjectDataSource.  This saves you the trouble of disposing of your objects properly, as well as doing it at the right place.]]></description>
			<content:encoded><![CDATA[<p>So, I&#8217;ve been preaching for a long time that it&#8217;s best to use the Using pattern when working with anything that implements IDisposable.&#160; That way, you don&#8217;t have to worry about calling Dispose, or calling Close.&#160; The framework will just do it for you.&#160; I&#8217;ve answered this question on the forums several times so I thought I&#8217;d past some code I&#8217;m doing right now for simple ado.net stuff.&#160; It&#8217;s actually code that is inside a business object that I hook up to an ObjectDataSource in asp.net 2.0. </p>  <p>The code is posted below.&#160; I think you&#8217;ll get the idea.</p> <span id="more-83"></span>  <p>[<span style="color: #2b91af">DataObjectMethod</span>(<span style="color: #2b91af">DataObjectMethodType</span>.Select, <span style="color: blue">false</span>)]</p>  <div style="font-family: courier new; background: white; color: black; font-size: 10pt">   <p style="margin: 0px"><span style="color: blue">public</span> <span style="color: #2b91af">List</span>&lt;<span style="color: #2b91af">DataObjectCategory</span>&gt; GetByPrimaryKey(<span style="color: blue">int</span> id)</p>    <p style="margin: 0px">{</p>    <p style="margin: 0px"><span style="color: blue">string</span> sqlWhere = <span style="color: #2b91af">String</span>.Format(<span style="color: #a31515">&quot; WHERE id={0} &quot;</span>, id);</p>    <p style="margin: 0px"><span style="color: blue">return</span> GetByRawSQL(<span style="color: blue">string</span>.Empty, sqlWhere);</p>    <p style="margin: 0px">}</p>    <p style="margin: 0px">&#160;</p>    <p style="margin: 0px"><span style="color: blue">private</span> <span style="color: #2b91af">List</span>&lt;<span style="color: #2b91af">DataObjectCategory</span>&gt; GetByRawSQL(<span style="color: blue">string</span> sortData, <span style="color: blue">string</span> sqlWhereClause)</p>    <p style="margin: 0px">{</p>    <p style="margin: 0px"><span style="color: blue">string</span> sqlBaseString = <span style="color: #a31515">&quot;SELECT ContentTypeId,Description,SortOrder,Id FROM Category &quot;</span>;</p>    <p style="margin: 0px"><span style="color: #2b91af">List</span>&lt;<span style="color: #2b91af">DataObjectCategory</span>&gt; DataTemplateODSList = <span style="color: blue">new</span> <span style="color: #2b91af">List</span>&lt;<span style="color: #2b91af">DataObjectCategory</span>&gt;();</p>    <p style="margin: 0px"><span style="color: blue">using</span> (<span style="color: #2b91af">SqlConnection</span> conn = <span style="color: blue">new</span> <span style="color: #2b91af">SqlConnection</span>(connectionString))</p>    <p style="margin: 0px">{</p>    <p style="margin: 0px">&#160;&#160;&#160; conn.Open();</p>    <p style="margin: 0px">&#160;&#160;&#160; <span style="color: blue">if</span> (!<span style="color: #2b91af">String</span>.IsNullOrEmpty(sqlWhereClause))</p>    <p style="margin: 0px">&#160;&#160;&#160; {</p>    <p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; sqlBaseString += sqlWhereClause;</p>    <p style="margin: 0px">&#160;&#160;&#160; }</p>    <p style="margin: 0px">&#160;&#160;&#160; <span style="color: blue">using</span> (<span style="color: #2b91af">SqlCommand</span> cmd = <span style="color: blue">new</span> <span style="color: #2b91af">SqlCommand</span>(sqlBaseString, conn))</p>    <p style="margin: 0px">&#160;&#160;&#160; {</p>    <p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">using</span> (<span style="color: #2b91af">SqlDataReader</span> reader = cmd.ExecuteReader())</p>    <p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>    <p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">try</span></p>    <p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>    <p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">while</span> (reader.Read())</p>    <p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>    <p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">int</span> contenttypeid = reader.IsDBNull(0) ? 0 : reader.GetInt32(0);</p>    <p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">string</span> description = reader.IsDBNull(1) ? <span style="color: #a31515">&quot;&quot;</span> : reader.GetString(1);</p>    <p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">int</span> sortorder = reader.IsDBNull(2) ? 0 : reader.GetInt32(2);</p>    <p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">int</span> id = reader.IsDBNull(3) ? 0 : reader.GetInt32(3);</p>    <p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #2b91af">DataObjectCategory</span> td = <span style="color: blue">new</span> <span style="color: #2b91af">DataObjectCategory</span>(contenttypeid,</p>    <p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; description, sortorder, id);</p>    <p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; DataTemplateODSList.Add(td);</p>    <p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>    <p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>    <p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">catch</span> (<span style="color: #2b91af">Exception</span> ee)</p>    <p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>    <p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">throw</span> <span style="color: blue">new</span> <span style="color: #2b91af">ApplicationException</span>(ee.ToString());</p>    <p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>    <p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>    <p style="margin: 0px">&#160;&#160;&#160; }</p>    <p style="margin: 0px">}</p> </div>  <p>Hope this helps!</p>]]></content:encoded>
			<wfw:commentRss>http://peterkellner.net/2007/10/29/usingusinghowto/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to Set the Default Value of a DropDownList in an ASP.NET Page</title>
		<link>http://peterkellner.net/2007/10/17/dropdownlistdefaultsetting/</link>
		<comments>http://peterkellner.net/2007/10/17/dropdownlistdefaultsetting/#comments</comments>
		<pubDate>Wed, 17 Oct 2007 17:44:13 +0000</pubDate>
		<dc:creator>Peter Kellner</dc:creator>
				<category><![CDATA[.Net 2.0]]></category>
		<category><![CDATA[ASP.NET 2.0]]></category>
		<category><![CDATA[Membership]]></category>
		<category><![CDATA[ObjectDataSource]]></category>

		<guid isPermaLink="false">http://peterkellner.net/2007/10/17/dropdownlistdefaultsetting/</guid>
		<description><![CDATA[<p> This article shows how to set the default Value of a DropDownList Control when using asp.net 2.0.  It uses the DataBound event to do it.  A full page example which can be cut and paste is included</p>]]></description>
			<content:encoded><![CDATA[<h2>(Using Membership ObjectDataSource From MSDN Article)</h2>  <p>I&#8217;m doing a project where I have lots of DropDownList&#8217;s on a page and want a simple way to set the initial values based on some known value.&#160; The DropDownLists are retrieved using ObjectDataSource but I don&#8217;t want the first value displayed.&#160; I wrestled some with how to do this using page_load or page_prerender but didn&#8217;t come up with good solutions.&#160; I did finally    <br />decide that programming the databound event of the dropdownlist was probably the best way to go. </p>  <p>The solution is pasted below.&#160; The MembershipUtilities.MembershipODS c# code can be downloaded from MSDN or on my web site at the following location.&#160; <br /></p> <span id="more-80"></span>  <p><a href="/2006/01/09/microsoft-aspnet-20-memberrole-management-with-iis/">http://peterkellner.net/2006/01/09/microsoft-aspnet-20-memberrole-management-with-iis/</a>.</p> <!-- code formatted by http://manoli.net/csharpformat/ --><style type="text/css">


.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; }</style>  <pre class="csharpcode"><span class="asp">&lt;%@ Page Language=”C#” %&gt;</span>
<span class="kwrd">&lt;!</span><span class="html">DOCTYPE</span> <span class="attr">html</span> <span class="attr">PUBLIC</span> “<span class="attr">-</span>//<span class="attr">W3C</span>//<span class="attr">DTD</span> <span class="attr">XHTML</span> <span class="attr">1</span>.<span class="attr">0</span> <span class="attr">Transitional</span>//<span class="attr">EN</span>”

  “<span class="attr">http:</span>//<span class="attr">www</span>.<span class="attr">w3</span>.<span class="attr">org</span>/<span class="attr">TR</span>/<span class="attr">xhtml1</span>/<span class="attr">DTD</span>/<span class="attr">xhtml1-transitional</span>.<span class="attr">dtd</span>”<span class="kwrd">&gt;</span>

<span class="kwrd">&lt;</span><span class="html">script</span> <span class="attr">runat</span>=”<span class="attr">server</span>”<span class="kwrd">&gt;</span>
    <span class="kwrd">protected</span> <span class="kwrd">void</span> DropDownListUser_DataBound(<span class="kwrd">object</span> sender, EventArgs e)

    {
        DropDownListUser.SelectedIndex =
          DropDownListUser.Items.IndexOf
          (DropDownListUser.Items.FindByValue(Context.User.Identity.Name));
    }
<span class="kwrd">&lt;/</span><span class="html">script</span><span class="kwrd">&gt;</span>
 
<span class="kwrd">&lt;</span><span class="html">html</span> <span class="attr">xmlns</span>=”<span class="attr">http:</span>//<span class="attr">www</span>.<span class="attr">w3</span>.<span class="attr">org</span>/<span class="attr">1999</span>/<span class="attr">xhtml</span>” <span class="kwrd">&gt;</span>
<span class="kwrd">&lt;</span><span class="html">head</span> <span class="attr">runat</span>=”<span class="attr">server</span>”<span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;</span><span class="html">title</span><span class="kwrd">&gt;</span>DropDownList Initialize<span class="kwrd">&lt;/</span><span class="html">title</span><span class="kwrd">&gt;</span>
<span class="kwrd">&lt;/</span><span class="html">head</span><span class="kwrd">&gt;</span>
<span class="kwrd">&lt;</span><span class="html">body</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;</span><span class="html">form</span> <span class="attr">id</span>=”<span class="attr">form1</span>″ <span class="attr">runat</span>=”<span class="attr">server</span>”<span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;</span><span class="html">div</span><span class="kwrd">&gt;</span>
        <span class="kwrd">&lt;</span><span class="html">asp:DropDownList</span> <span class="attr">ID</span>=”<span class="attr">DropDownListUser</span>” <span class="attr">runat</span>=”<span class="attr">server</span>”
          <span class="attr">DataSourceID</span>=”<span class="attr">ObjectDataSourceUser</span>”
          <span class="attr">DataTextField</span>=”<span class="attr">UserName</span>” <span class="attr">DataValueField</span>=”<span class="attr">UserName</span>”
          <span class="attr">OnDataBound</span>=”<span class="attr">DropDownListUser_DataBound</span>”<span class="kwrd">&gt;</span>
        <span class="kwrd">&lt;/</span><span class="html">asp:DropDownList</span><span class="kwrd">&gt;</span>
        <span class="kwrd">&lt;</span><span class="html">asp:ObjectDataSource</span> <span class="attr">ID</span>=”<span class="attr">ObjectDataSourceUser</span>” <span class="attr">runat</span>=”<span class="attr">server</span>”
          <span class="attr">SelectMethod</span>=”<span class="attr">GetMembers</span>”
          <span class="attr">TypeName</span>=”<span class="attr">MembershipUtilities</span>.<span class="attr">MembershipUserODS</span>”<span class="kwrd">&gt;</span>
            <span class="kwrd">&lt;</span><span class="html">SelectParameters</span><span class="kwrd">&gt;</span>
                <span class="kwrd">&lt;</span><span class="html">asp:Parameter</span> <span class="attr">Name</span>=”<span class="attr">sortData</span>” <span class="attr">Type</span>=”<span class="attr">String</span>” <span class="kwrd">/&gt;</span>
            <span class="kwrd">&lt;/</span><span class="html">SelectParameters</span><span class="kwrd">&gt;</span>
        <span class="kwrd">&lt;/</span><span class="html">asp:ObjectDataSource</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;/</span><span class="html">div</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;/</span><span class="html">form</span><span class="kwrd">&gt;</span>
<span class="kwrd">&lt;/</span><span class="html">body</span><span class="kwrd">&gt;</span>
<span class="kwrd">&lt;/</span><span class="html">html</span><span class="kwrd">&gt;</span></pre>]]></content:encoded>
			<wfw:commentRss>http://peterkellner.net/2007/10/17/dropdownlistdefaultsetting/feed/</wfw:commentRss>
		<slash:comments>22</slash:comments>
		</item>
		<item>
		<title>Silicon Valley Code Camp Integrates the DevExpress Cloud Control for Sessions</title>
		<link>http://peterkellner.net/2007/09/04/cloudcontrolforcodecamp/</link>
		<comments>http://peterkellner.net/2007/09/04/cloudcontrolforcodecamp/#comments</comments>
		<pubDate>Tue, 04 Sep 2007 19:11:58 +0000</pubDate>
		<dc:creator>Peter Kellner</dc:creator>
				<category><![CDATA[ASP.NET 2.0]]></category>
		<category><![CDATA[Atlas/AJAX]]></category>
		<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[Community]]></category>
		<category><![CDATA[ObjectDataSource]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://peterkellner.net/2007/09/04/cloudcontrolforcodecamp/</guid>
		<description><![CDATA[Using the DevExpress CloudControl in the ASP.NET 2.0 Silicon Valley Code Camp's web site was easy.  In this short post, you'll hear about the details and see some code.]]></description>
			<content:encoded><![CDATA[<p>Recently, is seems that many web sites and blogs are starting to use a navigation technique where you have multiple hyperlinks grouped in a box, with size, color, or brightness giving some meaning.&#160; I like this very much and have been on the lookout for a while for a control to do this in ASP.NET.&#160; Turns out, DevExpress has one!&#160; It&#8217;s called the CloudControl and you can read more about it at the following URL.</p> <span id="more-74"></span>  <p>&#160;<a href="http://www.devexpress.com/Products/NET/WebForms/ASPxCloudControl/Index.xml">http://www.devexpress.com/Products/NET/WebForms/ASPxCloudControl/Index.xml</a></p>  <p>So, now, where to use it?&#160; Code Camp of course!&#160; Now, if you browse to the Sessions listing, you&#8217;ll see the DevExpress Cloud Control in use.</p>  <p><img alt="Silicon Valley Code Camp Cloud Control" src="http://peterkellner.net/wp/Images/misc/cloudcontrol.jpg" /></p>  <p>You can see this control in action at our web site here:&#160; <br /><a href="http://www.siliconvalley-codecamp.com/Sessions.aspx">     <br />http://www.siliconvalley-codecamp.com/Sessions.aspx</a></p>  <p>My experience with using this control was great!&#160; Easy to setup.&#160; Below is all the code I needed on my asp page to make it happen.</p>  <p>&#160;<!--<br />
{\rtf1\ansi\ansicpg\lang1024\noproof1252\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue255;\red255\green255\blue255;\red163\green21\blue21;\red0\green0\blue0;\red255\green0\blue0;}??\fs20 \cf1 &lt;\cf3 dxcc\cf1 :\cf3 ASPxCloudControl\cf0  \cf5 ID\cf1 =&#8221;ASPxCloudControl1&#8243;\cf0  \cf5 runat\cf1 =&#8221;server&#8221;\cf0  \par ??           \cf5 DataSourceID\cf1 =&#8221;ObjectDataSourceCloudControl&#8221;\cf0  \cf5 ShowValues\cf1 =&#8221;True&#8221;\cf0  \par ??           \cf5 HorizontalAlign\cf1 =&#8221;NotSet&#8221;\cf0  \cf5 TextField\cf1 =&#8221;TagName&#8221;\cf0  \cf5 ValueField\cf1 =&#8221;TagCount&#8221;\cf0  \par ??           \cf5 NavigateUrlField\cf1 =&#8221;TagId&#8221;\cf0  \par ??           \cf5 NavigateUrlFormatString\cf1 =&#8221;Sessions.aspx?sortby=title&amp;by=category&amp;tag=\{0\}&#8221;\cf0  \par ??           \cf5 ToolTip\cf1 =&#8221;CloudControl Provided From DevExpress&#8221;&gt;\par ??\cf0                 \cf1 &lt;\cf3 RankProperties\cf1 &gt;\par ??\cf0                     \cf1 &lt;\cf3 dxcc\cf1 :\cf3 RankProperties\cf0  \cf1 /&gt;\par ??\cf0                     \cf1 &lt;\cf3 dxcc\cf1 :\cf3 RankProperties\cf0  \cf1 /&gt;\par ??\cf0                     \cf1 &lt;\cf3 dxcc\cf1 :\cf3 RankProperties\cf0  \cf1 /&gt;\par ??\cf0                     \cf1 &lt;\cf3 dxcc\cf1 :\cf3 RankProperties\cf0  \cf1 /&gt;\par ??\cf0                     \cf1 &lt;\cf3 dxcc\cf1 :\cf3 RankProperties\cf0  \cf1 /&gt;\par ??\cf0                     \cf1 &lt;\cf3 dxcc\cf1 :\cf3 RankProperties\cf0  \cf1 /&gt;\par ??\cf0                     \cf1 &lt;\cf3 dxcc\cf1 :\cf3 RankProperties\cf0  \cf1 /&gt;\par ??\cf0                 \cf1 &lt;/\cf3 RankProperties\cf1 &gt;\par ??\cf0         \cf1 &lt;/\cf3 dxcc\cf1 :\cf3 ASPxCloudControl\cf1 &gt;\par ??\cf0         \cf1 &lt;\cf3 asp\cf1 :\cf3 ObjectDataSource\cf0  \cf5 ID\cf1 =&#8221;ObjectDataSourceCloudControl&#8221;\cf0  \cf5 runat\cf1 =&#8221;server&#8221;\cf0  \par ??            \cf5 SelectMethod\cf1 =&#8221;GetAllTags&#8221;\cf0  \cf5 TypeName\cf1 =&#8221;CodeCampSV.SessionTagsODS&#8221;&gt;\par ??\cf0         \cf1 &lt;/\cf3 asp\cf1 :\cf3 ObjectDataSource\cf1 &gt;}<br />
&#8211;></p>  <div style="font-family: courier new; background: white; color: black; font-size: 10pt">   <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 52</span>&#160;<span style="color: blue">&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;</span><span style="color: #a31515">dxcc</span><span style="color: blue">:</span><span style="color: #a31515">ASPxCloudControl</span> <span style="color: red">ID</span><span style="color: blue">=&quot;ASPxCloudControl1&quot;</span> <span style="color: red">runat</span><span style="color: blue">=&quot;server&quot;</span></p>    <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 53</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: red">DataSourceID</span><span style="color: blue">=&quot;ObjectDataSourceCloudControl&quot;</span> <span style="color: red">ShowValues</span><span style="color: blue">=&quot;True&quot;</span></p>    <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 54</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: red">HorizontalAlign</span><span style="color: blue">=&quot;NotSet&quot;</span> <span style="color: red">TextField</span><span style="color: blue">=&quot;TagName&quot;</span> <span style="color: red">ValueField</span><span style="color: blue">=&quot;TagCount&quot;</span></p>    <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 55</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: red">NavigateUrlField</span><span style="color: blue">=&quot;TagId&quot;</span></p>    <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 56</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: red">NavigateUrlFormatString</span><span style="color: blue">=&quot;Sessions.aspx?sortby=title&amp;by=category&amp;tag={0}&quot;</span></p>    <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 57</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: red">ToolTip</span><span style="color: blue">=&quot;CloudControl Provided From DevExpress&quot;&gt;</span></p>    <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 58</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">&lt;</span><span style="color: #a31515">RankProperties</span><span style="color: blue">&gt;</span></p>    <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 59</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">&lt;</span><span style="color: #a31515">dxcc</span><span style="color: blue">:</span><span style="color: #a31515">RankProperties</span> <span style="color: blue">/&gt;</span></p>    <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 60</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">&lt;</span><span style="color: #a31515">dxcc</span><span style="color: blue">:</span><span style="color: #a31515">RankProperties</span> <span style="color: blue">/&gt;</span></p>    <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 61</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">&lt;</span><span style="color: #a31515">dxcc</span><span style="color: blue">:</span><span style="color: #a31515">RankProperties</span> <span style="color: blue">/&gt;</span></p>    <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 62</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">&lt;</span><span style="color: #a31515">dxcc</span><span style="color: blue">:</span><span style="color: #a31515">RankProperties</span> <span style="color: blue">/&gt;</span></p>    <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 63</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">&lt;</span><span style="color: #a31515">dxcc</span><span style="color: blue">:</span><span style="color: #a31515">RankProperties</span> <span style="color: blue">/&gt;</span></p>    <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 64</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">&lt;</span><span style="color: #a31515">dxcc</span><span style="color: blue">:</span><span style="color: #a31515">RankProperties</span> <span style="color: blue">/&gt;</span></p>    <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 65</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">&lt;</span><span style="color: #a31515">dxcc</span><span style="color: blue">:</span><span style="color: #a31515">RankProperties</span> <span style="color: blue">/&gt;</span></p>    <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 66</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">&lt;/</span><span style="color: #a31515">RankProperties</span><span style="color: blue">&gt;</span></p>    <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 67</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">&lt;/</span><span style="color: #a31515">dxcc</span><span style="color: blue">:</span><span style="color: #a31515">ASPxCloudControl</span><span style="color: blue">&gt;</span></p>    <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 68</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">&lt;</span><span style="color: #a31515">asp</span><span style="color: blue">:</span><span style="color: #a31515">ObjectDataSource</span> <span style="color: red">ID</span><span style="color: blue">=&quot;ObjectDataSourceCloudControl&quot;</span> <span style="color: red">runat</span><span style="color: blue">=&quot;server&quot;</span></p>    <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 69</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: red">SelectMethod</span><span style="color: blue">=&quot;GetAllTags&quot;</span> <span style="color: red">TypeName</span><span style="color: blue">=&quot;CodeCampSV.SessionTagsODS&quot;&gt;</span></p>    <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 70</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">&lt;/</span><span style="color: #a31515">asp</span><span style="color: blue">:</span><span style="color: #a31515">ObjectDataSource</span><span style="color: blue">&gt;</span></p> </div>  <p style="margin: 0px">&#160;</p>  <p style="margin: 0px">This is my first trip into the Developer Express toolbox and so far, I&#8217;m very impressed!</p>]]></content:encoded>
			<wfw:commentRss>http://peterkellner.net/2007/09/04/cloudcontrolforcodecamp/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Logging From an ASP.NET 2.0 Application to a Local File</title>
		<link>http://peterkellner.net/2007/08/12/aspnetsimplelogging/</link>
		<comments>http://peterkellner.net/2007/08/12/aspnetsimplelogging/#comments</comments>
		<pubDate>Mon, 13 Aug 2007 00:54:36 +0000</pubDate>
		<dc:creator>Peter Kellner</dc:creator>
				<category><![CDATA[.Net 2.0]]></category>
		<category><![CDATA[ASP.NET 2.0]]></category>

		<guid isPermaLink="false">http://peterkellner.net/2007/08/12/aspnetsimplelogging/</guid>
		<description><![CDATA[<br />In this article, a very simple method is demonstrated for logging text data in an asp.net 2.0 application.  It's safe, reliable, but not very elegant.  Just what you need when you want to crank something out for testing or proof of concept.  It uses StreamWriter and MapPath to get it's job done.]]></description>
			<content:encoded><![CDATA[<p><strong>(User MapPath and FileStream Together)</strong></p>  <p>A very common scenario we often run into is we need to log some information to a local text file on the web server.&#160; We know we can use all the health monitoring capabilities built in to asp.net for reasons like performance,   <br />standards, best practices, etc., but sometimes, you just want to log something right now and you don&#8217;t want to spend a lot of time.</p> <span id="more-72"></span>  <p>So, Here is a very very simple version that does that and is 100% reliable.&#160; Basically, say you wanted to simply log the useragent from a request to a file called ~/App_Data/UserAgents.txt.&#160; Here is some simple code to do that.</p>    <div style="font-family: courier new; background: white; color: black; font-size: 10pt">   <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160;&#160; 1</span>&#160;<span style="color: blue">using</span> System;</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160;&#160; 2</span>&#160;<span style="color: blue">using</span> System.Data;</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160;&#160; 3</span>&#160;<span style="color: blue">using</span> System.Configuration;</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160;&#160; 4</span>&#160;<span style="color: blue">using</span> System.Collections;</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160;&#160; 5</span>&#160;<span style="color: blue">using</span> System.Web;</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160;&#160; 6</span>&#160;<span style="color: blue">using</span> System.Web.Security;</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160;&#160; 7</span>&#160;<span style="color: blue">using</span> System.Web.UI;</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160;&#160; 8</span>&#160;<span style="color: blue">using</span> System.Web.UI.WebControls;</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160;&#160; 9</span>&#160;<span style="color: blue">using</span> System.Web.UI.WebControls.WebParts;</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 10</span>&#160;<span style="color: blue">using</span> System.Web.UI.HtmlControls;</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 11</span>&#160;</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 12</span>&#160;<span style="color: blue">public</span> <span style="color: blue">partial</span> <span style="color: blue">class</span> <span style="color: #2b91af">Default2</span> : System.Web.UI.<span style="color: #2b91af">Page</span></p>    <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 13</span> {</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 14</span>&#160;</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 15</span>&#160;&#160;&#160;&#160; <span style="color: blue">public</span> <span style="color: blue">static</span> <span style="color: #2b91af">Object</span> synchronizeVariable = <span style="color: #a31515">&quot;locking&quot;</span>;</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 16</span>&#160;</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 17</span>&#160;&#160;&#160;&#160; <span style="color: blue">protected</span> <span style="color: blue">void</span> Page_Load(<span style="color: blue">object</span> sender, <span style="color: #2b91af">EventArgs</span> e)</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 18</span>&#160;&#160;&#160;&#160; {</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 19</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #2b91af">String</span> fileName = Context.Server.MapPath(<span style="color: #a31515">&quot;~&quot;</span>) +</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 20</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #a31515">&quot;\\App_Data\\UserAgents.txt&quot;</span>;</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 21</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">lock</span> (synchronizeVariable)</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 22</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 23</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; StreamWriter sw = <span style="color: blue">new</span> StreamWriter(fileName, <span style="color: blue">true</span>);</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 24</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; sw.WriteLine(<span style="color: #2b91af">DateTime</span>.Now);</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 25</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; sw.WriteLine(Request.UserAgent);</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 26</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; sw.Close();</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 27</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 28</span>&#160;&#160;&#160;&#160; }</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 29</span> }</p> </div>  <p>Just to be safe, we added a lock around the file write code.&#160; This way, if two processes come in at the same time, they will both write out correctly. Again, this is very crude, not very efficient or elegant, but very clean and   <br />reliable.&#160; Just don&#8217;t mention you got it from me!</p>]]></content:encoded>
			<wfw:commentRss>http://peterkellner.net/2007/08/12/aspnetsimplelogging/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Always Set Stop On Exception While Doing Debugging in Visual Studio 2005 or 2008</title>
		<link>http://peterkellner.net/2007/08/10/stoponexceptionvs/</link>
		<comments>http://peterkellner.net/2007/08/10/stoponexceptionvs/#comments</comments>
		<pubDate>Fri, 10 Aug 2007 16:05:12 +0000</pubDate>
		<dc:creator>Peter Kellner</dc:creator>
				<category><![CDATA[.Net 2.0]]></category>
		<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://peterkellner.net/2007/08/10/stoponexceptionvs/</guid>
		<description><![CDATA[<p>This article discusses a best practices method for automatically having the debugger stop on unhandled exceptions in visual studio 2005 or 2008</p>]]></description>
			<content:encoded><![CDATA[<p>One of the tricks I&#8217;ve learned over time is to always set visual studio to stop on a thrown exception.&#160; Normally, during running of a .net application, unhandled exceptions are simply processed and absorbed quietly.&#160; For the most part, this is good because you do not want your users to see error messages all the time, and likely what is being thrown is not interesting anyhow.&#160; It is however bad because throwing exceptions is very time consuming for the application as well as it may actually be something important.</p>  <p>To keep this from happening, my &quot;best practice&quot; is to go into the menu choice Debug/Exceptions as follows:</p>  <p><img alt="Debug Excetpion Menu Choice" src="http://peterkellner.net/wp/Images/misc/vsexceptions1.jpg" /></p> <span id="more-71"></span>  <p>Then, you will get the following dialog.&#160; Make sure to check everything as show below:</p>  <p><img alt="Debug Excetpion Menu Choice" src="http://peterkellner.net/wp/Images/misc/vsexceptions.jpg" /></p>  <p>Then, when you hit an exception while debugging, the debugger will stop on the offending line so you can figure out if you should be surrounding this with a try/catch, or whether it&#8217;s just an oversight you need to fix.</p>  <p>Good luck with this!&#160; It&#8217;s helped me a huge amount in finding bugs I would have likely found later and much more painfully.</p>]]></content:encoded>
			<wfw:commentRss>http://peterkellner.net/2007/08/10/stoponexceptionvs/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>TechEd Orlando, Visual Studio Tracing Tricks</title>
		<link>http://peterkellner.net/2007/06/04/teched2007a/</link>
		<comments>http://peterkellner.net/2007/06/04/teched2007a/#comments</comments>
		<pubDate>Mon, 04 Jun 2007 16:48:20 +0000</pubDate>
		<dc:creator>Peter Kellner</dc:creator>
				<category><![CDATA[.Net 2.0]]></category>

		<guid isPermaLink="false">http://peterkellner.net/2007/06/04/teched2007a/</guid>
		<description><![CDATA[Day 1 at Teched in Orlando has been great so far.  My helper, Steve Carroll, and a cool Visual Studio tip for doing tracking while debugging is explained.

<br />
<img src="http://peterkellner.net/wp/Images/misc/teched20071.jpg" alt="Peter Kellner and Steve Carroll of Microsoft" />]]></description>
			<content:encoded><![CDATA[<h2>TechEd 2007, Orlando</h2>  <p>Visual Studio Debug/Trace Tricks From the Learning Center With Steve Carol</p>  <p>I love these meetings!&#160; I have to admit that I come not for the sessions, but for the learning center.&#160; At the moment I&#8217;m working on a .net Silverlight application and I&#8217;ve got lots of problems.&#160; What I do is put the mark $$$ in my code in all the places where I&#8217;m having problems.&#160; I trek over to the learning center area and sit down with a Microsoft engineer who is willing to tolerate me.&#160; Today, the guy was Steve Carroll who I believe is a manager on the visual studio performance team.&#160; Score!&#160; Big time help, and some bonuses also.&#160; Steve didn&#8217;t really know anything about WPF   <br />or Silverlight but knows c# very very well.&#160; I asked him if he was a c# wizard at the start and he said no.&#160; He was very wrong about that.</p> <span id="more-63"></span>  <p>So, here we are, all smiles.</p>  <p><img alt="Peter Kellner and Steve Carroll of Microsoft" src="http://peterkellner.net/wp/Images/misc/teched20071.jpg" /></p>  <p>So, not only did I get huge help, but Steve showed me some very cool tricks.&#160; Specifically how to turn trace output on in the debugger.&#160; Basically, you go to the debug point you set, right mouse button on it and you get this menu, you choose &quot;When Hit&quot;.</p>  <p><img alt="Right Mouse on Break Point" src="http://peterkellner.net/wp/Images/misc/teched20072.jpg" /></p>  <p>Then, you get the following dialog where you put stuff you want to get displayed when the point gets hit (without stopping).&#160; Basically, it logs it all to the output window.&#160; You can put your own variables in parenthesis, or any text you want.</p>  <p><img alt="The When Hit Window" src="http://peterkellner.net/wp/Images/misc/teched20073.jpg" /></p>  <p>Awesome feature!&#160;&#160; Now, I&#8217;ve given a little back after learning so much.&#160; Four and half days left!</p>]]></content:encoded>
			<wfw:commentRss>http://peterkellner.net/2007/06/04/teched2007a/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Microsoft ASP.NET Member/Role Management with IIS (VB Version)</title>
		<link>http://peterkellner.net/2007/02/15/membershipodsvb/</link>
		<comments>http://peterkellner.net/2007/02/15/membershipodsvb/#comments</comments>
		<pubDate>Thu, 15 Feb 2007 20:08:16 +0000</pubDate>
		<dc:creator>Peter Kellner</dc:creator>
				<category><![CDATA[ASP.NET 2.0]]></category>
		<category><![CDATA[ObjectDataSource]]></category>

		<guid isPermaLink="false">http://peterkellner.net/2007/02/15/membershipodsvb/</guid>
		<description><![CDATA[<p>Back in January of 2006, I published on
<a href="http://peterkellner.net/2006/01/09/microsoft-aspnet-20-memberrole-management-with-iis/">
MSDN an article and source code for managing ASP.NET 2.0 Membership users with
an ObjectDataSource.</a>&#160; Since I&#39;m not much of a VB person, I only
published them in c#.&#160; since then, I&#39;ve had hundreds of requests for this
code in VB.&#160; Until now, I&#39;ve had to send an excuse for not having it.&#160;
Now, thanks to Dave at <a href="http://www.tangiblesoftwaresolutions.com/">
Tangible Solutions Software</a>,
we now have a VB version.</p>]]></description>
			<content:encoded><![CDATA[<h2>The Visual Basic Version of the Objects!</h2>  <p>Back in January of 2006, I published on <a href="/2006/01/09/microsoft-aspnet-20-memberrole-management-with-iis/">MSDN an article and source code for managing ASP.NET 2.0 Membership users with an ObjectDataSource.</a>&#160; Since I&#8217;m not much of a VB person, I only published them in c#.&#160; since then, I&#8217;ve had hundreds of requests for this code in VB.&#160; Until now, I&#8217;ve had to send an excuse for not having it. Now, thanks to Dave at&#160; <a href="http://www.tangiblesoftwaresolutions.com/">Tangible Solutions Software</a>, we now have a VB version.&#160; Dave converted it with there conversion software called <em>Instant VB</em>.</p>  <p class="style1">The following zip file includes these VB objects along with a very simple aspx page in VB.&#160; It does not include any more complete examples of using the objects because the code associated with the aspx pages I wrote is all in c#.&#160; If anyone wants to convert the other pages, I&#8217;d be happy to post those also.</p>  <p class="style1">Thanks Dave and Thanks Tangible Solutions!    <br /><a href="/DownLoads/MembershipEditorVB.zip">     <br />http://peterkellner.net/DownLoads/MembershipEditorVB.zip</a></p>]]></content:encoded>
			<wfw:commentRss>http://peterkellner.net/2007/02/15/membershipodsvb/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Rock And Roll Code Camp Presentation</title>
		<link>http://peterkellner.net/2007/02/01/codecampla07/</link>
		<comments>http://peterkellner.net/2007/02/01/codecampla07/#comments</comments>
		<pubDate>Fri, 02 Feb 2007 02:13:27 +0000</pubDate>
		<dc:creator>Peter Kellner</dc:creator>
				<category><![CDATA[ASP.NET 2.0]]></category>
		<category><![CDATA[Community]]></category>
		<category><![CDATA[ObjectDataSource]]></category>

		<guid isPermaLink="false">http://peterkellner.net/2007/02/01/codecampla07/</guid>
		<description><![CDATA[Code Camp Presentation at LA's Rock and Roll Code Camp.  Lots of nuts and bolts about using ObjectDataSoruce including a real life
example using the enterprise data block.]]></description>
			<content:encoded><![CDATA[<p><strong>Rock And Roll Code Camp in Los Angeles Presentation</strong></p>  <p>This is the first time I&#8217;ve presented this material. I&#8217;ve presented on several previous occassions the basic    <br />material on how to build an ObjectDataSource class from scratch but this time was different. Inspired by people     <br />often asking me &quot;what good is the ObjectDataSource&quot;, I decided to create a useful example. Since the ObjectDataSource is inherently a complex abstraction, creating a real life demo that can be presented in a short amount of time is a challenge. In this presntation, I hopefully rose to the challenge. Below is the abstract along with the URL to the actual codecamp. Below that is a link to the project that was created at class for     <br />anyone interested in seeing the material.</p> <span id="more-47"></span>  <p>Lots of nuts and bolts about using ObjectDataSoruce including a real life example using the enterprise data block (NetTiers and CodeSmith).</p>  <p><a href="http://www.socalcodecamp.com/session.aspx?sid=20a9c60e-9193-47bb-aed1-d756afbbd730">     <br />Build an ASP.NET 2.0 ObjectDataSource From Scratch and Use it with a DAL (NetTiers)</a></p>  <p><a href="http://www.socalcodecamp.com/sessions.aspx">     <br />http://www.socalcodecamp.com/sessions.aspx</a></p>  <p>And, Here is the Project Files.&#160; it includes all the .nettiers created code also.&#160; Not easy to build, but you will get the idea.&#160; The project to look at in specific would be the one named: JustODSWeb.&#160; All the others are just .NetTiers support.   <br /><a href="http://peterkellner.net/DownLoads/CodeCampJan07LA.zip">     <br />http://peterkellner.net/DownLoads/CodeCampJan07LA.zip</a></p>]]></content:encoded>
			<wfw:commentRss>http://peterkellner.net/2007/02/01/codecampla07/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Have GridView Highlight Last Inserted Record in ASP.NET 2.0</title>
		<link>http://peterkellner.net/2006/12/07/gridviewhighlightlastinsertedrow/</link>
		<comments>http://peterkellner.net/2006/12/07/gridviewhighlightlastinsertedrow/#comments</comments>
		<pubDate>Thu, 07 Dec 2006 23:41:04 +0000</pubDate>
		<dc:creator>Peter Kellner</dc:creator>
				<category><![CDATA[.Net 2.0]]></category>
		<category><![CDATA[ASP.NET 2.0]]></category>
		<category><![CDATA[Membership]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://peterkellner.net/2006/12/07/gridviewhighlightlastinsertedrow/</guid>
		<description><![CDATA[A question that frequently comes up in the asp.net forums is how to have a gridview show the the last record added highlighted. This articles gives a technique for doing this. It only works with SqlServer but could could be modified for other databases.]]></description>
			<content:encoded><![CDATA[<h2>Introduction</h2>  <p>A question that frequently comes up in the asp.net forums is how to have a gridview show the the last record added highlighted. This articles gives a technique for doing this. It only works with SqlServer but could could be modified for other databases. </p>  <h2>What It Looks Like Running</h2>  <p>After pressing the insert button on the screen shot below, the bottom line was actually added and it is automatically highlighted. This is in a nutshell, what the code listed below and this article discusses.</p> <span id="more-43"></span>  <p><img src="http://peterkellner.net/wp/Images/misc/GridViewInsertHighlight.jpg" width="409" height="625" /></p>  <h2>The Code</h2>  <p>In order to run the code below, you must first set up Membership. The simplest way to do this is to simply add to your web.config a very small section enabling RoleManager. This will automatically create the membership database in sqlexpress. You should probably add a couple users just so your gridview is not empty from the start. The code you need to add to an empty asp.net 2.0 web site project is as follows (put it in the &lt;System.Web&gt; section).</p>  <div style="font-family: courier new; background: white; color: black; font-size: 10pt">   <p style="margin: 0px"><span style="color: blue">&lt;</span><span style="color: #a31515">roleManager</span><span style="color: blue"> </span><span style="color: red">enabled</span><span style="color: blue">=</span>&quot;<span style="color: blue">true</span>&quot;<span style="color: blue">&gt;&lt;/</span><span style="color: #a31515">roleManager</span><span style="color: blue">&gt;</span> </p> </div>  <p>Once you have done that, you can copy the code below to a new web page and simply run it.</p>  <p>Briefly, the way the code works is that when a row is inserted into the database the sqldatasource&#8217;s Inserted event is called. In this event, we take a look at the return parameter which comes from the sql:</p>  <div style="font-family: courier new; background: white; color: black; font-size: 10pt">   <p style="margin: 0px"><span style="color: red">InsertCommand</span><span style="color: blue">=&quot;INSERT INTO [Names] ([name]) VALUES (@name);SELECT @NewID = Scope_Identity()&quot;</span></p> </div>  <p>NewId is actually a return parameter, so we can get that back in the inserted event. Once we get the value back, we store it in viewstate so that on the upcoming page_prerender, we can check and see which row has that id in it, and then highlight that row. The reason we do it in prerender and not load is because the inserted event is processed after load and it would not work if we put it there.</p>  <p>So, here is the code! Good luck.</p> <style type="text/css">

.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; }</style>  <pre class="csharpcode"><span class="asp">&lt;%@ Page Language=”C#” %&gt;</span>

<span class="kwrd">&lt;!</span><span class="html">DOCTYPE</span> <span class="attr">html</span> <span class="attr">PUBLIC</span> “<span class="attr">-</span>//<span class="attr">W3C</span>//<span class="attr">DTD</span> <span class="attr">XHTML</span> <span class="attr">1</span>.<span class="attr">0</span> <span class="attr">Transitional</span>//<span class="attr">EN</span>” “<span class="attr">http:</span>//<span class="attr">www</span>.<span class="attr">w3</span>.<span class="attr">org</span>/<span class="attr">TR</span>/<span class="attr">xhtml1</span>/<span class="attr">DTD</span>/<span class="attr">xhtml1-transitional</span>.<span class="attr">dtd</span>”<span class="kwrd">&gt;</span>

<span class="kwrd">&lt;</span><span class="html">script</span> <span class="attr">runat</span>=”<span class="attr">server</span>”<span class="kwrd">&gt;</span>

    <span class="rem">// simple table named: Names. Two columns:  id int, name varchar(64)</span>

    <span class="kwrd">protected</span> <span class="kwrd">void</span> ButtonInsert_Click(<span class="kwrd">object</span> sender, EventArgs e)
    {      
        SqlDataSource1.InsertParameters[<span class="str">&quot;name&quot;</span>].DefaultValue = DateTime.Now.ToString();
        <span class="kwrd">int</span> numInserted = SqlDataSource1.Insert();
        GridView1.DataBind();
    }

    <span class="kwrd">protected</span> <span class="kwrd">void</span> SqlDataSource1_Inserted(<span class="kwrd">object</span> sender, SqlDataSourceStatusEventArgs e)
    {
        <span class="kwrd">object</span> newId = e.Command.Parameters[<span class="str">&quot;@NewId&quot;</span>].Value;
        ViewState[<span class="str">&quot;NewId&quot;</span>] = Convert.ToInt32(newId);
    }

    <span class="kwrd">protected</span> <span class="kwrd">void</span> Page_PreRender(<span class="kwrd">object</span> sender, EventArgs e)
    {
        <span class="kwrd">string</span> newIdLast = <span class="kwrd">string</span>.Empty;
        <span class="kwrd">if</span> (ViewState[<span class="str">&quot;NewId&quot;</span>] != <span class="kwrd">null</span>)
        {
            <span class="kwrd">int</span> newId = (<span class="kwrd">int</span>)ViewState[<span class="str">&quot;NewId&quot;</span>];
            newIdLast = newId.ToString();
            <span class="kwrd">int</span> rowCnt = 0;
            <span class="kwrd">foreach</span> (GridViewRow row <span class="kwrd">in</span> GridView1.Rows)
            {
               <span class="kwrd">string</span> newIdText = row.Cells[1].Text;
                <span class="kwrd">if</span> (newIdText.Equals(newIdLast))
                {
                    <span class="rem">//GridView1.EditIndex = rowCnt;</span>
                    <span class="rem">//GridView1.SelectedIndex = rowCnt;</span>
                    row.Attributes.Add(“bgcolor”, “Gray”);
                    <span class="kwrd">break</span>;
                }
                rowCnt++;
            }
        }
    }
<span class="kwrd">&lt;/</span><span class="html">script</span><span class="kwrd">&gt;</span>

<span class="kwrd">&lt;</span><span class="html">html</span> <span class="attr">xmlns</span>=”<span class="attr">http:</span>//<span class="attr">www</span>.<span class="attr">w3</span>.<span class="attr">org</span>/<span class="attr">1999</span>/<span class="attr">xhtml</span>” <span class="kwrd">&gt;</span>
<span class="kwrd">&lt;</span><span class="html">head</span> <span class="attr">id</span>=”<span class="attr">Head1</span>? <span class="attr">runat</span>=”<span class="attr">server</span>”<span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;</span><span class="html">title</span><span class="kwrd">&gt;</span>Untitled Page<span class="kwrd">&lt;/</span><span class="html">title</span><span class="kwrd">&gt;</span>
<span class="kwrd">&lt;/</span><span class="html">head</span><span class="kwrd">&gt;</span>
<span class="kwrd">&lt;</span><span class="html">body</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;</span><span class="html">form</span> <span class="attr">id</span>=”<span class="attr">form1</span>? <span class="attr">runat</span>=”<span class="attr">server</span>”<span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;</span><span class="html">div</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;</span><span class="html">h2</span><span class="kwrd">&gt;</span>Example of GridView that shows highlighted last inserted row<span class="kwrd">&lt;/</span><span class="html">h2</span><span class="kwrd">&gt;</span>
        <span class="kwrd">&lt;</span><span class="html">br</span> <span class="kwrd">/&gt;</span>
        <span class="kwrd">&lt;</span><span class="html">asp:GridView</span> <span class="attr">ID</span>=”<span class="attr">GridView1</span>? <span class="attr">runat</span>=”<span class="attr">server</span>” <span class="attr">AutoGenerateColumns</span>=”<span class="attr">False</span>” <span class="attr">DataKeyNames</span>=”<span class="attr">id</span>” <span class="attr">DataSourceID</span>=”<span class="attr">SqlDataSource1</span>? <span class="kwrd">&gt;</span>
            <span class="kwrd">&lt;</span><span class="html">Columns</span><span class="kwrd">&gt;</span>
                <span class="kwrd">&lt;</span><span class="html">asp:CommandField</span> <span class="attr">ShowEditButton</span>=”<span class="attr">True</span>” <span class="attr">ShowDeleteButton</span>=”<span class="attr">True</span>” <span class="kwrd">/&gt;</span>
                <span class="kwrd">&lt;</span><span class="html">asp:BoundField</span> <span class="attr">DataField</span>=”<span class="attr">id</span>” <span class="attr">HeaderText</span>=”<span class="attr">id</span>” <span class="attr">InsertVisible</span>=”<span class="attr">False</span>” <span class="attr">ReadOnly</span>=”<span class="attr">True</span>”
                    <span class="attr">SortExpression</span>=”<span class="attr">id</span>” <span class="kwrd">/&gt;</span>
                <span class="kwrd">&lt;</span><span class="html">asp:BoundField</span> <span class="attr">DataField</span>=”<span class="attr">name</span>” <span class="attr">HeaderText</span>=”<span class="attr">name</span>” <span class="attr">SortExpression</span>=”<span class="attr">name</span>” <span class="kwrd">/&gt;</span>
            <span class="kwrd">&lt;/</span><span class="html">Columns</span><span class="kwrd">&gt;</span>
        <span class="kwrd">&lt;/</span><span class="html">asp:GridView</span><span class="kwrd">&gt;</span>
        <span class="kwrd">&lt;</span><span class="html">asp:SqlDataSource</span> <span class="attr">ID</span>=”<span class="attr">SqlDataSource1</span>? <span class="attr">runat</span>=”<span class="attr">server</span>” <span class="attr">ConnectionString</span>=”&amp;<span class="attr">lt</span>;%$ <span class="attr">ConnectionStrings:ConnectionString</span> %&amp;<span class="attr">gt</span>;“
          <span class="attr">DeleteCommand</span>=”<span class="attr">DELETE</span> <span class="attr">FROM</span> [<span class="attr">Names</span>] <span class="attr">WHERE</span> [<span class="attr">id</span>] = @<span class="attr">id</span>”
          <span class="attr">InsertCommand</span>=”<span class="attr">INSERT</span> <span class="attr">INTO</span> [<span class="attr">Names</span>] ([<span class="attr">name</span>]) <span class="attr">VALUES</span> (@<span class="attr">name</span>);<span class="attr">SELECT</span> @<span class="attr">NewID</span> = <span class="attr">Scope_Identity</span>()”

          <span class="attr">SelectCommand</span>=”<span class="attr">SELECT</span> [<span class="attr">id</span>], [<span class="attr">name</span>] <span class="attr">FROM</span> [<span class="attr">Names</span>]“ <span class="attr">UpdateCommand</span>=”<span class="attr">UPDATE</span> [<span class="attr">Names</span>] <span class="attr">SET</span> [<span class="attr">name</span>] = @<span class="attr">name</span> <span class="attr">WHERE</span> [<span class="attr">id</span>] = @<span class="attr">id</span>” <span class="attr">OnInserted</span>=”<span class="attr">SqlDataSource1_Inserted</span>”<span class="kwrd">&gt;</span>
            <span class="kwrd">&lt;</span><span class="html">DeleteParameters</span><span class="kwrd">&gt;</span>
                <span class="kwrd">&lt;</span><span class="html">asp:Parameter</span> <span class="attr">Name</span>=”<span class="attr">id</span>” <span class="attr">Type</span>=”<span class="attr">Int32</span>? <span class="kwrd">/&gt;</span>
            <span class="kwrd">&lt;/</span><span class="html">DeleteParameters</span><span class="kwrd">&gt;</span>
            <span class="kwrd">&lt;</span><span class="html">UpdateParameters</span><span class="kwrd">&gt;</span>
                <span class="kwrd">&lt;</span><span class="html">asp:Parameter</span> <span class="attr">Name</span>=”<span class="attr">name</span>” <span class="attr">Type</span>=”<span class="attr">String</span>” <span class="kwrd">/&gt;</span>
                <span class="kwrd">&lt;</span><span class="html">asp:Parameter</span> <span class="attr">Name</span>=”<span class="attr">id</span>” <span class="attr">Type</span>=”<span class="attr">Int32</span>? <span class="kwrd">/&gt;</span>
            <span class="kwrd">&lt;/</span><span class="html">UpdateParameters</span><span class="kwrd">&gt;</span>
            <span class="kwrd">&lt;</span><span class="html">InsertParameters</span><span class="kwrd">&gt;</span>
                <span class="kwrd">&lt;</span><span class="html">asp:Parameter</span> <span class="attr">Name</span>=”<span class="attr">name</span>” <span class="attr">Type</span>=”<span class="attr">String</span>” <span class="kwrd">/&gt;</span>
               <span class="kwrd">&lt;</span><span class="html">asp:Parameter</span> <span class="attr">Direction</span>=<span class="attr">Output</span> <span class="attr">Name</span>=”<span class="attr">NewId</span>” <span class="attr">Size</span>=<span class="attr">4</span> <span class="attr">Type</span>=<span class="attr">Int16</span> <span class="kwrd">/&gt;</span>
            <span class="kwrd">&lt;/</span><span class="html">InsertParameters</span><span class="kwrd">&gt;</span>
        <span class="kwrd">&lt;/</span><span class="html">asp:SqlDataSource</span><span class="kwrd">&gt;</span>
        <span class="kwrd">&lt;</span><span class="html">br</span> <span class="kwrd">/&gt;</span>
        <span class="kwrd">&lt;</span><span class="html">br</span> <span class="kwrd">/&gt;</span>
        <span class="attr">&amp;nbsp;</span><span class="kwrd">&lt;</span><span class="html">asp:Button</span> <span class="attr">ID</span>=”<span class="attr">ButtonInsert</span>” <span class="attr">runat</span>=”<span class="attr">server</span>” <span class="attr">OnClick</span>=”<span class="attr">ButtonInsert_Click</span>” <span class="attr">Text</span>=”<span class="attr">Insert</span> <span class="attr">Record</span>” <span class="kwrd">/&gt;&lt;/</span><span class="html">div</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;/</span><span class="html">form</span><span class="kwrd">&gt;</span>
<span class="kwrd">&lt;/</span><span class="html">body</span><span class="kwrd">&gt;</span>
<span class="kwrd">&lt;/</span><span class="html">html</span><span class="kwrd">&gt;</span></pre>

<h2>About the Author </h2>

<p>Peter Kellner currently works as an asp.net enterprise consultant at <a href="http://www.73rdstreet.com">http://www.73rdstreet.com</a>. During the past year, Peter Kellner has authored four MSDN articles dealing with Membership and Profiles. He maintains a blog with more articles at <a href="http://peterkellner.net">http://peterkellner.net</a>. </p>]]></content:encoded>
			<wfw:commentRss>http://peterkellner.net/2006/12/07/gridviewhighlightlastinsertedrow/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Page Caching using disk (enhanced)
Database Caching 6/13 queries in 0.066 seconds using disk

Served from: peterkellner.net @ 2012-02-08 20:18:09 -->
