Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
227 views
in Technique[技术] by (71.8m points)

javascript - 在Gridview中启用/禁用文本框(Enable/disable text box in Gridview)

I want to disable the textbox when the checkbox is checked in a user control (ACSX page).

(我想在用户控件(ACSX页)中选中复选框时禁用文本框。)

These controls are in a gridview.

(这些控件位于gridview中。)

<div>
  <asp:GridView ID="gvModifOuvrageNonControles" runat="server" AutoGenerateColumns="false" SkinID="MarionGridView">
    <Columns>
      <asp:TemplateField HeaderText="NO CONTROL">
        <ItemTemplate>
          <asp:CheckBox ID="cbInspection" OnClick="grisé(this);" runat="server" />
        </ItemTemplate>
      </asp:TemplateField>
      <asp:TemplateField HeaderText="RAISON">
        <ItemTemplate>
          <asp:TextBox ID="txtCause" runat="server"></asp:TextBox>
        </ItemTemplate>
      </asp:TemplateField>
    </Columns>
  </asp:GridView>
</div>
function grisé(obj) {
  alert(obj.getAttribute('id'));
}
  ask by user12456581 translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I am assuming this grid has 3 columns ie 2 Template field and one BoundField cause it will be needed while grabing the textbox..

(我假设此网格有3列,即2个Template字段和一个BoundField,导致在抓取文本框时将需要它。)

在此处输入图片说明
   function grisé(obj) {
            var rowData = obj.parentNode.parentNode;
            //0-based
            // use as: (YourTemplateFieldColumnWhichContainsThatTextBox -1)
            rowData.cells[2].firstElementChild.disabled = true 
        }

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...