private void DrawBoxDetails()
{
if (boxData == null)
{
boxData = new List<KeyValuePair<string, int>>();
}
pnlBoxDetails.Controls.Clear();
Literal litHeader = new Literal();
pnlBoxDetails.Controls.Add(litHeader);
litHeader.ID = "litBoxesHeader";
litHeader.Text = "<fieldset><legend>Box Details</legend><ol>";
foreach (KeyValuePair<string, int> currentKVP in boxData)
{
if (pnlAddBoxes.FindControl("txt" + currentKVP.Key.ToString() + "Boxes") == null)
{
Literal myStartLit = new Literal();
Label myOfficeLabel = new Label();
TextBox myBoxesTextBox = new TextBox();
Literal myEndLit = new Literal();
Button myChangeButton = new Button();
pnlBoxDetails.Controls.Add(myStartLit);
pnlBoxDetails.Controls.Add(myOfficeLabel);
pnlBoxDetails.Controls.Add(myBoxesTextBox);
pnlBoxDetails.Controls.Add(myChangeButton);
pnlBoxDetails.Controls.Add(myEndLit);
myStartLit.ID = "litStart" + currentKVP.Key.ToString();
myStartLit.Text = "<li>";
myOfficeLabel.ID = "lbl" + currentKVP.Key.ToString();
myOfficeLabel.Text = currentKVP.Key.ToString();
myBoxesTextBox.ID = "txt" + currentKVP.Key.ToString() + "Boxes";
myBoxesTextBox.Text = currentKVP.Value.ToString();
myBoxesTextBox.EnableViewState = true;
myBoxesTextBox.AutoPostBack = false;
myChangeButton.ID = "btn" + currentKVP.Key.ToString() + "Boxes";
myChangeButton.Text = "Update Box";
myChangeButton.Click += new EventHandler(myBoxesTextBox_TextChanged);
myEndLit.ID = "litEnd" + currentKVP.Key.ToString();
myEndLit.Text = "</li>";
}
}
Literal litFooter = new Literal();
pnlBoxDetails.Controls.Add(litFooter);
litFooter.ID = "litBoxesFooter";
litFooter.Text = "</ol></fieldset>";
}