日期:2014-05-17 浏览次数:20373 次
<form id="form1" runat="server"> <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false"> <Columns> <asp:BoundField DataField="ID" HeaderText="ID" /> <asp:BoundField DataField="Name" HeaderText="Name" /> <asp:TemplateField HeaderText="InputOne"> <ItemTemplate> <asp:TextBox ID="TextBox1" runat="server" onblur="Caculate(this)"></asp:TextBox> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="InputTwo"> <ItemTemplate> <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView> <asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" /> <script type="text/javascript"> function Caculate(obj){ if(obj.value.length<=0){ return; } var ct = 5; var PN = obj.parentNode; while(PN.tagName!="TD") PN=PN.parentNode; var nt = PN.nextSibling; while(nt.tagName!="TD") nt = nt.nextSibling; var ntTxt = nt.firstChild; ntTxt.value = ct*obj.value; } </script> </form>