Belinda Griffith Belinda Griffith - 3 years ago 132
ASP.NET (C#) Question

Simple VB.NET Url Issues with For Statement

We are looping through an array to fill a table and it fills fine, but we are trying to add a hyperlink to each value we put in the table. It will only hyperlink the last value it puts in the table. Why is it not hyperlinking every value we put in the table? Every value is in the table just not linked. Any help would be greatly appreciated.

Dim url as system.web.ui.webcontrol.hyperlink
For i = 0 to count - 1
url.text = multi(i,1)
url.navigateurl = "IPPTraining.aspx?login=" & multi(i,0)
tblmain.rows(j).cells(1).text = url.text
Next i

Answer Source

Move your dim statement inside the loop. I believe you are only creating one instance of the control. So therefore the last assignment is the only one that sticks.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download