Wrox Programmer Forums
|
VB.NET 2002/2003 Basics For coders who are new to Visual Basic, working in .NET versions 2002 or 2003 (1.0 and 1.1).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET 2002/2003 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 16th, 2006, 10:24 AM
Registered User
 
Join Date: Feb 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Looping through a datagrid

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







Similar Threads
Thread Thread Starter Forum Replies Last Post
Looping ssaranam SQL Server 2005 2 April 17th, 2008 01:40 AM
looping mrjoka Classic ASP Basics 1 September 26th, 2007 12:21 AM
looping through datagrid derekl ASP.NET 1.0 and 1.1 Professional 6 February 14th, 2006 08:19 PM
Looping..? dedex C# 2 January 6th, 2005 11:24 PM
looping over datagrid rj1406 Classic ASP Databases 1 September 30th, 2004 08:43 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.