我正在尝试将r1,r2,r3列加载到复选框列表中,但输出不是我预期的结果
我的数据库中的数据
问题r1 r2 r3
我是谁? A B C输出(我的复选框列表中的项目)
A
预期输出
A
乙
C
我试图将r1,r2,r3添加到DataTextField但asp.net不允许我这样做=(
DataSourceID="SqlDataSource1" DataTextField="r1" DataValueField="r1">
</asp:CheckBoxList>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT [r1], [r2], [r3] FROM [ExerciseTable] WHERE ([Question] = @Question)">
<SelectParameters>
<asp:Parameter DefaultValue="who am i?" Name="Question" Type="String" />
</SelectParameters>
答案 0 :(得分:0)
尝试此选择命令:
SELECT [r1] AS [Option] FROM [ExerciseTable] WHERE ([Question] = @Question)
UNION
SELECT [r2] AS [Option] FROM [ExerciseTable] WHERE ([Question] = @Question)
UNION
SELECT [31] AS [Option] FROM [ExerciseTable] WHERE ([Question] = @Question)