Hi everyone,
I am working on a form and I am trying to add buttons back and submit when I go to another page, but I keep getting the error "Collection was modified; enumeration operation may not execute." whenever it tries to create the buttons and add them. I am generating these buttons from a C# script on my web page.
<asp:TableCell>
<asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem>1</asp:ListItem>
<asp:ListItem>2</asp:ListItem>
<asp:ListItem>3</asp:ListItem>
<asp:ListItem>4</asp:ListItem>
</asp:DropDownList>
</asp:TableCell>
</asp:TableRow>
</asp:Table>
<% if (questionIndex > 0) //it is this and the other script that are giving me the problems
{
Button back = new Button();
back.Text = "Back >";
Page.Controls.Add(back);
}
%>
<asp:Button ID="next" runat="server" Text="Next >" onclick="next_Click" />
<asp:Button ID="cancel" runat="server" Text="Cancel" />
<% if (questionIndex > 0)
{
Button submit = new Button();
submit.Text = "Submit";
Page.Controls.Add(submit);
}
%>
Thank you,
Brian Wimpsett