473,323 Members | 1,537 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,323 software developers and data experts.

Adding gridveiw row values

20
I am developing an application using the gridview. the last column is a total column I want to compare the typed in value to the sum of values in the rest of the cells. I tried to use custom validation but the textboxes that contain the values are not seen by the application below is my validation code

Expand|Select|Wrap|Line Numbers
  1.     Protected Sub validateTotals(ByVal source As Object, _
  2.     ByVal args As System.Web.UI.WebControls.ServerValidateEventArgs) _
  3.  
  4.         Dim total, sums As Integer
  5.         Dim txtBox As TextBox
  6.  
  7.         sums = 0
  8.         txtBox = CType(GridView1.FindControl("Textbox1"), TextBox)
  9.         total = CInt(txtBox.Text)
  10.         txtBox = CType(GridView1.FindControl("Textbox1"), TextBox)
  11.         sums += CInt(txtBox.Text)
  12.         txtBox = CType(GridView1.FindControl("Textbox2"), TextBox)
  13.         sums += CInt(txtBox.Text)
  14.         txtBox = CType(GridView1.FindControl("Textbox3"), TextBox)
  15.         sums += CInt(txtBox.Text)
  16.         txtBox = CType(GridView1.FindControl("Textbox4"), TextBox)
  17.         sums += CInt(txtBox.Text)
  18.         txtBox = CType(GridView1.FindControl("Textbox5"), TextBox)
  19.         sums += CInt(txtBox.Text)
  20.         txtBox = CType(GridView1.FindControl("Textbox6"), TextBox)
  21.         sums += CInt(txtBox.Text)
  22.         If sums <> total Then
  23.             args.IsValid = False
  24.         Else
  25.             args.IsValid = True
  26.         End If
  27.  
  28.     End Sub


I have also tried JavaScript which works fine if the user navigates through all the other cells but if not it does not work

Please help
Nov 25 '08 #1
0 1045

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Frank | last post by:
I have a large form, that has text boxes of numbers in rows and columns. I need to sum the values in the columns, and put the total at the bottom of the column. But I also need to sum the values in...
5
by: Paul | last post by:
Hi I have a table that currently has 466 columns and about 700,000 records. Adding a new DEFAULT column to this table takes a long time. It it a lot faster to recreate the table with the new...
2
by: Viorel | last post by:
Adding new row with default values. In order to insert programmatically a new row into a database table, without direct "INSERT INTO" SQL statement, I use the well-known DataTable.NewRow,...
3
by: Jim Heavey | last post by:
Trying to figure out the technique which should be used to add rows to a datagrid. I am thinking that I would want an "Add" button on the footer, but I am not quite sure how to do that. Is that...
6
by: Rudy | last post by:
Hi all, I know this is easy, just can't seem to get it. I have a windows form, and a text box, with a value already in it. I need to add that value to a table. It's just one value, so the entire...
17
by: Sri | last post by:
How do you add an n-bit number in C? Regards, Sri
1
by: Rich | last post by:
Hello, I can update a dataset from my client app using a dataAdapter.Updatecommand when I add parameter values outside of the param declaration. But If I add the param values inline with the...
0
by: Venu | last post by:
hi all I am having a problem with grid view control. I am having a gridview with automaticgenerateeditbutton = "true".I edited a row , In edit mode I deleted the values in that row and updated,...
2
by: Canye | last post by:
I have a very long list of codes that i was advised to put in a module but don't know where to start from. Also i have a botton in my software that i what to use to be adding tabs when running my...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.