通过JS触发TextBox的ontextchanged事件,并获取TextBox所在GridView的那一行

 protected void txtInsNum_TextChanged(object sender, EventArgs e)
    {
        TextBox t = (TextBox)sender;

        GridViewRow drv = (GridViewRow)t.NamingContainer;

        int rowIndex = drv.RowIndex;
       

      
    }
 function txtInsNum(txt) {
            var td = txt.parent();
            var InsNumTotal = td.find("input:eq(3)");
            InsNumTotal.val(td.find("input:eq(0)").val() * 1 + td.find("input:eq(1)").val() * 1 + td.find("input:eq(2)").val() * 1);                     
        }

 

  <asp:TemplateField HeaderText="ORDER QTY READY FOR INSPECTION">
    <ItemTemplate>
        <asp:TextBox ID="txtInsNum1" onblur="txtInsNum($(this))"  runat="server" ></asp:TextBox>
         <asp:TextBox ID="txtInsNum2" onblur="txtInsNum($(this))"   runat="server" ></asp:TextBox>
        <asp:TextBox ID="txtInsNum3" onblur="txtInsNum($(this))"   runat="server" ></asp:TextBox>
         <asp:TextBox ID="txtInsNumTotal" AutoPostBack="true" Enabled="false" OnTextChanged="txtInsNum_TextChanged" runat="server" ></asp:TextBox>
    </ItemTemplate>
</asp:TemplateField>

需要注意 txtInsNumTotal 控件的 AutoPostBack="true"   

纯粹记录,以免以后又忘记了

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。