Click here to Skip to main content
15,901,373 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
XML
<%@ Page Language="C#" AutoEventWireup="true" ViewStateMode="Enabled"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js">
    </script>

    <script type="text/javascript">

        $(function () {

            //Column index value of price field (Column index start from 1)
            var columnIndexValue = 2;

            var checked = $('input:checkbox').click(function (e) {

                var total = 0;
                $("tr:has(:checkbox:checked) td:nth-child(" + columnIndexValue + ")").each(function () {
                    total += parseInt($(this).text());
                });

                $('#lbl').text("your total is:" + total.toFixed());


            });

        });


 </script>


</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
            CellPadding="3" GridLines="None" BackColor="White" BorderColor="White"
            BorderStyle="Ridge" BorderWidth="2px" CellSpacing="1"
            onrowcommand="GridView1_RowCommand" onrowdatabound="GridView1_RowDataBound">
        <Columns>
            <asp:TemplateField>
                <ItemTemplate>
                    <asp:CheckBox ID="Check" runat="server" />
                    <%--<input type="checkbox"  id="chk" runat="server" />--%>
                </ItemTemplate>
            </asp:TemplateField>

            <asp:TemplateField HeaderText="Emp Salary">
                <ItemTemplate>
                    <%#Eval("EmpSalary") %>
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
            <FooterStyle BackColor="#C6C3C6" ForeColor="Black" />
            <RowStyle BackColor="#DEDFDE" ForeColor="Black" />
            <SelectedRowStyle BackColor="#9471DE" Font-Bold="True" ForeColor="White" />
            <PagerStyle BackColor="#C6C3C6" ForeColor="Black" HorizontalAlign="Right" />
            <HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#E7E7FF" />
        </asp:GridView>
    <p id="tot" ></p>
    </div>
        <br />
        <asp:LinkButton ID="LinkButton1" runat="server" OnClick="LinkButton1_Click">Select All</asp:LinkButton>
        &nbsp;|
        <asp:LinkButton ID="LinkButton2" runat="server" OnClick="LinkButton2_Click">Deselct All</asp:LinkButton>
        &nbsp;|
        <asp:LinkButton ID="LinkButton3" runat="server" OnClick="LinkButton3_Click">Delete</asp:LinkButton>
        <br />
        <asp:Label ID="lbl" runat="server"></asp:Label>
        <asp:TextBox ID="txt" runat="server" MaxLength="50"></asp:TextBox>
    <br />
    <br />
    <br />
    <table>
    <tr>
    <td id="tttt">

    </td>
    </tr>
    </table>

    <asp:Button ID="Button1" runat="server" onclick="Button1_Click"
        style="height: 26px" Text="Button" />
    </form>
</body>
</html>
Posted
Comments
[no name] 11-Oct-11 8:11am    
And what issues do you have?

Try this.
JavaScript
$("#txt").val("your total is:" + total.toFixed());
 
Share this answer
 
for a textbox you need to use $(#eleId).val instead of .text
 
Share this answer
 
v2
JavaScript
$("#txt").text("your total is:" + total.toFixed());


Will work fine for you
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900