通过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);
InsNumTotal.change(); }
<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"
纯粹记录,以免以后又忘记了
posted on 2014-02-18 16:32 Peter.gao 阅读(1773) 评论(0) 编辑 收藏 举报