I have 10 labels in my mark up as follows
I am trying to set the text in a select in the code behind
[CODE English]
COL = 0
While MyMenu.Read
Select Case MyMenu.GetInt32(1)
Case 1
COL = COL + 1
lblHeadCOL.Text = "MyMenu.GetString(4)"
Case 2
Case 3
Case 4
End Select
End While
[/code]
Obviously this will not work as "lblHeadCOL" does not exist, but I cannot find the correct format. I think I have to use findcontrol. I have tried
[CODE English]
Dim myLabel As Object = FindControl("lblHead1")
myLabel.Text = "MyMenu.GetString(4)"
[/code]
Can anyone help me with the correct format please, or is there a better way.
Steve
Code:
<asp:Label ID="lblHead1" runat="server"></asp:Label>
<asp:Label ID="lblHead2" runat="server"></asp:Label>
<asp:Label ID="lblHead3" runat="server"></asp:Label>
<asp:Label ID="lblHead4" runat="server"></asp:Label>
<asp:Label ID="lblHead5" runat="server"></asp:Label>
<asp:Label ID="lblHead6" runat="server"></asp:Label>
<asp:Label ID="lblHead7" runat="server"></asp:Label>
<asp:Label ID="lblHead8" runat="server"></asp:Label>
<asp:Label ID="lblHead9" runat="server"></asp:Label>
<asp:Label ID="lblHead10" runat="server"></asp:Label>
[CODE English]
COL = 0
While MyMenu.Read
Select Case MyMenu.GetInt32(1)
Case 1
COL = COL + 1
lblHeadCOL.Text = "MyMenu.GetString(4)"
Case 2
Case 3
Case 4
End Select
End While
[/code]
Obviously this will not work as "lblHeadCOL" does not exist, but I cannot find the correct format. I think I have to use findcontrol. I have tried
[CODE English]
Dim myLabel As Object = FindControl("lblHead1")
myLabel.Text = "MyMenu.GetString(4)"
[/code]
Can anyone help me with the correct format please, or is there a better way.
Steve