private void BindFree() { AdvancementList list = GetAdvancementList(); // determine how many, if any, free points the user has left. int free = 0; foreach (Advancement adv in list) free += (adv.Free - adv.FreePlaced); FreePanel.Visible = (free > 0); // do nothing if the user has no free points if (free == 0) return; Intelligence.Text = UserHouse.Intelligence.ToString(); Power.Text = UserHouse.Power.ToString(); Protection.Text = UserHouse.Protection.ToString(); Affluence.Text = UserHouse.Affluence.ToString(); Speed.Text = UserHouse.Speed.ToString(); Contingency.Text = UserHouse.Contingency.ToString(); // clear any free point rows in order to rebind with new rows - the first two rows are header rows and should be retained if ( Page.IsPostBack && FreeTable.Rows.Count > 2 ) { for ( int row = FreeTable.Rows.Count -1; row >= 2; row-- ) FreeTable.Rows.RemoveAt( row ); } // for each free point, create a table row for managing the point placement for (int i = 0; i < free; i++) { TableRow row = new TableRow(); TableCell pointCell = new TableCell(); TableCell intelligenceCell = new TableCell(); TableCell powerCell = new TableCell(); TableCell protectionCell = new TableCell(); TableCell affluenceCell = new TableCell(); TableCell speedCell = new TableCell(); TableCell contingencyCell = new TableCell(); int pointIndex = i + 1; pointCell.Text = pointIndex.ToString(); CheckBox intCheck = new CheckBox(); intCheck.ID = "IntelligenceCheckBox" + i.ToString(); AjaxControlToolkit.MutuallyExclusiveCheckBoxExtender intExtend = new MutuallyExclusiveCheckBoxExtender(); intExtend.ID = "IntelligenceCheckBoxExtender" + i.ToString(); intExtend.TargetControlID = intCheck.ID; intExtend.Key = "Row" + i.ToString() + "CheckBoxes"; intelligenceCell.Controls.Add( intCheck ); intelligenceCell.Controls.Add( intExtend ); CheckBox powCheck = new CheckBox(); powCheck.ID = "PowerCheckBox" + i.ToString(); AjaxControlToolkit.MutuallyExclusiveCheckBoxExtender powExtend = new MutuallyExclusiveCheckBoxExtender(); powExtend.ID = "PowerCheckBoxExtender" + i.ToString(); powExtend.TargetControlID = powCheck.ID; powExtend.Key = "Row" + i.ToString() + "CheckBoxes"; powerCell.Controls.Add( powCheck ); powerCell.Controls.Add( powExtend ); CheckBox proCheck = new CheckBox(); proCheck.ID = "ProtectionCheckBox" + i.ToString(); AjaxControlToolkit.MutuallyExclusiveCheckBoxExtender proExtend = new MutuallyExclusiveCheckBoxExtender(); proExtend.ID = "ProtectionCheckBoxExtender" + i.ToString(); proExtend.TargetControlID = proCheck.ID; proExtend.Key = "Row" + i.ToString() + "CheckBoxes"; protectionCell.Controls.Add( proCheck ); protectionCell.Controls.Add( proExtend ); CheckBox affCheck = new CheckBox(); affCheck.ID = "AffluenceCheckBox" + i.ToString(); AjaxControlToolkit.MutuallyExclusiveCheckBoxExtender affExtend = new MutuallyExclusiveCheckBoxExtender(); affExtend.ID = "AffluenceCheckBoxExtender" + i.ToString(); affExtend.TargetControlID = affCheck.ID; affExtend.Key = "Row" + i.ToString() + "CheckBoxes"; affluenceCell.Controls.Add( affCheck ); affluenceCell.Controls.Add( affExtend ); CheckBox spdCheck = new CheckBox(); spdCheck.ID = "SpeedCheckBox" + i.ToString(); AjaxControlToolkit.MutuallyExclusiveCheckBoxExtender spdExtend = new MutuallyExclusiveCheckBoxExtender(); spdExtend.ID = "SpeedCheckBoxExtender" + i.ToString(); spdExtend.TargetControlID = spdCheck.ID; spdExtend.Key = "Row" + i.ToString() + "CheckBoxes"; speedCell.Controls.Add( spdCheck ); speedCell.Controls.Add( spdExtend ); CheckBox conCheck = new CheckBox(); conCheck.ID = "ContingencyCheckBox" + i.ToString(); AjaxControlToolkit.MutuallyExclusiveCheckBoxExtender conExtend = new MutuallyExclusiveCheckBoxExtender(); conExtend.ID = "ContingencyCheckBoxExtender" + i.ToString(); conExtend.TargetControlID = conCheck.ID; conExtend.Key = "Row" + i.ToString() + "CheckBoxes"; contingencyCell.Controls.Add( conCheck ); contingencyCell.Controls.Add( conExtend ); row.Cells.Add( pointCell ); row.Cells.Add( intelligenceCell ); row.Cells.Add( powerCell ); row.Cells.Add( protectionCell ); row.Cells.Add( affluenceCell ); row.Cells.Add( speedCell ); row.Cells.Add( contingencyCell ); FreeTable.Rows.Add( row ); } }