Exemplo n.º 1
0
        private void BindRadioButtonList4()
        {
            List <TestClass> myList = new List <TestClass>();

            myList.Add(new TestClass("value1", "数据绑定值 1"));
            myList.Add(new TestClass("value2", "数据绑定值 2"));
            myList.Add(new TestClass("value3", "数据绑定值 3"));
            myList.Add(new TestClass("value4", "数据绑定值 4"));
            myList.Add(new TestClass("value5", "数据绑定值 5"));
            myList.Add(new TestClass("value6", "数据绑定值 6"));

            RadioButtonList4.DataTextField  = "Name";
            RadioButtonList4.DataValueField = "Id";
            RadioButtonList4.DataSource     = myList;
            RadioButtonList4.DataBind();

            RadioButtonList4.SelectedValue = "value2";
        }
Exemplo n.º 2
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            sComplete.CompletedSurveyID = count++;

            sComplete.CompletedSurveyName = ddlSurveyList.Text;

            sComplete.Answer1 = RadioButtonList1.SelectedValue;
            sComplete.Answer2 = RadioButtonList2.SelectedValue;
            sComplete.Answer3 = RadioButtonList3.SelectedValue;
            sComplete.Answer4 = RadioButtonList4.SelectedValue;
            sComplete.Answer5 = RadioButtonList5.SelectedValue;

            sComplete.Question1 = lblQuestion1.Text;
            sComplete.Question2 = lblQuestion2.Text;
            sComplete.Question3 = lblQuestion3.Text;
            sComplete.Question4 = lblQuestion4.Text;
            sComplete.Question5 = lblQuestion5.Text;

            if (sComplete.Answer1 != string.Empty && sComplete.Answer2 != string.Empty &&
                sComplete.Answer3 != string.Empty && sComplete.Answer4 != string.Empty && sComplete.Answer5 != string.Empty)
            {
                lblSaved.Visible = true;

                ddlSurveyList.SelectedIndex = 0;

                lblQuestion1.Visible = false;
                lblQuestion2.Visible = false;
                lblQuestion3.Visible = false;
                lblQuestion4.Visible = false;
                lblQuestion5.Visible = false;

                RadioButtonList1.Visible = false;
                RadioButtonList2.Visible = false;
                RadioButtonList3.Visible = false;
                RadioButtonList4.Visible = false;
                RadioButtonList5.Visible = false;

                RadioButtonList1.ClearSelection();
                RadioButtonList2.ClearSelection();
                RadioButtonList3.ClearSelection();
                RadioButtonList4.ClearSelection();
                RadioButtonList5.ClearSelection();
            }
        }
 protected void Button1_Click(object sender, EventArgs e)
 {
     TextBox1.Text = "";
     TextBox2.Text = "";
     TextBox3.Text = "";
     TextBox4.Text = "";
     TextBox5.Text = "";
     TextBox6.Text = "";
     TextBox7.Text = "";
     TextBox8.Text = "";
     TextBox9.Text = "";
     RadioButtonList1.ClearSelection();
     RadioButtonList2.ClearSelection();
     RadioButtonList3.ClearSelection();
     RadioButtonList4.ClearSelection();
     DropDownList1.ClearSelection();
     DropDownList3.ClearSelection();
     DropDownList4.ClearSelection();
     DropDownList5.ClearSelection();
 }
    protected void Button1_Click(object sender, EventArgs e)
    {
        string s = @"Data Source=localhost; Database=audit_form; User ID=root; Password='******'";



        if (faculty_name_text.Text == "" || sub_text.Text == "" /*|| impr_expt_text.Text == "" || add_cmnt_text.Text == ""*/)
        {
            Page.ClientScript.RegisterStartupScript(this.GetType(), "scripts", "<script>alert('Please fill all compulsory fields');</script>");
        }

        else
        {
            // try
            //{


            if (fac_count <= fac_name.Count)
            {
                Response.Write(fac_count);


                double sum = (Convert.ToDouble(RadioButtonList1.SelectedValue) + Convert.ToDouble(RadioButtonList2.SelectedValue) + Convert.ToDouble(RadioButtonList3.SelectedValue) + Convert.ToDouble(RadioButtonList4.SelectedValue) + Convert.ToDouble(RadioButtonList5.SelectedValue) + Convert.ToDouble(RadioButtonList6.SelectedValue) + Convert.ToDouble(RadioButtonList7.SelectedValue) + Convert.ToDouble(RadioButtonList8.SelectedValue) + Convert.ToDouble(RadioButtonList9.SelectedValue));
                double avg = sum / 9.0;

                String insert1 = "insert into fac_performance(fac_name,q1,q2,q3,q4,q5,q6,q7,q8,q9,c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,Average) values('" + faculty_name_text.Text + "','" + RadioButtonList1.SelectedItem.Value + "','" + RadioButtonList2.SelectedItem.Value + "','" + RadioButtonList3.SelectedItem.Value + "','" + RadioButtonList4.SelectedItem.Value + "','" + RadioButtonList5.SelectedItem.Value + "','" + RadioButtonList6.SelectedItem.Value + "','" + RadioButtonList7.SelectedItem.Value + "','" + RadioButtonList8.SelectedItem.Value + "','" + RadioButtonList9.SelectedItem.Value + "','" + TextBox5.Text + "','" + TextBox6.Text + "','" + TextBox7.Text + "','" + TextBox8.Text + "','" + TextBox9.Text + "','" + TextBox10.Text + "','" + TextBox11.Text + "','" + TextBox12.Text + "','" + TextBox13.Text + "','" + impr_expt_text.Text + "','" + add_cmnt_text.Text + "','" + avg + "')";

                MySqlCommand cmd2 = new MySqlCommand(insert1, con);
                cmd2.ExecuteNonQuery();
                /* Sets every radiobuttonlist to null  */
                { RadioButtonList1.ClearSelection(); RadioButtonList2.ClearSelection(); RadioButtonList3.ClearSelection(); RadioButtonList4.ClearSelection(); RadioButtonList5.ClearSelection(); RadioButtonList6.ClearSelection(); RadioButtonList7.ClearSelection(); RadioButtonList8.ClearSelection(); RadioButtonList9.ClearSelection();

                  TextBox5.Text = String.Empty; TextBox6.Text = String.Empty; TextBox7.Text = String.Empty; TextBox8.Text = String.Empty; TextBox9.Text = String.Empty; TextBox10.Text = String.Empty; TextBox11.Text = String.Empty; TextBox12.Text = String.Empty; TextBox13.Text = String.Empty;  impr_expt_text.Text = String.Empty; add_cmnt_text.Text = String.Empty; }


                if (fac_count == fac_name.Count)
                {
                    Response.Redirect("Student_Login_Page.aspx");
                }
                else
                {
                    faculty_name_text.Text = fac_name[fac_count];
                    sub_text.Text          = sub[fac_count];

                    fac_count += 1;
                }
            }



            else
            {
                /*Button1.Text = "submit"; Session.Clear(); Session.Abandon(); */

                /*Response.ExpiresAbsolute = DateTime.Now;
                 * Response.Expires = 0;
                 * Response.CacheControl = "no-cache";
                 */

                Response.Redirect("Student_Login_Page.aspx");
            }

            //}


            /* catch (Exception ex)
             * {
             *   Console.WriteLine(ex);
             * }
             * finally
             * { con.Close(); }*/
        }
    }
Exemplo n.º 5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)

        {
            DataSet ds1 = GetData2();
            for (int i = 0; i < 10; i++)
            {
                int     Qid  = int.Parse(ds1.Tables["Questions"].Rows[i][0].ToString());
                DataSet ds   = GetData1(Qid);
                int     type = int.Parse(ds1.Tables["Questions"].Rows[i][2].ToString());
                if (type == 0)
                {
                    controlArray[i] = new string[4]
                    {
                        ds.Tables["Choices"].Rows[0][0].ToString(),
                        ds.Tables["Choices"].Rows[1][0].ToString(),
                        ds.Tables["Choices"].Rows[2][0].ToString(),
                        ds.Tables["Choices"].Rows[3][0].ToString()
                    };
                }

                else
                {
                    controlArray[i] = new string[2]
                    {
                        ds.Tables["Choices"].Rows[0][0].ToString(),
                        ds.Tables["Choices"].Rows[1][0].ToString()
                    };
                }
            }

            RadioButtonList1.DataSource = controlArray[0];
            RadioButtonList1.DataBind();
            RadioButtonList2.DataSource = controlArray[1];
            RadioButtonList2.DataBind();
            RadioButtonList3.DataSource = controlArray[2];
            RadioButtonList3.DataBind();
            RadioButtonList4.DataSource = controlArray[3];
            RadioButtonList4.DataBind();
            RadioButtonList5.DataSource = controlArray[4];
            RadioButtonList5.DataBind();
            RadioButtonList6.DataSource = controlArray[5];
            RadioButtonList6.DataBind();
            RadioButtonList7.DataSource = controlArray[6];
            RadioButtonList7.DataBind();
            RadioButtonList8.DataSource = controlArray[7];
            RadioButtonList8.DataBind();
            RadioButtonList9.DataSource = controlArray[8];
            RadioButtonList9.DataBind();
            RadioButtonList10.DataSource = controlArray[9];
            RadioButtonList10.DataBind();
            Label1.Text  = ds1.Tables["Questions"].Rows[0][1].ToString();
            Label2.Text  = ds1.Tables["Questions"].Rows[1][1].ToString();
            Label3.Text  = ds1.Tables["Questions"].Rows[2][1].ToString();
            Label4.Text  = ds1.Tables["Questions"].Rows[3][1].ToString();
            Label5.Text  = ds1.Tables["Questions"].Rows[4][1].ToString();
            Label6.Text  = ds1.Tables["Questions"].Rows[5][1].ToString();
            Label7.Text  = ds1.Tables["Questions"].Rows[6][1].ToString();
            Label8.Text  = ds1.Tables["Questions"].Rows[7][1].ToString();
            Label9.Text  = ds1.Tables["Questions"].Rows[8][1].ToString();
            Label10.Text = ds1.Tables["Questions"].Rows[9][1].ToString();
        }
    }