I am trying to update the datagrid rather then wiping it and repopulating it on each refresh.
Can anyone please assist?
Thanks
Code:
If (CurrentMarket.marketId > 0) Then
tbl.Rows.Clear()
Dim total AsDecimal
total = 0
Dim req AsNew GetMarketPricesReq
Dim resp AsNew GetMarketPricesResp
Dim r As DataRow
Dim s As DataRow
req.header = Header
req.marketId = CurrentMarket.marketId
resp = BFService.getMarketPrices(req)
Dim i AsInteger
Dim j AsInteger
TextBox14.Text = CurrentMarket.runners.Length
For i = 1 To CurrentMarket.runners.Length
r = tbl.NewRow
r("Name") = CurrentMarket.runners(i - 1).name
For j = 1 To resp.marketPrices.runnerPrices.Length
If (resp.marketPrices.runnerPrices(j - 1).selectionId = CurrentMarket.runners(i - 1).selectionId) Then
If (resp.marketPrices.runnerPrices(j - 1).bestPricesToBack.Length = 1) Then
r("Back 3") = 0
r("Back 2") = 0
r("Back 1") = resp.marketPrices.runnerPrices(j - 1).bestPricesToBack(0).price
ElseIf (resp.marketPrices.runnerPrices(j - 1).bestPricesToBack.Length = 2) Then
r("Back 3") = 0
r("Back 2") = resp.marketPrices.runnerPrices(j - 1).bestPricesToBack(1).price
r("Back 1 ") = resp.marketPrices.runnerPrices(j - 1).bestPricesToBack(0).price
ElseIf (resp.marketPrices.runnerPrices(j - 1).bestPricesToBack.Length = 3) Then
r("Back 3") = resp.marketPrices.runnerPrices(j - 1).bestPricesToBack(2).price
r("Back 2") = resp.marketPrices.runnerPrices(j - 1).bestPricesToBack(1).price
r("Back 1") = resp.marketPrices.runnerPrices(j - 1).bestPricesToBack(0).price
Else
' Do Nothing
EndIf
If (resp.marketPrices.runnerPrices(j - 1).bestPricesToLay.Length = 1) Then
r("Lay 3") = 0
r("Lay 2") = 0
r("Lay 1") = resp.marketPrices.runnerPrices(j - 1).bestPricesToLay(0).price
ElseIf (resp.marketPrices.runnerPrices(j - 1).bestPricesToBack.Length = 2) Then
r("Lay 3") = 0
r("Lay 2") = resp.marketPrices.runnerPrices(j - 1).bestPricesToLay(1).price
r("Lay 1") = resp.marketPrices.runnerPrices(j - 1).bestPricesToLay(0).price
ElseIf (resp.marketPrices.runnerPrices(j - 1).bestPricesToBack.Length = 3) Then
r("Lay 3") = resp.marketPrices.runnerPrices(j - 1).bestPricesToLay(2).price
r("Lay 2") = resp.marketPrices.runnerPrices(j - 1).bestPricesToLay(1).price
r("Lay 1") = resp.marketPrices.runnerPrices(j - 1).bestPricesToLay(0).price
Else
' Do Nothing
EndIf
tbl.Rows.Add(r)
EndIf
Next
Dim TotalBack AsDecimal
Dim TotalLay AsDecimal
s("Name") = ""
For j = 1 To resp.marketPrices.runnerPrices.Length
If (resp.marketPrices.runnerPrices(j - 1).selectionId = CurrentMarket.runners(i - 1).selectionId) Then
If (resp.marketPrices.runnerPrices(j - 1).bestPricesToBack.Length = 1) Then
s("Back 3") = 0
s("Back 2") = 0
s("Back 1") = resp.marketPrices.runnerPrices(j - 1).bestPricesToBack(0).amountAvailable
TotalBack = Int(resp.marketPrices.runnerPrices(j - 1).bestPricesToBack(0).amountAvailable)
TextBox8.Text = CurrentMarket.runners(i - 1).name
TextBox9.Text = Int(TotalBack)
ElseIf (resp.marketPrices.runnerPrices(j - 1).bestPricesToBack.Length = 2) Then
s("Back 3") = 0
s("Back 2") = resp.marketPrices.runnerPrices(j - 1).bestPricesToBack(1).amountAvailable
s("Back 1 ") = resp.marketPrices.runnerPrices(j - 1).bestPricesToBack(0).amountAvailable
TotalBack = Int(resp.marketPrices.runnerPrices(j - 1).bestPricesToBack(0).amountAvailable) + Int(resp.marketPrices.runnerPrices(j - 1).bestPricesToBack(1).amountAvailable)
TextBox8.Text = CurrentMarket.runners(i - 1).name
TextBox9.Text = Int(TotalBack)
ElseIf (resp.marketPrices.runnerPrices(j - 1).bestPricesToBack.Length = 3) Then
s("Back 3") = resp.marketPrices.runnerPrices(j - 1).bestPricesToBack(2).amountAvailable
s("Back 2") = resp.marketPrices.runnerPrices(j - 1).bestPricesToBack(1).amountAvailable
s("Back 1") = resp.marketPrices.runnerPrices(j - 1).bestPricesToBack(0).amountAvailable
TotalBack = Int(resp.marketPrices.runnerPrices(j - 1).bestPricesToBack(0).amountAvailable) + Int(resp.marketPrices.runnerPrices(j - 1).bestPricesToBack(1).amountAvailable) + Int(resp.marketPrices.runnerPrices(j - 1).bestPricesToBack(2).amountAvailable)
TextBox8.Text = CurrentMarket.runners(i - 1).name
TextBox9.Text = Int(TotalBack)
Else
' Do Nothing
EndIf
If (resp.marketPrices.runnerPrices(j - 1).bestPricesToLay.Length = 1) Then
s("Lay 3") = 0
s("Lay 2") = 0
s("Lay 1") = resp.marketPrices.runnerPrices(j - 1).bestPricesToLay(0).amountAvailable
TotalLay = Int(resp.marketPrices.runnerPrices(j - 1).bestPricesToLay(0).amountAvailable)
ElseIf (resp.marketPrices.runnerPrices(j - 1).bestPricesToBack.Length = 2) Then
s("Lay 3") = 0
s("Lay 2") = resp.marketPrices.runnerPrices(j - 1).bestPricesToLay(1).amountAvailable
s("Lay 1") = resp.marketPrices.runnerPrices(j - 1).bestPricesToLay(0).amountAvailable
TotalLay = Int(resp.marketPrices.runnerPrices(j - 1).bestPricesToLay(0).amountAvailable) + Int(resp.marketPrices.runnerPrices(j - 1).bestPricesToLay(1).amountAvailable)
ElseIf (resp.marketPrices.runnerPrices(j - 1).bestPricesToBack.Length = 3) Then
s("Lay 3") = resp.marketPrices.runnerPrices(j - 1).bestPricesToLay(2).amountAvailable
s("Lay 2") = resp.marketPrices.runnerPrices(j - 1).bestPricesToLay(1).amountAvailable
s("Lay 1") = resp.marketPrices.runnerPrices(j - 1).bestPricesToLay(0).amountAvailable
TotalLay = Int(resp.marketPrices.runnerPrices(j - 1).bestPricesToLay(0).amountAvailable) + Int(resp.marketPrices.runnerPrices(j - 1).bestPricesToLay(1).amountAvailable) + Int(resp.marketPrices.runnerPrices(j - 1).bestPricesToLay(2).amountAvailable)
Else
' Do Nothing
EndIf
s("POM") = 0
tbl.Rows.Add(s)
EndIf
Next
Next
EndIf