Question table colums are question_id,teacher_id,teacher_question,teacher_answer
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 } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)