在线考试中的下一个按钮的代码 [英] code for next button in online Examination
本文介绍了在线考试中的下一个按钮的代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经编写了代码,但没有正确执行,如果有可能给我其他代码
问题是当我点击下一步按钮它显示我的下一条记录,程序工作正常,但当我退出并直接登录显示我最后的记录不是从开始
i have written code but not Executing properly if it is possible give me other code
problem is when i click on next button it is showing me next record, program works properly but when I log out and log in directly shows me last record not from start
Question table colums are question_id,teacher_id,teacher_question,teacher_answer
//代码是
//code is
namespace project_master
{
public partial class acnj : System.Web.UI.Page
{
SqlCommand cmd = new SqlCommand();
public static int i = 0;
DataTable dt = new DataTable();
DataRow drr;
SqlConnection con = new SqlConnection(@"Data Source=.\sqlexpress;Initial Catalog=swatidb;Integrated Security=True;Pooling=False");
public void Page_Load(object sender, EventArgs e)
{
con.Open();
string s1 = "select student_id from Student where user_name='" + Session["sid"] + "'";
SqlCommand cmd = new SqlCommand(s1, con);
SqlDataReader dr;
dr = cmd.ExecuteReader();
if (dr.Read())
{
Label4_stu_id.Text =dr[0].ToString();//for displaying student_id
dr.Close();
}
SqlDataAdapter da = new SqlDataAdapter("select * from Question where question_id>=1 and question_id<=3", con);
da.Fill(dt);
drr = dt.Rows[i];
Label2_tea_que.Text = "Write question below in Textbox click next to get questoion";
}
public void next_Click(object sender, System.EventArgs e)
{
if (i == (dt.Rows.Count - 1))
{
Response.Write("Last record !");
}
else
{
i++;
}
Label3_que_id.Text = Convert.ToString(drr[0]);//tlabel for displaying question_id
Label2_tea_que.Text = Convert.ToString(drr[2]); //label displaying Teacher question
}
}
}
}
推荐答案
这与如何编写代码的问题相同在线检查中的下一个按钮以及上一个按钮 [ ^ ]。请编辑原文而不是重新发布。
This is the same question as how to write code for next button in online examination and also for previous button[^]. Please edit your original rather than reposting.
这篇关于在线考试中的下一个按钮的代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文