David Svedarsky
asked on
Display sum of databound datagridview column in textbox
Software: Visual studio VB.net & sql server 2005.
I need sample code to display the sum of a databound datagridview column in a textbox.
Thanks!
I need sample code to display the sum of a databound datagridview column in a textbox.
Thanks!
ASKER
I tried this:
GridViewRo w' cannot be indexed because it has no default property.
Any ideas??
Should the Column RunningTotals be unbound?
Dim RunningTotals As Double = 4
For Each Rw As DataGridViewRow In TblBreakEvenDataGridView.Rows
RunningTotals += CDbl(IIf(Rw(0) Is DBNull.Value, 0, Rw(0))) 'Gets the values for each cell with the column index 0 and sum each one
Next
TextboxTotals.Text = RunningTotals.ToString
And got this error: Error 3 Class 'System.Windows.Forms.DataAny ideas??
Should the Column RunningTotals be unbound?
Can you post the grid view bounding structure for the colums that you want to sum. If you want to sum 2 colums and show the result in a 3 one then get the sum result in the query and later bound it if not add a 3 Colin and in the event of day abound do the sum and add it to the 3rd colum. Send me the grid and the bound query that populate it and I will check it
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you!
Open in new window