本文介绍了在线考试系统的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
先生
下一个问题按钮的代码有问题.我编写了代码,但是单击下一步按钮时,它仅显示两个问题.
我的代码如下:-
sir
have a problem in code for the next question button. i write a code but on clicking the next button it shows only two questions.
my code is as follows:-
public partial class test : System.Web.UI.Page
{
int x = 0;
int ans1 = 0;
SqlConnection ob = new SqlConnection(ConfigurationManager.ConnectionStrings["upsc"].ToString());
protected void Page_Load(object sender, EventArgs e)
{
question();
}
protected void question()
{
ob.Open();
String a = "Select que,op1,op2,op3,op4,answer from test";
SqlDataAdapter objcmd = new SqlDataAdapter(a, ob);
DataSet ds = new DataSet();
objcmd.Fill(ds, "exam" );
lblQues.Text = ds.Tables["exam"].Rows[x][0].ToString();
RadioButton1.Text = ds.Tables["exam"].Rows[x][1].ToString();
RadioButton2.Text = ds.Tables["exam"].Rows[x][2].ToString();
RadioButton3.Text = ds.Tables["exam"].Rows[x][3].ToString();
RadioButton4.Text = ds.Tables["exam"].Rows[x][4].ToString();
ans.Text = ds.Tables["exam"].Rows[x][5].ToString();
x++;
ob.Close();
}
protected void Button1_Click(object sender, EventArgs e)
{
ob.Open();
lblQues.Text = ds.Tables["exam"].Rows[x][0].ToString();
RadioButton1.Text = ds.Tables["exam"].Rows[x][1].ToString();
RadioButton2.Text = ds.Tables["exam"].Rows[x][2].ToString();
RadioButton3.Text = ds.Tables["exam"].Rows[x][3].ToString();
RadioButton4.Text = ds.Tables["exam"].Rows[x][4].ToString();
ans.Text = ds.Tables["exam"].Rows[x][5].ToString();
x++;
}
}
推荐答案
这篇关于在线考试系统的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!