@
@
@xaknet2014-10-04 21:33:12
ASP.NET
@xaknet, 2014-10-04 21:33:12

Asp.net - Calculating columns and displaying result without reloading UserController GridView page?

Dear colleagues.
The task arose to implement a table (using GridView or simply Table ) the same as in excel (screenshot) with the ability to enter values ​​​​into the fields and display their multiplication result in a specific table cell. A working example of a table on the screen. I tried to look for a similar implementation without reloading the page, but did not find a similar one. I also note that the data is entered manually online, you do not need to save them, the main thing is to be able to multiply, for example A1 * B1 = C2.
If there are similar examples of implementation, then please help.
Thank you.

Half solved the problem.
It remains to understand how to display the value in asp: Label through javascript, namely the code below. Help you know how.
Table animation : screen.gif
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication5.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 id="Head1" runat="server">
    <title>Untitled Page</title>
    <script type="text/javascript">
        function JvfunonBlur() {
            var grid = document.getElementById('<%=GridView1.ClientID %>');

            var txtHeadCount;
            var totalSumMandays = 0;

            var txtWorkdaysPerHeadcount;
            var valueResultManhours;

            var totalManhours = 0;


            for (i = 0; i < grid.rows.length; i++) {
                txtHeadCount = grid.rows[i].cells[1];
                txtWorkdaysPerHeadcount = grid.rows[i].cells[2];

                for (j = 0; j < txtHeadCount.childNodes.length; j++) {
                    if (txtHeadCount.childNodes[j].type == "text") {
                        if (!isNaN(txtHeadCount.childNodes[j].value) && txtHeadCount.childNodes[j].value != "") {

                            

                            txtValueResultMandays = parseInt(txtHeadCount.childNodes[j].value) * parseInt(txtWorkdaysPerHeadcount.childNodes[j].value);

                            document.getElementById('<%= GridView1.ClientID %>').getElementsByTagName('txtValueResultMandays').value = txtValueResultMandays;
                        }
                    }
                }
            }
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false" OnRowDataBound="GridView1_RowDataBound">
                    <Columns>
                        <asp:BoundField DataField="Resource Demand" HeaderText="Resource Demand" />

                        <asp:TemplateField HeaderText="Headcount">
                            <ItemTemplate>
                                <asp:TextBox ID="txtHeadCount" Text='<%#Eval("idHeadCount") %>' runat="server">
                                </asp:TextBox>
                            </ItemTemplate>
                        </asp:TemplateField>

                        <asp:TemplateField HeaderText="Workdays per Headcount">
                            <ItemTemplate>
                                <asp:TextBox ID="txtWorkdaysPerHeadcount" Text='<%#Eval("idWorkdaysPerHeadcount") %>'
                                    runat="server">
                                </asp:TextBox>
                            </ItemTemplate>
                        </asp:TemplateField>

                        <asp:TemplateField HeaderText="Mandays">
                            <ItemTemplate>
                                <asp:Label ID="txtValueResultMandays" runat="server"></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>

                        <asp:TemplateField HeaderText="Manhours">
                            <ItemTemplate>
                                <asp:Label ID="resultManhours" runat="server"></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>

                    </Columns>
                </asp:GridView>
                Total
                <br />
                <asp:TextBox ID="txttotalSumMandays" runat="server"></asp:TextBox>
                <asp:TextBox ID="txttotalManhours" runat="server"></asp:TextBox>
                <br />
            </ContentTemplate>
        </asp:UpdatePanel>
    </div>
    </form>
</body>
</html>

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Voucik, 2014-10-15
@Voucik

Well shit like this

<!DOCTYPE HTML>
<html>
  <head> </head>
  <body>

    <script>

function Start()
{
 document.all('lb').innerHTML ="hello word"
}


    </script>
<label id= "lb">aaaaaaaa</label>
<input type="button" onclick="Start()">
  </body>
</html>

M
Maxim Fedorov, 2016-10-24
@qonand

if I understood the problem correctly, then to select analogues for a certain idprice

SELECT * FROM analog  WHERE num IN (SELECT num FROM price WHERE idprice = 1)

M
Max, 2016-10-24
@AloneCoder

4 hours? How many records do you have?
Regardless of your question, it seems to me that you do not have enough indexes in the tables or they are not correct if they are
. And about the question - try using IN in the selections

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question