I am creating a quiz application in ASP.net (c#) and I currently have one question at a time displaying with the use of a datapager. However, If I chose radiobutton1 and then move on to question 2, It has radiobutton1 already selected, even though I am yet to answer that question. So for some reason the selection I make on question 1 is being duplicated to the other questions - I think it's obviously something to do with the setting and retreiving of the viewstates. Any help would be greatly appreciated!!
- <body>
- <form id="form1" runat="server">
- <div>
- <asp:ListView ID="lvCustomers" runat="server" GroupPlaceholderID="groupPlaceHolder1"
- ItemPlaceholderID="itemPlaceHolder1" OnPagePropertiesChanging="OnPagePropertiesChanging" OnPreRender="ListPager_PreRender">
-
- <LayoutTemplate>
- <div id="itemPlaceHolder1" runat="server">
- </div>
- <asp:DataPager ID="DataPager1" runat="server" PagedControlID="lvCustomers" PageSize="1">
- <Fields>
- <asp:NextPreviousPagerField runat="server" ButtonType="Link"
- ShowFirstPageButton="false"
- ShowPreviousPageButton="true"
- ShowNextPageButton="false" />
- <asp:NumericPagerField ButtonType="Link" />
- <asp:NextPreviousPagerField ButtonType="Link"
- ShowNextPageButton="true"
- ShowLastPageButton="false"
- ShowPreviousPageButton="false" />
- </Fields>
- </asp:DataPager>
- </LayoutTemplate>
- <ItemTemplate>
- <asp:Label ID="Label2" runat="server" Text='<%#Eval("QuestionID")%>'></asp:Label><br />
- <asp:Label ID="Label1" runat="server" Text='<%#Eval("QuestionText")%>'></asp:Label><br />
- <li>
- <asp:RadioButton ID="Radio1" Text='<%#Eval("Answer1") %>' GroupName="radiobtns" EnableViewState="true" runat="server" />
- </li>
- <li>
- <asp:RadioButton ID="Radio2" runat="server" GroupName="radiobtns" EnableViewState="true" Text='<%#Eval("Answer2") %>' />
- </li>
- <li>
- <asp:RadioButton ID="Radio3" runat="server" GroupName="radiobtns" EnableViewState="true" Text='<%#Eval("Answer3") %>' />
- </li>
- <li>
- <asp:RadioButton ID="Radio4" runat="server" GroupName="radiobtns" EnableViewState="true" Text='<%#Eval("Answer4") %>' />
- </li>
- <br />
- </ItemTemplate>
- </asp:ListView>
- </div>
- <p>
- <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
- </p>
- </form>
- </body>
- </html>