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"
纯粹记录,以免以后又忘记了