日期:2014-05-16  浏览次数:20905 次

.net 中如何判断选的radiobuttonlist的值与数据库中值相同
string x;
    protected void Button1_Click(object sender, EventArgs e)
    {
        int count = 0;
      //  string anw1,anw2,anw3,anw4,anw5,anw6,anw7,anw8;
        string [] anw=new string[8];
        string[] anwyes=new string [8] ;
        int[] score =new int [8];

      //  string a, b, c, d, e1, f, g, h;
      //  int  t1, t2, t3, t4, t5, t6, t7, t8;
        anw[0] = RadioButtonList1.SelectedItem.Value.ToString();
        anw[1] = RadioButtonList2.SelectedItem.Value.ToString();
        anw[2] = RadioButtonList3.SelectedItem.Value.ToString();
        anw[3] = RadioButtonList4.SelectedItem.Value.ToString();
        anw[4] = RadioButtonList5.SelectedItem.Value.ToString();
        anw[5] = RadioButtonList6.SelectedItem.Value.ToString();
        anw[6] = RadioButtonList7.SelectedItem.Value.ToString();
        anw[7] = RadioButtonList8.SelectedItem.Value.ToString();

        string sql = "SELECT 答案 FROM Que_title where 题目='数据库技术经典习题'";
        string sql1 = "SELECT 分值 FROM Que_title where 题目='数据库技术经典习题'";
        DataTable dt1 = Class1.GetDsFromSql(sql).Tables[0];
        DataTable dt2 = Class1.GetDsFromSql(sql1).Tables[0];
        anwyes[0] = dt1.Rows[0]["答案"].ToString();
        anwyes[1] = dt1.Rows[1]["答案"].ToString();
        anwyes[2] = dt1.Rows[2]["答案"].ToString();
        anwyes[3] = dt1.Rows[3]["答案"].ToString();
        anwyes[4] = dt1.Rows[4]["答案"].ToString();
        anwyes[5] = dt1.Rows[5]["答案"].ToString();
        anwyes[6] = dt1.Rows[6]["答案"].ToString();
        anwyes[7] = dt1.Rows[7]["答案"].ToString();
        score[0] = Convert.ToInt32(dt2.Rows[0]["分值"].ToString());
        score[1] = Convert.ToInt32(dt2.Rows[1]["分值"].ToString());
        score[2] = Convert.ToInt32(dt2.Rows[2]["分值"].ToString());
        score[3] = Convert.ToInt32(dt2.Rows[3]["分值"].ToString());
        score[4] = Convert.ToInt32(dt2.Rows[4]["分值"].ToString());
     &nb