我想要實現的功能:
1.黨我選中checkbox,當前這條記錄的信息顯示到textbox上(根據PRInfoBind()),當前這條紀錄的背景顔色為紅色!
private void PRInfoBind() 
    { 
        int recordCount = 0; 
        string thisPR_ID = ""; 
        string thisMat_ID = ""; 
        string thisSupplier = ""; 
        string thisBuyer = ""; 
        for (int i = 0; i  < this.GridView_PR.Rows.Count; i++) 
        { 
            CheckBox cb_Check = (CheckBox)this.GridView_PR.Rows[i].FindControl("cb_Check"); 
            if (cb_Check.Checked) 
            { 
                this.GridView_PR.Rows[i].BackColor = System.Drawing.Color.Yellow;                 thisPR_ID = this.GridView_PR.Rows[i].Cells[2].Text.ToString().Trim(); 
                thisMat_ID = this.GridView_PR.Rows[i].Cells[3].Text.ToString().Trim(); 
                thisSupplier = ((Label)this.GridView_PR.Rows[i].FindControl("Label1")).Text.ToString().Trim(); 
                string strSql = "select distinct buyer from tbprxz where pr_id='" + thisPR_ID + "' and mat_id='" + thisMat_ID + "'"; 
                thisBuyer = dl.ExcuteScalar(strSql);                 this.DDL_PR_ID.SelectedValue = thisPR_ID.ToString(); 
                this.DDL_Supplier.Items.Insert(0, thisSupplier.ToString()); 
                this.DDL_Buyer.SelectedValue = thisBuyer.ToString(); 
                
            } 
        } 
    }2.當前取消,當前textbox上的信息清空,當前這條紀錄的背景顔色還原!請問大家應該怎麽做?以下就是把上面的問題分開化,但是還是有很多問題
http://topic.csdn.net/u/20080515/11/68a0780a-e5b5-4bba-81c0-d2222b4002de.html
http://topic.csdn.net/u/20080515/09/1698861e-96a9-440b-8ae7-2bea1e43f208.html

解决方案 »

  1.   

    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>无标题页</title>
        <script>
        function changecolor(chk)
        {
            if(chk.checked==true)chk.parentElement.parentElement.style.backgroundColor='red';
            else chk.parentElement.parentElement.style.backgroundColor='white';
        }
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <table>
                <tr>
                    <td style="width: 100px">
                        <input name="ck" type="checkbox" onclick="changecolor(this)" /></td>
                    <td style="width: 100px">
                        呵呵</td>
                </tr>
                <tr>
                    <td style="width: 100px">
                        <input name="ck" type="checkbox" onclick="changecolor(this)" /></td>
                    <td style="width: 100px">
                        哈哈</td>
                </tr>
            </table>
        
        </div>
        </form>
    </body>
    </html>
      

  2.   

    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>无标题页</title>
        <script>
        function changecolor(chk)
        {
            if(chk.checked==true)
            {
            chk.parentElement.parentElement.style.backgroundColor='red';
            }
            else {
            chk.parentElement.parentElement.getElementsByTagName('input')[1].value='';
            chk.parentElement.parentElement.style.backgroundColor='white';
            }
        }
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <table>
                <tr>
                    <td style="width: 100px">
                        <input name="ck" type="checkbox" onclick="changecolor(this)" /></td>
                    <td style="width: 100px">
                        <input id="Text1" type="text" /></td>
                </tr>
                <tr>
                    <td style="width: 100px">
                        <input name="ck" type="checkbox" onclick="changecolor(this)" /></td>
                    <td style="width: 100px">
                        <input id="Text2" type="text" /></td>
                </tr>
            </table>
        
        </div>
        </form>
    </body>
    </html>清空用这个饿