David Emerson
newsgrps at dalyn.co.nz
Sun Apr 23 15:59:09 CDT 2006
I have found a partial solution:
Dim myControl1 As Control, myInt As Integer, lblLoop As Label
For myInt = 1 To 3
myControl1 = Page.FindControl("lblYrEnd" & myInt)
If (Not myControl1 Is Nothing) Then
lblLoop = CType(myControl1, Label)
lblLoop.Text = "Label No: " & myInt
End If
Next myInt
This appends the value of myInt to the value entered into TextBox2
and puts the result into the lblYrEnd label with the last character
equal to myInt.
I can get this to work in a plain aspx page. However, the page I
want to use it on has a Master page and content control. When I run
the same code the "myControl1 = Page.FindControl("lbltemp" & myInt)"
line doesn't find the control. My guess is that it is because it is
hidden down the control hierarchy but I am having trouble with VB.Net
help finding how to reference them. Can anyone help?
The code for the objects is:
<%@ Page Language="VB" MasterPageFile="~/MasterPage.master"
AutoEventWireup="false" CodeFile="pgeSingleItemResult.aspx.vb"
Inherits="pgeSingleItemResult" title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"
Runat="Server">
<table style="z-index: 100; left: 237px; width: 713px; position:
absolute; top: 217px; vertical-align: top; font-family: arial;
border-collapse: separate; text-align: center; border-right: black
1px solid; border-top: black 1px solid; border-left: black 1px solid;
border-bottom: black 1px solid;" cellspacing="0" id="tblItemResult">
<tr>
<td align="center" style="width: 21px; height: 20px;"
bordercolor="black">
<asp:Label ID="lblYrEnd1" runat="server"
Width="96px"></asp:Label></td>
</tr>
<tr>
<td align="center" style="width: 21px" bordercolor="black">
<asp:Label ID="lblYrEnd2" runat="server"
Width="96px"></asp:Label></td>
</tr>
<tr>
<td align="center" style="width: 21px" bordercolor="black">
<asp:Label ID="lblYrEnd3" runat="server"
Width="96px"></asp:Label></td>
</tr>
<tr>
<td align="center" style="width: 21px" bordercolor="black">
<asp:Label ID="lblYrEnd4" runat="server"
Width="96px"></asp:Label></td>
</tr>
<tr>
<td align="center" style="width: 21px" bordercolor="black">
<asp:Label ID="lblYrEnd5" runat="server"
Width="96px"></asp:Label></td>
</tr>
</table>
</asp:Content>
Regards
David Emerson
Dalyn Software Ltd
New Zealand