jQuery的总gridview列. [英] total gridview column with jquery.

查看:53
本文介绍了jQuery的总gridview列.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好.

我想使用jquery总计gridview列.
我有一个执行初始计算的javascript函数,然后调用应该合计该列的calculate jquery函数.

当前正在获取对象预期错误.

Javascript计算代码如下.

Hello.

I''m looking to total a gridview column using jquery.
I have a javascript function that does the initial calculations then calls the calculate jquery function that is supposed to total the column.

Getting an object expected error at present.

Javascript calculation code below.

function multiply(Rate, number, total) {

       var grid = document.getElementById('GridView1');
       var num = parseFloat(document.getElementById(number).value);
       var tot = document.getElementById(total);

       var totValue = parseFloat(((Rate * num)));
       var totValueRound = Math.round(totValue);
       var totValueRound = totValue;
       tot.innerHTML = "$" + totValue.toFixed(2);
       calculate();



jQuery代码计算下面的列.



Jquery code to calculate the column below.

<script src="jquery-1.7.1.min.js" type="text/javascript"></script>
    <script language="javascript" type="text/javascript">
        
        function calculate() {
            var values = 0;
            $(".total").each(function(){
            values += parseInt($(this).html());
            $("#lblTotalAmount").html(values);  
        }
    </script>



在下方标记



Mark up below

 <asp:GridView ID="GridView1" runat="server"

AutoGenerateColumns="False" OnRowDataBound="GridView1_RowDataBound" 

            DataSourceID="AccessDataSource1" 

            ShowFooter="True" style="margin-bottom: 0px">
            <Columns>
            <asp:TemplateField HeaderText="Devices And Services" Visible="True" HeaderStyle-HorizontalAlign="Left"  FooterText="Payable monthly in advance (excluding Agreement items):" ItemStyle-BackColor="#CCCCCC">
                    <ItemTemplate>
                        <asp:Label ID="lblItemDescription" runat="server" Width="382"

Text='<%# Eval("itemDescription") %>'></asp:Label>
                    </ItemTemplate>

<HeaderStyle HorizontalAlign="Left"></HeaderStyle>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Rate">
                    <ItemTemplate>
                        <asp:Label ID="lblRate" runat="server" width="50" ></asp:Label>
                       
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Number" ControlStyle-BackColor="#FFFFCC">
                    <ItemTemplate>
                        <asp:TextBox ID="txtBoxNumber" Width="100px"

runat="Server"  />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Total" ItemStyle-CssClass="total">
                    <ItemTemplate>                  
                        <asp:Label ID="lblTotal" runat="Server"  Width="106"  />
                    </ItemTemplate>
                    <FooterTemplate>
                          
                 <asp:Label ID="lblTotalAmount" runat="server"  />        
                
                    </FooterTemplate>
                </asp:TemplateField>
              
               
                  
                    
                
            </Columns>
            <FooterStyle Font-Bold="True" />
        </asp:GridView>

推荐答案

" + totValue.toFixed(
" + totValue.toFixed(2); calculate();



jQuery代码计算下面的列.



Jquery code to calculate the column below.

<script src="jquery-1.7.1.min.js" type="text/javascript"></script>
    <script language="javascript" type="text/javascript">
        
        function calculate() {
            var values = 0;


( .total").each( parseInt (
(".total").each(function(){ values += parseInt(


( this ).html( ));
(this).html());


这篇关于jQuery的总gridview列.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆