title: Loop, aggregate and return unique DataRow sum
body: <p>I have a DataGrid which contains multiple transactions of Customer's buy ins.
  What I want is to add up the transaction buy ins from each customer and add the result on the related images. What I have at the moment gives me logic errors i.e. adding the same amounts on more than one images.</p>
  
  <p>Here is the structure of my DataGrid (column titles): <code>[Name,Surname, Buyin, Type, StartTime, TransactionID, CustomerID]</code>
  and here is my code:</p>
  
  <pre><code>Dim tbActivePlayers As DataTable = Me.ActivePlayersTableAdapter.GetData()
  
  Dim tbTemp As New DataTable
  
  '   table = DataSet.Tables("Orders")
  
  ' Declare an object variable.
  Dim objTotalBuyin As Object
  Dim iCount, ilbl As Integer
  ilbl = 1
  
  Dim viewUniquePlayers As New DataView(tbActivePlayers)
  Dim iActivePlayers As Integer = viewUniquePlayers.ToTable(True, "CustomerID").Rows.Count
  Dim dtDataTable As DataTable = viewUniquePlayers.ToTable(True, "CustomerID")
  
  Dim myLabel As Label
  For iCount = 0 To dtDataTable.Rows.Count
      objTotalBuyin = tbActivePlayers.Compute("Sum(Buyin)", "CustomerID = " &amp; tbActivePlayers.Rows(iCount).Item("CustomerID"))
      'MsgBox("Name: " &amp; tbActivePlayers.Rows(iCount + 1).Item("Name") &amp; ", Sumbuyin:" &amp; sumObject.ToString &amp; " ResultCount:" &amp; ResultCount)
      '
      myLabel = CType(Me.Controls.Find("lblPlayer" &amp; ilbl, True)(0), Label)
      If Not myLabel Is Nothing Then
          myLabel.Text = "Empty Seat"
      End If
      '
  
      myLabel.Text = tbActivePlayers.Rows(iCount).Item("Name") &amp; Environment.NewLine &amp; _
                     "€" &amp; objTotalBuyin.ToString
  
      myLabel.Image = Global.PokerBusiness.My.Resources.Resources.seatocc
      ilbl += 1
  
  Next
  </code></pre>