G
Guest
I try to use "for" loop to retrieve and assign values in web form. The code
is in the following. But it can not be compiled.
What I want to do is:
txtQ1.Text = ds.Tables("mmsSpecRecord").Rows(0)("Q1")
txtQ2.Text = ds.Tables("mmsSpecRecord").Rows(0)("Q2")
.....
txtQ10.Text = ds.Tables("mmsSpecRecord").Rows(0)("Q10")
------code -------
Dim field As String = "Q"
Dim score As String = "txtQ"
For i As Integer = 1 To 10
field += i
score += i
score.Text = ds.Tables("mmsSpecRecord").Rows(0)(field)
Next
is in the following. But it can not be compiled.
What I want to do is:
txtQ1.Text = ds.Tables("mmsSpecRecord").Rows(0)("Q1")
txtQ2.Text = ds.Tables("mmsSpecRecord").Rows(0)("Q2")
.....
txtQ10.Text = ds.Tables("mmsSpecRecord").Rows(0)("Q10")
------code -------
Dim field As String = "Q"
Dim score As String = "txtQ"
For i As Integer = 1 To 10
field += i
score += i
score.Text = ds.Tables("mmsSpecRecord").Rows(0)(field)
Next