只选择忽略休息的相关列

时间:2016-03-07 07:38:17

标签: c# asp.net

当我开始测试时,我有一个问题论文,然后我根据id得到了下一个问题但是主题id是随机的意味着我的主题ID是交替的。假设我的主题ID为4,当我点击下一个问题时,主键是替代的,那么如果主题ID不是4,我就会变成空白请帮帮我

这是我的代码

    private void getQuestion(int no)
    {
    //con.Open();
    //    SqlCommand cmd = new SqlCommand("select count(TopicId) from QuetionBank where TopicId='"+topicID+"'", con);
    //   Int32 count1 = (Int32)cmd.ExecuteScalar();
    //  lbltotQue.Text = count1.ToString();
    //  con.Close();

        topicID=((Practice_Test)frm1).cmbTopic.SelectedValue.ToString();

       // clear();
        if (incQuestion <= 40)//&& topicID!= null
        {

            string str = "select * from QuetionBank  where TopicID='" + topicID + "' and QuetionId='" + no + "' ";
            SqlDataAdapter da = new SqlDataAdapter(str, con);
            DataSet ds = new DataSet();
            da.Fill(ds, "QuetionBank");
            //    da.Fill(ds, "Answer");

            if (ds.Tables[0].Rows.Count > 0)
            {
                DataRow dtr;
                int i = 0;
                while (i < ds.Tables[0].Rows.Count)
                {
                    dtr = ds.Tables[0].Rows[i];
                    //   Session["Answer"] = Convert.ToString(Convert.ToInt32(dtr["Correct"].ToString()) - 1);
               LblQuestionNo.Text =+ incQuestion + " " +"/100".ToString();
               lblQuestionId.Text = dtr["QuetionId"].ToString();
               RtfDirection.Text = dtr["Direction"].ToString();
               rtfQuestion.Text = dtr["Question"].ToString();
               rbOptionA.Text=(dtr["OptionA"].ToString());
               rbOptionB.Text=(dtr["OptionB"].ToString());
               rbOptionC.Text = (dtr["OptionC"].ToString());
               rbOptionD.Text = (dtr["OptionD"].ToString());
               rtbOptionE.Text = (dtr["OptionE"].ToString());
               rtbSolution.Text = (dtr["Solution"].ToString());
                    //pbDirection.ImageLocation= dtr["Image_Direction"].ToString();
                    //pbQuestion.ImageLocation = dtr["Image_Quetion"].ToString();
                    //pbOptionA.ImageLocation = dtr["Image_OptionA"].ToString();
                    //pbOptionB.ImageLocation = dtr["Image_OptionB"].ToString();
                    //pbOptionC.ImageLocation = dtr["Image_OptionC"].ToString();
                    //pbOptionD.ImageLocation = dtr["Image_OptionD"].ToString();
                    //pbOptionE.ImageLocation = dtr["Image_OptionE"].ToString();
                    //pbSolution.ImageLocation = dtr["Image_Solution"].ToString();
               lblCorrect.Text = dtr["CorrectAns"].ToString();
                    i++;


                }
            incQuestion += 1;
            }





        }



           // }

        //}

0 个答案:

没有答案