Tom Tom - 3 days ago 5
Vb.net Question

Reordering table rows on server side

I have a table which contains asp radiobuttonlists (see below) for a survey. Once submitted the results are written to a database.

I would like to use this same table for a similar survey, but the trouble is the question order needs to be different. The questions are the same, just in a different order.

Is there a way (server side) to change the order of the table rows?

<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>EXCELLENT</td>
<td>GOOD</td>
<td>AVERAGE</td>
<td>POOR</td>
</tr>
<tr>
<td>1</td>
<td>Question 1</td>
<td colspan="4" class="radiocell"><asp:RadioButtonList ID="question1" runat="server" CssClass="radiooptions" RepeatColumns="4" CellPadding="0" CellSpacing="0">
<asp:ListItem id="answer1_1" runat="server" Value="1" Text="" />
<asp:ListItem id="answer1_2" runat="server" Value="2" Text="" />
<asp:ListItem id="answer1_3" runat="server" Value="3" Text="" />
<asp:ListItem id="answer1_4" runat="server" Value="4" Text="" />
</asp:RadioButtonList></td>
</tr>
<tr>
<td>2</td>
<td>Question 2</td>
<td colspan="4" class="radiocell"><asp:RadioButtonList ID="question2" runat="server" CssClass="radiooptions" RepeatColumns="4" CellPadding="0" CellSpacing="0">
<asp:ListItem id="answer2_1" runat="server" Value="1" Text="" />
<asp:ListItem id="answer2_2" runat="server" Value="2" Text="" />
<asp:ListItem id="answer2_3" runat="server" Value="3" Text="" />
<asp:ListItem id="answer2_4" runat="server" Value="4" Text="" />
</asp:RadioButtonList></td>
</tr>
<tr>
<td>3</td>
<td>Question 3</td>
<td colspan="4" class="radiocell"><asp:RadioButtonList ID="question3" runat="server" CssClass="radiooptions" RepeatColumns="4" CellPadding="0" CellSpacing="0">
<asp:ListItem id="answer3_1" runat="server" Value="1" Text="" />
<asp:ListItem id="answer3_2" runat="server" Value="2" Text="" />
<asp:ListItem id="answer3_3" runat="server" Value="3" Text="" />
<asp:ListItem id="answer3_4" runat="server" Value="4" Text="" />
</asp:RadioButtonList></td>
</tr>
</table>

Answer

You could use the ASP.Net DataList or Repeater instead and sort the DataSource accordingly.

Comments