如何计算gridview值plz帮助任何身体? [英] how to calculate gridview values plz help any body?

查看:89
本文介绍了如何计算gridview值plz帮助任何身体?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="demos.aspx.cs" Inherits="ADMIN_demos" %>

<!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 id="Head1" runat="server">
   <title>CMPSS</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="imagetoolbar" content="no" />
<link rel="stylesheet" href="../styles/layout.css" type="text/css" />
 <link type="text/css" href="../css1/ui-lightness/jquery-ui-1.8.19.custom.css" rel="stylesheet" />
<script type="text/javascript" src="../js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="../js/jquery-ui-1.8.19.custom.min.js"></script>
<script type="text/javascript">
    function getValues(val) {

        var numVal1 = parseInt(document.getElementById("txtmrp").value);
        var numVal2 = parseInt(document.getElementById("txtptr").value);
        var numVal3 = parseInt(document.getElementById("txtpts").value);

        var totalValue = numVal1 + numVal2 + numVal3;

        document.getElementById("txtOqnty").value = totalValue;
    }
</script>

<style>
input.numbox{
    width:30px;
    height:20px;
}
textarea.mainbox{
    width:200px;
    height:100px;
}
</style>
    <style type="text/css">

table{
    width:100%;
    border-collapse:collapse;
    table-layout:auto;
    vertical-align:top;
    margin-bottom:15px;
    border:1px solid #CCCCCC;
            margin-right: 0px;
        }

table thead th, table tbody td{
    padding:5px;
    border-collapse:collapse;
    }

table tbody td{
    vertical-align:top;
    border-collapse:collapse;
    border-left:1px solid #CCCCCC;
    border-right:1px solid #CCCCCC;
    }

    </style>
</head>
<body id="top" style="background-color:White">
    <form action="" id="cakeform" onsubmit="return false;" runat="server">
<div class="wrapper col1">
  <div id="topbar">
     <p>Mobile: 91 44 2474 5051 | Mail: admin@cydex.co.in</p>
    <ul>
      <li><p>Fax: 91 44 2471 1789&nbsp; </p></li>
      <li class="last"><a href="../Default.aspx">Logout</a></li>
    </ul>
    <br class="clear" />
  </div>
</div>
<!-- ####################################################################################################### -->
<div class="wrapper col2">
  <div id="header">
    <div class="fl_left">
      <h1><asp:Label ID="Label4" runat="server"

              Text="Label">CMPSS</asp:Label></h1>
      <p></p>
    </div>
      <%-- <div class="fl_right"> <a href="#"><img src="images/demo/468x60.gif" alt="" /></a> </div>--%>
    <br class="clear" />
     <br class="clear" />
      <br class="clear" />
  </div>
</div>
<!-- ####################################################################################################### -->
<div class="wrapper col3">
  <div id="topnav">
    <ul>
      <li class="active"><a href="#">Home</a><span></span></li>
      <li><a href="demos.aspx">Order Form</a><span></span>
        <%--<ul>
          <li><a href="RawMaterial.aspx">Raw Material</a></li>
          <li><a href="BricksType.aspx">Bricks Type</a></li>
          <li><a href="Bricksizes.aspx">Bricks Sizes</a></li>
          <li><a href="AEmployee.aspx">Employee</a></li>
          <li><a href="Suppliers.aspx">Suppliers</a></li>
          <li><a href="Customer.aspx">Customers</a></li>
         </ul>--%>
      </li>
     <li><a href="../login.aspx">Sign IN</a><span></span>
        <%--<ul>
          <li><a href="Sale.aspx">Sales</a></li>
          <li><a href="Purchas.aspx">Purchase</a></li>
          <li><a href="AExpanses.aspx">Expanses</a></li>
          <li><a href="IssueRawM.aspx">Issue Raw Materials</a></li>
          <li><a href="BricksReceiptI.aspx">Issue Bricks</a></li>
        </ul>
      </li>--%>
      <li><a href="Signup.aspx">REGISTARTION</a><span></span>
        <%--<ul>
          <li><a href="SaleReport.aspx">Sales</a></li>
          <li><a href="BrickStocks.aspx">Bricks Stock</a></li>
          <li><a href="RawStock.aspx">Raw Material Stock</a></li>
        </ul>--%>
      </li>
    </ul>
    <br class="clear" />
  </div>
</div>
    <%--<form id="form1" runat="server">--%>
    <p>
        <asp:Label ID="Label1" runat="server" Font-Bold="True" Font-Size="Large"

            ForeColor="#FF3300" Text="Order Form Details"></asp:Label>
        <br />
    </p>
    <div>

        <asp:GridView ID="grvStudentDetails" runat="server" AutoGenerateColumns="False"

            CellPadding="4" ForeColor="#333333" GridLines="None"

            OnRowDeleting="grvStudentDetails_RowDeleting" ShowFooter="True"

            Style="text-align: left" Width="97%">
            <Columns>
                <asp:BoundField DataField="RowNumber" HeaderText="SNo" />
               <asp:TemplateField HeaderText="Product">
                    <ItemTemplate>
                        <asp:DropDownList ID="drpproduct" runat="server">
                            <asp:ListItem>Select</asp:ListItem>
                            <asp:ListItem Value="G">abc</asp:ListItem>
                            <asp:ListItem Value="P">bcd</asp:ListItem>
                        </asp:DropDownList>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"

                            ControlToValidate="drpproduct" ErrorMessage="*" InitialValue="Select"></asp:RequiredFieldValidator>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="seats">
                    <ItemTemplate>
                        <asp:DropDownList ID="drpseats" runat="server">
                            <asp:ListItem>Select</asp:ListItem>
                            <asp:ListItem Value="G">10</asp:ListItem>
                            <asp:ListItem Value="P">20</asp:ListItem>
                        </asp:DropDownList>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server"

                            ControlToValidate="drpseats" ErrorMessage="*" InitialValue="Select"></asp:RequiredFieldValidator>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="MRP">
                    <ItemTemplate>
                        <asp:TextBox ID="txtmrp" runat="server" MaxLength="3" Width="66px" onkeyup="getValues()" ></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"

                            ControlToValidate="txtmrp" ErrorMessage="*" SetFocusOnError="True"></asp:RequiredFieldValidator>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="PTR">
                    <ItemTemplate>
                        <asp:TextBox ID="txtptr" runat="server" MaxLength="3" Width="66px" onkeyup="getValues()" ></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server"

                            ControlToValidate="txtptr" ErrorMessage="*" SetFocusOnError="True"></asp:RequiredFieldValidator>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="PTS">
                    <ItemTemplate>
                        <asp:TextBox ID="txtpts" runat="server" MaxLength="3" Width="66px" onkeyup="getValues()"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server"

                            ControlToValidate="txtpts" ErrorMessage="*" SetFocusOnError="True"></asp:RequiredFieldValidator>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Order Quantity">
                    <ItemTemplate>
                        <asp:TextBox ID="txtOqnty" runat="server" MaxLength="50" Width="66px"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server"

                            ControlToValidate="txtOqnty" ErrorMessage="*" SetFocusOnError="True"></asp:RequiredFieldValidator>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Free Quantity">
                    <ItemTemplate>
                        <asp:DropDownList ID="drpQualification" runat="server">
                            <asp:ListItem>Select</asp:ListItem>
                            <asp:ListItem Value="G">10%</asp:ListItem>
                            <asp:ListItem Value="P">20%</asp:ListItem>
                        </asp:DropDownList>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator9" runat="server"

                            ControlToValidate="drpQualification" ErrorMessage="*" InitialValue="Select"></asp:RequiredFieldValidator>
                    </ItemTemplate>
                </asp:TemplateField>
                 <asp:TemplateField HeaderText="Bill Value">
                    <ItemTemplate>
                        <asp:TextBox ID="txtbill" runat="server" MaxLength="50" Width="66px"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="server"

                            ControlToValidate="txtbill" ErrorMessage="*" SetFocusOnError="True"></asp:RequiredFieldValidator>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Margin">
                    <ItemTemplate>
                        <asp:TextBox ID="txtmargin" runat="server" MaxLength="50" Width="66px"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator8" runat="server"

                            ControlToValidate="txtmargin" ErrorMessage="*" SetFocusOnError="True"></asp:RequiredFieldValidator>
                    </ItemTemplate>
                    <FooterStyle HorizontalAlign="Right" />
                    <FooterTemplate>
                        <asp:Button ID="ButtonAdd" runat="server" OnClick="ButtonAdd_Click"

                            Text="Add New Row" />
                    </FooterTemplate>
                </asp:TemplateField>
                <asp:CommandField ShowDeleteButton="True" />
            </Columns>
            <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
            <RowStyle BackColor="#EFF3FB" />
            <EditRowStyle BackColor="#2461BF" />
            <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
            <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
            <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
            <AlternatingRowStyle BackColor="White" />
        </asp:GridView>

    </div>
    <p>
                        <%--<asp:Button ID="Button2" runat="server" BackColor="Transparent"
                            onclick="Button2_Click" BorderStyle="None" />--%>
                        <asp:TextBox ID="txtTamount" runat="server" BackColor="#FFFFCC" Width="167px"

                            MaxLength="150" Height="20px" onblur="totalamt()"></asp:TextBox>
                        <asp:HiddenField ID="Hiddenrowtot" runat="server" />
                        </p>
    </form>
</body>
</html>

推荐答案

Vedakumar, could you please refine your question? I guess we are getting lost in the long code lines above. Calc on grid is fairly simple , so if you could get the right question posted you will get a quick answer.



-Guru
Vedakumar, could you please refine your question? I guess we are getting lost in the long code lines above. Calc on grid is fairly simple , so if you could get the right question posted you will get a quick answer.

-Guru


check your textbox id’s when u do calculations at client side using javascript or jquery the id will be changed bcoz the contrls i.e textboxes are nested inside the gridview check page source on the browser and see the textbox is



for eg: it coluld be like gridview1_textbox1...........................



and also call your function getValues() where it is nescessary







but it would be easy to code to do on server side rather than client side bcoz the controls nested inside other controls
check your textbox id's when u do calculations at client side using javascript or jquery the id will be changed bcoz the contrls i.e textboxes are nested inside the gridview check page source on the browser and see the textbox is

for eg: it coluld be like gridview1_textbox1...........................

and also call your function getValues() where it is nescessary



but it would be easy to code to do on server side rather than client side bcoz the controls nested inside other controls


这篇关于如何计算gridview值plz帮助任何身体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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