Question

I want to iterate through the rows of a certain column in my datatable and add the contents of these rows to calculate yhe sum. However I only want the sum of SOME rows NOT just all of the rows. I am using the code below to show me the value of the last row in that particular column however now I want to iterate through MORE rows and calculate the totals(For this one particular column) how can I do this?

 For Each mytablerow As DataRow In myTable.Rows()
     RadTextBox8.Text = mytablerow.Item("PercentageInMix")
 Next
Was it helpful?

Solution

I got it all I needed was just one line of code

        RadTextBox8.Text = myTable.Compute("SUM(PercentageInMix)", " [Include] =1      AND    ProductCode = '" & txtProductCode.Text & "'   ").ToString
        BindingContext(myTable).EndCurrentEdit()
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top