Created
February 28, 2013 08:42
-
-
Save einarwh/5055254 to your computer and use it in GitHub Desktop.
FoodListColumnTemplate class.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class FoodListColumnTemplate : ITemplate | |
{ | |
public void InstantiateIn(Control container) | |
{ | |
var list = new DropDownList(); | |
list.DataBinding += OnDataBinding; | |
container.Controls.Add(list); | |
} | |
private void OnDataBinding(object sender, EventArgs e) | |
{ | |
var list = (DropDownList) sender; | |
var row = (DataGridItem) list.NamingContainer; | |
var canine = (ICanine) row.DataItem; | |
Action<Food> add = food => { if (canine.Eats(food)) { list.Items.Add(food.ToString()); } }; | |
add(Food.Biscuit); | |
add(Food.Meatballs); | |
add(Food.You); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment