<?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>spamguy &#187; .NET</title>
	<atom:link href="http://blog.spamguy.org/tag/net/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.spamguy.org</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Tue, 09 Feb 2010 16:42:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.5</generator>
		<item>
		<title>DropDownList Drops The GridView Ball</title>
		<link>http://blog.spamguy.org/2009/03/05/dropdownlist-drops-the-gridview-ball/</link>
		<comments>http://blog.spamguy.org/2009/03/05/dropdownlist-drops-the-gridview-ball/#comments</comments>
		<pubDate>Thu, 05 Mar 2009 23:57:24 +0000</pubDate>
		<dc:creator>spamguy</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://blog.spamguy.org/?p=177</guid>
		<description><![CDATA[When .NET 2.0 makes things easy, it makes them brain-dead easy. But when it makes things hard, you wish you were working as a greeter at Wal-Mart. Take GridView editing. If you accept Microsoft&#8217;s TextBox method of editing GridView cells, you&#8217;re golden. Sometimes you need DropDownLists in place of TextBoxes, and that takes a teensy [...]]]></description>
			<content:encoded><![CDATA[<p>When .NET 2.0 makes things easy, it makes them brain-dead easy. But when it makes things hard, you wish you were working as a greeter at Wal-Mart. Take GridView editing. If you accept Microsoft&#8217;s TextBox method of editing GridView cells, you&#8217;re golden. Sometimes you need DropDownLists in place of TextBoxes, and that takes a teensy bit more work:</p>
<p>[code lang="csharp"]<asp:GridView ID="gvProgramRoles" runat="server" AutoGenerateColumns="False" DataKeyNames="ID" DataSourceID="dsProgramRoles"></p>
<columns>
		<asp:TemplateField HeaderText="Program Role"><br />
			<itemTemplate><%# Eval("Role") %></itemTemplate><br />
			<editItemTemplate><br />
				<asp:DropDownList runat="server" ID="ddlEditRole" DataSourceID="dsProgramRoleList" DataTextField="Name" DataValueField="ID"></asp:DropDownList><br />
			</editItemTemplate><br />
		</asp:TemplateField><br />
		<asp:CommandField ShowEditButton="True" ShowDeleteButton="true" /><br />
	</columns>
</asp:GridView><br />
[/code]</p>
<p>There&#8217;s a microscopic UI flaw in this approach: when the user clicks &#8216;Edit,&#8217; the selected DropDownList item is the first (index 0), not the item that matches the cell&#8217;s text. Uniting the two is surprisingly harsh, since the text disappears before the DDL appears. After many unfruitful searches for an answer, one long blog post has a solution. <a href="http://johnpadillaweb.spaces.live.com/blog/cns!85080ACE7B1F5195!115.entry">A very dirty but awesomely easy solution.</a> Use the DDL&#8217;s ValidationGroup field as short-term memory!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.spamguy.org/2009/03/05/dropdownlist-drops-the-gridview-ball/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

