// METHOD:: Add checked items and persist them to memory private void PersistItems(int item) { if (!SelectedIndexes.Exists(i => i == item)) { SelectedIndexes.Add(item); } }
// METHOD:: Repopulate checked items and store in gridview. private void RepopulateCheckedItems() { foreach (GridViewRow row in this.Rows) { // Retrieve the reference to the checkbox CheckBox checkBox = (CheckBox)row.FindControl(InputCheckBoxField.CheckBoxID); if (SelectedIndexes != null) { if (SelectedIndexes.Exists(i => i == row.DataItemIndex)) { checkBox.Checked = true; } } } }