大家帮我看一下红色部分。
那段代码没有作用。
我想两个checkbox与textbox状态只有一个作用。
protected void Button2_Click1(object sender, EventArgs e)
    {
        for (int i = 0; i < GridView1.Rows.Count; i++)
        {
            string value1 = (this.GridView1.Rows[i].FindControl("Label1") as Label).Text.Trim();
            string value2 = (this.GridView1.Rows[i].FindControl("Label2") as Label).Text.Trim();
            string value4 = (this.GridView1.Rows[i].FindControl("Label4") as Label).Text.Trim();
            string value5 = (this.GridView1.Rows[i].FindControl("Label5") as Label).Text.Trim();
            string value6 = string.Empty;
            string value7 = string.Empty;
            CheckBox cbox1 = (CheckBox)GridView1.Rows[i].FindControl("CheckBox2");
            CheckBox cbox2 = (CheckBox)GridView1.Rows[i].FindControl("CheckBox3");
            TextBox txt = (TextBox)GridView1.Rows[i].FindControl("TextBox6");
            if(cbox1.Checked==true)
            {
                value6 = cbox1.Text;
            }
         
            if(cbox2.Checked==true)
            {
                value7 = cbox2.Text;
            }
            string value8 = (this.GridView1.Rows[i].FindControl("TextBox7") as TextBox).Text.Trim();
            string value9 = (this.GridView1.Rows[i].FindControl("TextBox6") as TextBox).Text.Trim();            bool bo = false;
            if (txt.Text != "")
            {
                bo = true;
            }            if (bo == false)
            {
                if (cbox1.Checked == true)
                {
                    cbox2.Enabled = false;
                    txt.Enabled = false;
                }
                if (cbox2.Checked == true)
                {
                    cbox1.Enabled = false;
                    txt.Enabled = false;
                }
            }
            else
            {
                cbox1.Enabled = false;
                cbox2.Enabled = false;            }
            string sql = "insert into overtime(xm,gh,jz,lb,time1,time2,time3,shijian) values ('" + value1 + "','" + value2 + "','" + value4 + "','" + value5 + "','" + value6 + "','" + value7 + "','" + value8 + "','" + value9 + "')";
            if (ExecuteNonQuery(sql) > 0)
            {
                this.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('数据保存成功');</script>");
            }
            else
            {
                this.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('数据保存失败');</script>");
            }
        }    }

解决方案 »

  1.   

    你这个代码 看起来头好痛啊。。想实现什么功能啊我想两个checkbox与textbox状态只有一个作用。 啥意思?
      

  2.   


            if (c_1.Checked)
                c_2.Enabled = false;
                t_1.Enabled = false;
            if(c_2.Checked)
                 c_1.Enabled = false;
                 t_1.Enabled = false;
             if (t_1.Text!="")
                 c_2.Enabled = false;
                 c_1.Enabled = false;估计楼主是这个意思吧。
    单选有一个选中的话 另外两个控件停止使用 文本框写东西的话两个单选不用
      

  3.   

    我在看treeview这个控件。
    那个自带的不好看,我想改变他默认的样式,不知道有没有这方面的教程或者事例让我看看呢。
      

  4.   

    可以改变样式的。CS的话貌似有难度。。BS的可以改变