Solved

How use jquery to add totals in gridview

Posted on 2013-11-05
2
321 Views
Last Modified: 2013-11-08
I have a customized grid control that puts the Usage field in edit mode, and it allows me to just go down each row through the usage column as select the appropriate number from dropdownlist, based on quantity usage.  I got the grid to post back when the textchanged, however I don't know what row I am in, I really on get the value of the dropdownlist item.  What I need to do is take that amount and get do a calculation it and it fill the price label for that row with the calculated formula.   The formula really consists of looking up the usage in this table and taking the price from that.  Is there a better way to do this in JavaScript on the web page, or how can I get the datarow back to the code behind if that's the best way to do it.

<%@ Page Title="" Language="VB" MasterPageFile="~/ResidentConsole/Console_Master_Page1.master" AutoEventWireup="false" CodeFile="WaterSewer.aspx.vb" Inherits="ResidentConsole_WaterSewer" %>

<%@ Register Assembly="CustomGrid" Namespace="CustomGrid" TagPrefix="cc1" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">


	<%--<script type="text/javascript">
       
	</script>
--%>

<div >
	
	
</div>

	<div style="text-align: center;">
	<cc1:BulkEditGridView runat="server" ID="myGrid"  AutoGenerateColumns="False" BackColor="LightGoldenrodYellow" BorderColor="Tan" BorderWidth="1px" CellPadding="2" ForeColor="Black" GridLines="None" Width="616px">
		<Columns>
			<asp:TemplateField HeaderText="Unit ID">
				<ItemTemplate>
					<asp:Label ID="lblID" runat="server" Text='<%# Container.DataItemIndex %>' ></asp:Label>
				</ItemTemplate>
			</asp:TemplateField>
			<asp:TemplateField HeaderText="BldgID">
				<%--<EditItemTemplate>
					<asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("code") %>' Enabled="false"></asp:TextBox>
				</EditItemTemplate>--%>
				<ItemTemplate>
					<asp:Label ID="lblBldgID" runat="server" Text='<%# Bind("BldgID") %>'></asp:Label>
				</ItemTemplate>
			</asp:TemplateField>
			<asp:TemplateField HeaderText="Unit ID">
				<ItemTemplate>
					<asp:Label ID="lblUnitID" runat="server" Text='<%# Bind("UnitID") %>'></asp:Label>
				</ItemTemplate>
			</asp:TemplateField>
			<asp:TemplateField HeaderText="ResiID" Visible="False">
				
				<ItemTemplate>
					<asp:Label ID="lblResiID" runat="server" visible="false" Text='<%# Bind("ResiID") %>'></asp:Label>
				</ItemTemplate>
				<ItemStyle Wrap="False" />
			</asp:TemplateField>
			<asp:TemplateField HeaderText="Name">
				<ItemTemplate>
					<asp:Label ID="LblResiName" runat="server" Text='<%# Bind("ResiName") %>'></asp:Label>
				</ItemTemplate>
			</asp:TemplateField>
			<asp:TemplateField HeaderText="Usage">
				<EditItemTemplate>
					<%--<asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("Usage") %>'></asp:TextBox>--%>		<asp:DropDownList ID="ddUsage" runat="server" DataTextField='<%# Eval("Usage") %>' DataValueField='<%# Container.DataItemIndex %>' OnTextChanged="MyTestChanged" AutoPostBack="true">
						<asp:listitem Selected="True" Value="0"></asp:listitem>
						<asp:ListItem Selected="False" Value="1"></asp:ListItem>
						<asp:ListItem Selected="False" Value="2"></asp:ListItem>
						<asp:ListItem Selected="False" Value="3"></asp:ListItem>
						<asp:ListItem Selected="False" Value="4"></asp:ListItem>
					</asp:DropDownList>
				</EditItemTemplate>
				
			</asp:TemplateField>
			<asp:TemplateField HeaderText="Ext. Price">
				<%--<EditItemTemplate>
					<asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("Price") %>'></asp:TextBox>
				</EditItemTemplate>--%>
				<ItemTemplate>
					<asp:Label ID="lblPrice" runat="server" Text='<%# Bind("Price") %>'></asp:Label>
				</ItemTemplate>
			</asp:TemplateField>
		</Columns>
		<FooterStyle BackColor="Tan" />
		<PagerStyle BackColor="PaleGoldenrod" ForeColor="DarkSlateBlue" HorizontalAlign="Center" />
		<SelectedRowStyle BackColor="Red" ForeColor="GhostWhite" />
		<HeaderStyle BackColor="Tan" Font-Bold="True" />
		<EditRowStyle Wrap="False" />
		<AlternatingRowStyle BackColor="PaleGoldenrod" />
	
	
	</cc1:Bulkeditgridview>
</div>

</asp:Content>

Open in new window

0
Comment
Question by:mgmhicks
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 500 total points
ID: 39627039
0
 

Author Closing Comment

by:mgmhicks
ID: 39635282
Thanks, that is what I ended up doing.
0

Featured Post

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What is a Lightbox? A Lightbox is the effect you see when you click, for example, an image and the screen fades out and up pops the same image but in its full size dimensions. There are lots of Lightbox effects for jQuery. Problem is they are a…
How to build a simple, quick and effective accordion menu using just 15 lines of jQuery and 2 css classes
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

630 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question