JavaScript - Calculations and two gridviews

Asked By Rosie Buchanan
09-Feb-10 02:58 PM
I'm back...

This is what I'm trying to achieve:

         Month

Current Month

 Month

     Total

4/3/2009

$00.00

Jan

$0.00

4/17/2009

$00.00

Feb

$0.00

5/1/2009

$00.00

Mar

$0.00

5/15/2009

$00.00

Apr

$0.00

5/29/2009

$00.00

May

$0.00

6/12/2009

$0.00

Jun

$0.00

6/26/2009

$0.00

July

$0.00

7/10/2009

$0.00

Aug

$0.00

Sept

$0.00

Oct

$0.00

Nov

$0.00

Dec

$0.00

I want to be able to add
50.00 next to 4/2/2009 Under the current month column
and
20.00 next to 4/17/2009

I would like the total of 70.00 to go under the total column next to the April section.

I have the above set up but I had to use two gridviews to get the month's listed.  Here are the gridview's:

 

 

<asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1" AutoGenerateColumns="False" Width="103px" Font-Names="Calibri">

 

 

<Columns>

 

 

 

 

<asp:BoundField DataField="Dates" HeaderText="PPE Date" SortExpression="Dates" />

 

 

 

 

<asp:TemplateField HeaderText="Amount">

 

 

 <

 

ItemTemplate>

 

 <

 

asp:TextBox ID="TextBox1" runat="server" Width="99px"></asp:TextBox
 </
 
ItemTemplate>

 

 

 </

 

asp:TemplateField>

 

 

 </

 

Columns>

 

 

 

 

</asp:GridView>

 

 

 

 

</td>

 

 

 

 

<td style="width: 100px">

 

 

 

 

<asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource2">

 

 

 

 

<Columns>

 

 

 <

 

asp:BoundField DataField="MonthVal" HeaderText="MonthVal" ReadOnly="True" SortExpression="MonthVal" Visible="False" />

 

 

 

 

<asp:BoundField DataField="MonthName" ReadOnly="True" SortExpression="MonthName" />

 

 

 

 

<asp:TemplateField HeaderText="Total">

 

 

 <

 

ItemTemplate>

 

 

 <

 

asp:TextBox ID="TextBox6" runat="server" Width="69px"></asp:TextBox>

 

 

 </

 

ItemTemplate>

 

 

 </

 

asp:TemplateField>

 

 

 

 

</Columns>

 

 

 

 

</asp:GridView>

 

 

 Is this possible to be able to calculate in one gridview and display the answer in the other gridview or should I use a label?

 

 

 

  Pranay Singh replied to Rosie Buchanan
09-Feb-10 04:01 PM
You cannot do calculations in Gridview, its just for display purpose, you can either do it at database level by a stored proc to show the sum of amounts selected by months or you can capture the cell values of the gridview( based on month)  convert them to decimal  add them,  store them in  dataset object and feed it to the other gridview.  1st approach is easier, but it would require an extra call to database, 2nd approach is little complicated and need some coding.
I hope this gives you some idea.
  Rosie Buchanan replied to Pranay Singh
09-Feb-10 06:29 PM
Thanks I see this is going to be tough to handle so I would want to do it another way.  Instead of what I proposed how would I add capture the value of a gridview cell(s) and add them together and place the total in a label or a footer.  I would do this with only one gridview.
  Pranay Singh replied to Rosie Buchanan
10-Feb-10 08:43 AM
No, its not tough to handle if you do it at database level, all you need is stored proc.   and  if you have to show total just for the current month yeh you can use label but display is another thing 1st you need to decide how to capture these values...label or gridview wont make your work any different...but yeh Label is preferred option over gridview if you have just a grand total to display.
all the best
Create New Account
help
from different tables DataBase VISTA Enterprise / Office 2007 Plus situation: Two identically structured tables, [Prior month] and [current month] tables consist of contracts and assets with costs. there is a field that indicates the number of units on the contract) Occassionally, the number of assets may increase from last month with no increase in contract cost Record: [current month] Contract Asset Cost units 1 1 5.00 3 1 2 4.00 3 1 3 3.00 3 [prior month] 1 1 8.00 2 1 2 4.00 2 objective: Identify those items where the number of units assigned to a contract has increased, but total contract cost has not. I can isolate the contracts where the unit cnt has changed
start); string sp_start_str = sp_start.TotalDays.ToString("#"); double t1 = double.Parse(sp_start_str); / / change accordingly if (validation.Month = = 12) t1 = t1 - 14; if (validation.Month = = 01) t1 = t1 - 28; / / end date(t2) System.TimeSpan sp_end = end.Subtract(start); string sp_end_str so the cycle continues. . . Ok so tell me for these 2 days what would the total holiday days count be: 05th December 2009 (start date) 05th February 2011 (end date). What would the total holiday count be? ok anyways here's a simple function that I've done for DateTime currDate; currDate = DateTime.MinValue + daysCount; int monthCount = 0; monthCount = (((currDate.Year - 1) * 12) + currDate.Month) - 1; int subsractAmount = 0; int totalSubtract = 0; for (int i = 0; i < monthCount; i++) { DateTime parsingDate = startDate.AddMonths(i); if (parsingDate.Month = = 12) { subsractAmount + = 14; totalSubtract + = subsractAmount; } else if (parsingDate Month = = 1) { subsractAmount + = 14; totalSubtract + = subsractAmount; } else { totalSubtract + = subsractAmount; } } return daysCount.Days - totalSubtract; } this function returns substracted change the return line to return totalSubtract. Best regards. also the following: if (parsingDate.Month = = 12) { subsractAmount + = 14; totalSubtract + = subsractAmount; } else if (parsingDate.Month = = 1) { subsractAmount + = 14; totalSubtract + = subsractAmount; } else
us how many months of inventory we will be holding at the beginning of each month (given the entered projections and the known On Hand and production coming in). Sounds easy Projections are in these fields: M01Adj, M02Adj, M03Adj = 85M12Adj (with M01Adj always being the present month) The production are in these fields: M01ProdAdj, M02ProdAdj, M03ProdAdj = 85 M12ProdAdj (with M01ProdAdj always being the present month. The On hand is in this field: OnHandAdj. The fields stop at M12. So, given to figure out the number of months inventory we have at the beginning of each month. Let = 92s take this example, and though I will just type it out, please understand 0000, 0000, 0000, 0000, 0000 On Hand: 8000 First off, the Projection for the first month should be adjusted for the current day of the month it is. So if it is the 15th day of the month, let = 92s say, we should adjust it to 2000 * 15 / 30, or 1000. The reason
months as column headings. In a report, I need to calculate the percentage of the total for each value. I can get a percentage for either of the values, but not be clearer. The report I have to create looks like this: Transactions Jan Feb etc Total # % of Total Valid 2200 1849 etc xxxxx xx.x% Invalid 2015 1900 etc. xxxxx xx.x% Total / Mo. xxxx xxxx etc. % / Valid / Mo. xx.x% xx.x% etc The original data that have a crosstab that places the data in rows, and the totals in columns by month. Because the values are in a single control on the form, though, I can’t another report that has 7 rows and the percentage has to be calculated by the current month. So I was starting with the “simplest.” Hope this clarifies. Thanks. - - susan That posts better. The report I have to create looks like this: Transactions Jan Feb etc Total # % of Total Valid 2200 1849 etc xxxxx xx.x% Invalid 2015 1900 etc. xxxxx xx
some have no OAB. I have tested a new machine with a new profile. My current computer has never successfully downloaded an OAB. I suspect it has something to do with FOUND - this is ok. HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Services \ MSExchangeSA \ Parameters \ registry key has been closed. Total registry keys found 1. Total registry values found 0. Checking for the (HKLM) Exchange Provider Registry Key HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft FOUND - this is ok. HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ Exchange \ Exchange Provider registry key has been closed. Total registry keys found 1. Total registry values found 0. Checking for the (HKCU) Exchange Provider Registry Key Exchange Provider registry key not present on this system - this is ok. Total registry keys found 0 Total registry values found 0. Checking for the DSAccess Profile Registry Keys Default DSAccess profile key not found - this is ok. Default DSAccess profile (UserGC1) key not found - this is ok. Total registry keys found 0. Total registry values found 0. Checking for user MAPI profiles. The