Skip to content

Instantly share code, notes, and snippets.

@einarwh
Created February 28, 2013 08:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save einarwh/5055182 to your computer and use it in GitHub Desktop.
Save einarwh/5055182 to your computer and use it in GitHub Desktop.
Defining grid columns.
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