可以实现局部刷新的,意思就是可以局部切换题目的,希望可以详细点,下面有大概的示例图。
我自己通过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();
然后这个是我想实现的大概样子
拜托了,感谢大家!