houetsu 2019-12-11 16:46
浏览 206

asp.net 如何实现类似于考试系统的上一页,下一页?

可以实现局部刷新的,意思就是可以局部切换题目的,希望可以详细点,下面有大概的示例图。
我自己通过sqlcommand实现了题目的数据导入,然后利用radiobuttonlist和sqldatasource实现了选项的数据导入,但都只限于一道题,然后我不知道该如何导入后面的数据可以实现局部切换题目的那种。希望可以帮助我谢谢

下面是我实现的一些
前端

 <td style="height:50px;width:700px;background-color:#EBEBEB;border-width:1px;border-style:solid;border-color:#D5D5D5;text-align:center">
<asp:Label ID="type"  runat="server" Text="" ForeColor="#666666" Font-Size="20px"/>
 <asp:Label ID="text"  runat="server" ForeColor="#666666"/>

</td>
<asp:Label ID="value" Text="" runat="server" Font-Size="20px"  /><br />
<asp:RadioButtonList ID="option1" runat="server" DataSourceID="SqlDataSource1" DataTextField="option_value" DataValueField="option_id">
<asp:ListItem Value="A"></asp:ListItem>
<asp:ListItem Value="B"></asp:ListItem>
<asp:ListItem Value="C"></asp:ListItem>
<asp:ListItem Value="D"></asp:ListItem>
</asp:RadioButtonList>


 <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:网上考试系统ConnectionString %>" SelectCommand="SELECT [option_id], [option_value] FROM [第一套选项] WHERE ([question_id] = @question_id)">
<SelectParameters>
<asp:Parameter DefaultValue="1" Name="question_id" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
</td>

cs代码:

 SqlConnection scon = new SqlConnection("Data Source =.; Integrated Security = true; Initial Catalog = 网上考试系统;");
            scon.Open();
            SqlCommand sqlcmd = new SqlCommand();
            sqlcmd.Connection = scon;
            string str = "select* from 第一套题目 where  question_id='" + 1 + "'";
            sqlcmd.CommandText = str; //执行数据
            SqlDataReader sqlRead = sqlcmd.ExecuteReader();//读取数据
            if(sqlRead.Read())
            {

                type.Text=sqlRead.GetString(sqlRead.GetOrdinal("question_type"));
                text.Text = sqlRead.GetString(sqlRead.GetOrdinal("question_text"));
                value.Text = sqlRead.GetString(sqlRead.GetOrdinal("question_value"));
            }
            sqlRead.Close();              
            scon.Close();

然后这个是我想实现的大概样子
图片说明
拜托了,感谢大家!

  • 写回答

0条回答

    报告相同问题?

    悬赏问题

    • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
    • ¥15 求daily translation(DT)偏差订正方法的代码
    • ¥15 js调用html页面需要隐藏某个按钮
    • ¥15 ads仿真结果在圆图上是怎么读数的
    • ¥20 Cotex M3的调试和程序执行方式是什么样的?
    • ¥20 java项目连接sqlserver时报ssl相关错误
    • ¥15 一道python难题3
    • ¥15 牛顿斯科特系数表表示
    • ¥15 arduino 步进电机
    • ¥20 程序进入HardFault_Handler