protected void btnUpdateList_Click(object sender, EventArgs e)
{
foreach (GridViewRow row in gViewReferences.Rows)
{
if (row.RowType == DataControlRowType.DataRow)
{
//Get the unsolicited check box and then current reference
CheckBox cboxUnsolicited = (CheckBox)row.FindControl("chkUnsolicited");
int referenceID = (int)gViewReferences.DataKeys[row.RowIndex]["id"];
Reference currentReference = ReferenceBLL.GetByID(referenceID);
//Only save the information if it has changed
if (currentReference.UnsolicitedReference != cboxUnsolicited.Checked)
{
using (var ts = new TransactionScope())
{
currentReference.UnsolicitedReference = cboxUnsolicited.Checked;
ReferenceBLL.EnsurePersistent(currentReference);
ts.CommitTransaction();
}
}
}
}
//Notify the user that the update was successful
lblResult.Text = "Unsolicited List Updated";
}