Created
February 28, 2013 08:28
-
-
Save einarwh/5055182 to your computer and use it in GitHub Desktop.
Defining grid columns.
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
protected void Page_Load(object sender, EventArgs e) | |
{ | |
GetGridColumns().ForEach(f => _grid.Columns.Add(f)); | |
_grid.DataSource = new BoxEnumerable<ICanine>(GetCanines()); | |
_grid.DataBind(); | |
} | |
private static List<DataGridColumn> GetGridColumns() | |
{ | |
return new List<DataGridColumn> | |
{ | |
new TemplateColumn | |
{ | |
HeaderText = "Biscuits?", | |
ItemTemplate = new FoodColumnTemplate(Food.Biscuit) | |
}, | |
new TemplateColumn | |
{ | |
HeaderText = "Meatballs?", | |
ItemTemplate = new FoodColumnTemplate(Food.Meatballs) | |
}, | |
new TemplateColumn | |
{ | |
HeaderText = "You?", | |
ItemTemplate = new FoodColumnTemplate(Food.You) | |
} | |
}; | |
} | |
private static IEnumerable<ICanine> GetCanines() | |
{ | |
return new List<ICanine> {new Dog(), new Wolf(), new Chihuahua() }; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment