本文介绍了Javascript在文本框上显示gridview列的总和。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 先生,我有一个Gridview。我在一个列中的文本框。我需要当我在gridview文本框中输入数字时,它会计算文本框的总和并显示另一个文本框。我的asp代码在这里: - < ; asp:GridView ID = GridOtherFee runat = server AutoGenerateColumns = false CssClass = mGrid DataSourceID = SqlOtherFee > < 列 > ; < asp:BoundField DataField = Abb HeaderText = FeeHead ReadOnly = True HeaderStyle-Width = 100px / > < asp:TemplateField SortExpression = 金额 HeaderText = 金额 ItemStyle-HorizontalAlign = 右 HeaderStyle-HorizontalAlign = 右 HeaderStyle-Width = 150px > < ItemTemplate > < asp:TextBox ID = TxtRecd runat = server 宽度 = 100px AutoPostBack = true CssClass = aligntext > < / asp:TextBox > < / ItemTemplate > < / asp:TemplateField > < /列 > < / asp:GridView > < asp:TextBox ID =txtFeeRecdrunat =servername =aWidth =100 pxReadOnly =trueCssClass =aligntext> 当我输入数字时在gridview txtrecd文本框中显示textfeereced textbox中的显示总和.. 解决方案 在某些按钮单击或新行创建或任何您想要的事件上调用此方法 private void GrandTotal() { float GTotal = 0f; for ( int i = 0 ; i < GridView1.Rows.Count; i ++) { String total =(GridView1.Rows [i] .FindControl( lblTotal) as Label).Text; GTotal + = Convert.ToSingle(total); } txtTotal.text = GTotal.toString(); } 希望它有所帮助.. Sir, i have a Gridview. in which i take a textbox in a column. i need that when i enter numbers in gridview textbox then it calculate the sum of textbox and show one another textbox. my asp code is here:-<asp:GridView ID="GridOtherFee" runat="server" AutoGenerateColumns="false" CssClass="mGrid" DataSourceID="SqlOtherFee"> <Columns> <asp:BoundField DataField="Abb" HeaderText="FeeHead" ReadOnly="True" HeaderStyle-Width="100px"/> <asp:TemplateField SortExpression="Amount" HeaderText=" Amount" ItemStyle-HorizontalAlign="Right" HeaderStyle-HorizontalAlign="Right" HeaderStyle-Width="150px"> <ItemTemplate> <asp:TextBox ID="TxtRecd" runat="server" Width="100px" AutoPostBack="true" CssClass="aligntext"></asp:TextBox> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView> <asp:TextBox ID="txtFeeRecd" runat="server" name="a" Width="100px" ReadOnly="true" CssClass="aligntext" >when i enter digits in gridview txtrecd textbox the sum of show in textfeereced textbox.. 解决方案 Call this Method on some button click or on new row creation or whatever event you want toprivate void GrandTotal() { float GTotal = 0f; for (int i = 0; i < GridView1.Rows.Count; i++) { String total = (GridView1.Rows[i].FindControl("lblTotal") as Label).Text; GTotal += Convert.ToSingle(total); } txtTotal.text=GTotal.toString(); }Hope it will help.. 这篇关于Javascript在文本框上显示gridview列的总和。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-22 23:59