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’s TextBox method of editing GridView cells, you’re golden. Sometimes you need DropDownLists in place of TextBoxes, and that takes a teensy bit more work:
[code lang="csharp"]
[/code]
There’s a microscopic UI flaw in this approach: when the user clicks ‘Edit,’ the selected DropDownList item is the first (index 0), not the item that matches the cell’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 very dirty but awesomely easy solution. Use the DDL’s ValidationGroup field as short-term memory!
Tags: .NET, programming