protected void btnViewAll_Click(object sender, EventArgs e) { Stack1 = (Stack)ViewState["Stack1"]; string elements = ""; foreach (int element in Stack1.GetAllElements()) elements = elements + "[" + element + "]" + " "; lblDisplay.Text = "The elements in the stack are " + elements; }