Accessing labels properties within an asp table

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have got the below asp table and I would like to be able to call up the
lblAddress1 label with in the asp table in the code behind page. I tried
doing this.lblAddress1 and it didn't work and I tried doing
this.tblSearchAddresses.lblAddress1 and it didn't work. Has anyone an idea
how I call this lable with a asp table. Thanks in advance for any help anyone
can give me.

<asp:table id="tblSearchAddresses" Runat="server" Width="100%">
<asp:TableRow>
<asp:TableCell>
<asp:Label ID="lblAddress1" Runat="server"></asp:Label>
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell>
<asp:Label ID="lblAddress2" Runat="server"></asp:Label>
</asp:TableCell>
</asp:TableRow>

</asp:table>
 
Hi Stephen

Your label is part of the Controls-collection of the containing table
cell. The hierarchy looks like this (table->rows->cells):

//just samples
this.tblSearchAddresses.Rows[0].Cells[3].Controls[0];


However, you could just maintain a direct reference to your label in
your code - if this.lblAddress1 doesn't work, it's probably because it's
not declared in your initialization code...

Regards

Philipp
 
Back
Top