Click here to Skip to main content
15,949,741 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I am developing Online Examination Application .Answers are fetching in radio button. if user click next button that will change question/Answers and also adding Arraylist from selected radion button

Problem is that on click previou button Array list Also Adding except adding it should b updating on previous index.

C#
private void btnPrevious_Click(object sender, EventArgs e)
    {
        CountRating();
           if (i == ds.Tables[0].Rows.Count - 1 || i != 0)
        {
            i--;

            ShowData();
        }

        else
        {
            MessageBox.Show("no record found");
        }
    }


C#
public void CountRating()
      {
          try
          {
              if (radioButton1.Checked == true)
              {
                  RB = radioButton1.Text;
                  radioButton1.Checked = false;
              }
              else if (radioButton2.Checked == true)
              {
                  RB = radioButton2.Text;
                  radioButton2.Checked = false;

              }
              else if (radioButton3.Checked == true)
              {
                  RB = radioButton3.Text;
                  radioButton3.Checked = false;
              }
              else if (radioButton4.Checked == true)
              {
                  RB = radioButton4.Text;
                  radioButton4.Checked = false;
              }
              if (RB == "Excellent")
              {
                  rating = 5;
              }
              else if (RB == "Yes")
              {
                  rating = 5;

              }
              else if (RB == "Good")
              {
                  rating = 4;
              }
              else if (RB == "Average")
              {
                  rating = 3;
              }
              else if (RB == "Fair" || RB == "No")
              {
                  rating = 1;
             }
              else
              {
                  MessageBox.Show("masla");
              }
          }
          catch (Exception ex)
          {
              MessageBox.Show(ex.Message);
          }
      }

C#
public void ShowData()
        {
            key = Convert.ToInt32(ds.Tables[0].Rows[i]["qus_id"]);
            lblQ.Text = "Q. " + ds.Tables[0].Rows[i]["qus_id"].ToString();
            lblQues.Text = ds.Tables[0].Rows[i]["questions"].ToString();
            radioButton1.Text = ds.Tables[0].Rows[i]["Ans1"].ToString();
            radioButton2.Text = ds.Tables[0].Rows[i]["Ans2"].ToString();
            if (ds.Tables[0].Rows[i].IsNull("Ans3"))
            {

                radioButton3.Hide();
                radioButton4.Hide();

            }
            else
            {
                radioButton3.Show();
                radioButton4.Show();
                radioButton3.Text = ds.Tables[0].Rows[i]["Ans3"].ToString();
                radioButton4.Text = ds.Tables[0].Rows[i]["Ans4"].ToString();
            }
        }
Posted
Updated 27-Jul-13 5:56am
v2
Comments
[no name] 26-Jul-13 19:44pm    
What code?
OriginalGriff 27-Jul-13 1:08am    
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind.
Use the "Improve question" widget to edit your question and provide better information.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900