private void GetSelections_Click(object sender, System.EventArgs e)
{
int rowCount = 0;
StringBuilder gridSelections = new StringBuilder();
//Loop through each DataGridItem, and determine which CheckBox controls
//have been selected.
foreach(DataGridItem DemoGridItem in DemoGrid.Items)
{
CheckBox myCheckbox = (CheckBox)DemoGridItem.Cells[0].Controls[1];
if(myCheckbox.Checked == true)
{
rowCount++;
gridSelections.AppendFormat("The checkbox for {0} was selected<br>",
DemoGrid.DataKeys[DemoGridItem.ItemIndex].ToString());
}
}
gridSelections.Append("<hr>");
gridSelections.AppendFormat("Total number selected is: {0}", rowCount.ToString());
ResultsInfo.Text = gridSelections.ToString();
}