Click here to Skip to main content
15,896,557 members
Please Sign up or sign in to vote.
1.75/5 (4 votes)
See more:
XML
<%@ Page Language="C#" AutoEventWireup="true" 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></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 () {
            alert("dddd");
            //Column index value of price field (Column index start from 1)
            var columnIndexValue = 2;

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

                $('#txttotal').val(total.toFixed());


            });

        });


    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <table  >
            <tr>
                <td>
                    <table>
                        <tr>
                            <td>
                                <table>
                                    <tr>
                                        <td >
                                            <asp:GridView ID="gvAvail" Width="500px" CssClass="tableView" runat="server" ShowHeader="False"
                                                ShowFooter="True" GridLines="None" AutoGenerateColumns="False" CellPadding="4"
                                                CellSpacing="1" AllowSorting="True">
                                                <Columns>
                                                    <asp:TemplateField>
                                                        <%--<EditItemTemplate>
                                                            <asp:CheckBox ID="CheckBox1" runat="server" Checked='<%# Bind("selected") %>' />
                                                        </EditItemTemplate>--%>
                                                        <ItemTemplate>
                                                            <asp:CheckBox ID="CheckBox1" runat="server" Enabled="true" />
                                                        </ItemTemplate>
                                                    </asp:TemplateField>
                                                    <asp:TemplateField HeaderText="Price" ItemStyle-VerticalAlign="Top">
                                                        <%--<EditItemTemplate>
                                                            <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("price") %>'></asp:TextBox>
                                                        </EditItemTemplate>--%>
                                                        <ItemStyle HorizontalAlign="Left" VerticalAlign="Middle" />
                                                        <ItemTemplate>
                                                            <img src="images/rupeesymbol.jpg" alt="" />
                                                            <%#Eval("EmpSalary") %>
                                                            /-
                                                        </ItemTemplate>
                                                    </asp:TemplateField>
                                                </Columns>
                                                <HeaderStyle HorizontalAlign="Left" />
                                                <FooterStyle HorizontalAlign="Left" />
                                                <AlternatingRowStyle BackColor="WhiteSmoke" Wrap="True" />
                                            </asp:GridView>
                                            <asp:TextBox ID="txttotal" runat="server"></asp:TextBox>

                                        </td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
        <asp:Button ID="btnAddcart" runat="server" Text="Add To Cart" Font-Bold="True" Font-Names="Verdana"
            Font-Size="Medium" Height="36px" OnClick="btnAddcart_Click" Width="128px" />
    </div>
    </form>
</body>
</html>





i reffered to this website only
[^]

my task is also same i want the same out put please help me i am a fresher
Posted
Updated 14-Oct-11 0:07am
v3
Comments
OriginalGriff 14-Oct-11 6:02am    
Please, try to help us to help you. Don't title your question "its not working can u help me please" - it tells us nothing about the problem you are having, so we can't tell if we can help.
Instead, describe the area of your problem - briefly - and then in the body of you question describe what is wrong. At the moment, we can't tell what your problem is without running your code and trying to work out what it should be doing, from what it isn't. That wastes our time, and that wastes yours - because there is a good chance that any answer is not related to the problem you are having.
Use the "Improve question" widget to edit your question and provide better information.
Simon Bang Terkildsen 14-Oct-11 6:03am    
Do you expect us to figure out what problem you encountered and then also solve it for you? If you had stated what the problem was, you would have a chance of getting a solution.

Click "Improve question" to add details about the problem you're facing.
I.explore.code 14-Oct-11 6:38am    
get rid of the table then... :) the use of tables is discouraged in modern web development anyway...

Hi,

just check this once you'll get an idea what i did

ASP.NET
<div id="resdiv">0</div>
 <br />
     <asp:gridview id="GridView1" runat="server" autogeneratecolumns="false" xmlns:asp="#unknown">
     <columns>
       <asp:templatefield>
          <HeaderTemplate >
      ID

      </HeaderTemplate>
      <itemtemplate>
          <%#Eval("id") %>

      </itemtemplate>
      <footertemplate>

      </footertemplate>

       </asp:templatefield>
       <asp:templatefield>
            <HeaderTemplate >Value </HeaderTemplate>
      <itemtemplate><![CDATA[<%#Eval("value") %>]]></itemtemplate>
      <footertemplate></footertemplate>
       </asp:templatefield>
       <asp:templatefield>
          <HeaderTemplate >Add</HeaderTemplate>
      <itemtemplate><input type ="checkbox" onclick='addthis(this,<%#Eval("value") %>)' /></itemtemplate>
      <footertemplate></footertemplate>

       </asp:templatefield>
     </columns>
     </asp:gridview>


And javascript file contains following code

JavaScript
function addthis(tid, val1) {
       if (tid.checked) {
           document.getElementById("resdiv").innerText = parseInt(document.getElementById("resdiv").innerText) + parseInt(val1);
       }
       else {
           document.getElementById("resdiv").innerText = parseInt(document.getElementById("resdiv").innerText) - parseInt(val1);
       }


   }


And code behind file contains
C#
DataTable dt = new DataTable();
 protected void Page_Load(object sender, EventArgs e)
 {

     if (!IsPostBack)
     {
         filldata();
     }

 }

 public void filldata()
 {

     dt.Columns.Add("id");
     dt.Columns.Add("value");


     addrowin("1", "12");
     addrowin("2", "45");
     addrowin("3", "78");
     addrowin("4", "85");
     addrowin("5", "78");
     addrowin("6", "15");
     addrowin("7", "45");
     addrowin("8", "98");
     addrowin("9", "78");


     GridView1.DataSource = dt;
     GridView1.DataBind();
 }
 public void addrowin(string uid, string pid)
 {
     DataRow dr = dt.NewRow();
     dr[0] = uid;
     dr[1] = pid;

     dt.Rows.Add(dr);
 }


all the Best
 
Share this answer
 
Comments
yerrojumeher 14-Oct-11 8:30am    
thank you it worked.thanks a lot. i way trying in javascript for 2 days.thanks man.
Muralikrishna8811 14-Oct-11 8:32am    
most welcome
Have changed and its working for me know. Add class A1 to textbox dummy class just to get the textbox

XML
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>

    <script type="text/javascript">

        $(function () {
            alert("dddd");
            //Column index value of price field (Column index start from 1)
            var columnIndexValue = 2;

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

                var total = 0;
                 $("#gvAvail :checked").each(function() {                
                 var val=$('input.A1').val();
                    total += parseInt(val);

                });

                $('#txttotal').val(total.toFixed());


            });

        });


    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <b>LINQ stand for Language-Integrated Query.
        <br />
        <br />
        Basically LINQ address the current database development model in the context of Object Oriented Programming Model. If some one wants to develop database application on .Net platform the very simple approach
he uses ADO.Net. ADO.Net is serving as middle ware in application and provides complete object oriented wrapper around the database SQL. Developing application in C# and architect of C#.
            <br /><br />
             <i>"Microsoft original motivation behind LINQ was to address the impedance  mismatch between programming languages and database."</i> </b>
            <br />
            <br />
    </div>

    <div>
        <table  >
<tr>
<td>
<table>
<tr>
<td>
<table class="as">
<tr >
<td  >
                     <asp:GridView ID="gvAvail" Width="500px" CssClass="tableView" runat="server" ShowHeader="False"ShowFooter="True"                                                GridLines="None" CellPadding="4" CellSpacing="1" >                                            
 <Columns>
   <asp:TemplateField>
  <ItemTemplate>
  <asp:CheckBox ID="CheckBox1" runat="server" CssClass="abc" />
   </ItemTemplate>
    </asp:TemplateField>
   <asp:TemplateField HeaderText="Price" ItemStyle-VerticalAlign="Top">
  <%--<EditItemTemplate>
  <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("price") %>'></asp:TextBox>
  </EditItemTemplate>--%>
   <ItemStyle HorizontalAlign="Left" VerticalAlign="Middle" />
  <ItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='10' CssClass="A1"></asp:TextBox>

</ItemTemplate>
</asp:TemplateField>
</Columns> </asp:GridView>

        <asp:TextBox ID="txttotal" runat="server"></asp:TextBox>
    </div>
    </form>
</body>
</html>
 
Share this answer
 
v2

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