Gridview 中 Enable/disable 文本框的问题,javascript/Jquery

Problem with Enable/disable text box in Gridview, with javascript/Jquery

提前感谢您的帮助:我有一个 Gridview,只有当复选框被激活时,TextBox 才会被激活。我设法在 Javascript 中实现了这个功能。但问题是默认情况下启用文本框(见图)。按下复选框两次后,它会被停用。我想解决这个问题,你能帮帮我吗?太感谢了 ! Look the image here !!

这是我的代码:

<div>
       <asp:GridView ID="gvModifOuvrageNonControles" runat="server" AutoGenerateColumns="false" SkinID="MarionGridView">
            <Columns>
                <asp:BoundField DataField="MirePrincipal" HeaderText="OUVRAGE PRINCIPAL" />
                <asp:BoundField DataField="LibelleMireSecondaire" HeaderText="OUVRAGE SECONDAIRE" />
                <asp:TemplateField HeaderText="NON CONTROLE">
                    <ItemTemplate>
                        <asp:CheckBox ID="cbInspection" OnClick="grisé(this);" runat="server" />
                    </ItemTemplate>
                </asp:TemplateField> 
                <asp:BoundField DataField="Libellel" HeaderText="LIBELLE DES MS,VI,PI,SU,CP,PL,PF" />
                <asp:TemplateField HeaderText="RAISON">
                    <ItemTemplate>
                        <asp:TextBox ID="txtCause" On runat="server"></asp:TextBox>
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
        </asp:GridView>
    </div>
    <script type="text/javascript">

        function grisé(obj) {
            var rowData = obj.parentNode.parentNode;
            if (rowData.cells[2].firstElementChild.checked == false) {
                rowData.cells[4].firstElementChild.disabled = true;
            }
            else {
                rowData.cells[4].firstElementChild.disabled = false;

            }}

    </script> 

您可以将文本框的Enable 属性设置为false

<asp:TextBox ID="txtCause" runat="server" Enabled="false"></asp:TextBox>