Exemple #1
0
    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        // DataSet ds = new DataSet();
        string a = dd1.SelectedValue;

        ds = Showexam.showexam(a);
        if (ds.Tables.Count > 0)
        {
            GridView1.DataSource = ds.Tables[0];
            GridView1.DataBind();
        }
        else
        {
            GridView1.DataSource = null;
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            btn_1.BackColor = System.Drawing.Color.Gold;
            j = i + 1;
            btn_previous.Visible = false;
            lbl_no.Text          = j.ToString();
            //DataRow dr;
            //DataSet ds = new DataSet();
            Random rand          = new Random((int)DateTime.Now.Ticks);
            int    numIterations = 0;
            numIterations = rand.Next(1, 3);
            //Response.Write(numIterations.ToString());
            string a = Session["value"].ToString();

            string f = a + numIterations.ToString();
            Session["tablename"] = a;
            ds = Showexam.showexam(f);
            dt = ds.Tables[0];
            DataColumn dc = new DataColumn("userans");
            dt.Columns.Add(dc);
            dc.DefaultValue  = "";
            ViewState["ds"]  = dt;
            ViewState["ind"] = i;
            lbl_no.Text      = j.ToString();
            if (ds.Tables.Count > 0)
            {
                dr               = ds.Tables[0].Rows[i];
                lbl_que.Text     = dr["Question"].ToString();
                rdo_button1.Text = dr["CHOICE1"].ToString();
                rdo_button2.Text = dr["CHOICE2"].ToString();
                rdo_button3.Text = dr["CHOICE3"].ToString();
                rdo_button4.Text = dr["CHOICE4"].ToString();
            }
        }

        /* else {
         *   i = (int)ViewState["ind"];
         *   if (i == 1)
         *   {
         *       btn_2.BackColor = System.Drawing.Color.Yellow;
         *       btn_1.BackColor = System.Drawing.Color.White;
         *   }
         *   else if (i == 2)
         *   {
         *       btn_3.BackColor = System.Drawing.Color.Yellow;
         *       btn_2.BackColor = System.Drawing.Color.White;
         *   }
         *   else if (i == 3)
         *   {
         *       btn_5.BackColor = System.Drawing.Color.Yellow;
         *       btn_3.BackColor = System.Drawing.Color.White;
         *   }
         *   else if (i == 4)
         *   {
         *       btn_6.BackColor = System.Drawing.Color.Yellow;
         *       btn_5.BackColor = System.Drawing.Color.White;
         *   }
         *   else if (i == 5)
         *   {
         *       btn_7.BackColor = System.Drawing.Color.Yellow;
         *       btn_6.BackColor = System.Drawing.Color.White;
         *   }
         *   else if (i == 6)
         *   {
         *       btn_8.BackColor = System.Drawing.Color.Yellow;
         *   btn_7.BackColor = System.Drawing.Color.White;
         *   }
         *   else if (i == 7)
         *   {
         *       btn_9.BackColor = System.Drawing.Color.Yellow;
         *   btn_8.BackColor = System.Drawing.Color.White;
         *   }
         *   else if (i == 8){
         *       btn_10.BackColor = System.Drawing.Color.Yellow;
         *   btn_9.BackColor = System.Drawing.Color.White;
         *   }
         *   else if (i == 9)
         *   {
         *       btn_11.BackColor = System.Drawing.Color.Yellow;
         *       btn_10.BackColor = System.Drawing.Color.White;
         *   }
         *
         * }*/
    }