Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0FindControl not finding my controlFindControl not finding my control
Previous
 
Next
New Post
10/2/2008 1:28 AM
 

I have an asp table with asp rows and asp cells that I have given all specific names like tc1description and tc2description.

When I do tc = CType(Me.FindControl("tc1description"), TableCell) it's returning nothing.

What am I missing, why is it not returning my tablecell?

 
New Post
10/2/2008 2:09 AM
 

Possibly because of naming containers.  When this control is rendered the name of this control will not be not actually tc1description anymore.  Try:

Me.FindControl(tc1description.ClientID)

JK


You know your website is cool, so why not let your users help you by spreading the word on social networking sites - get the DotNetNuke Social Bookmarks Module with 57 different ways to add social bookmarks to your site ... or download the FREE demo right now
 
New Post
10/2/2008 2:41 AM
 

The problem is that I can't reference it directly as my code is part of a loop

It actually

For i as 1 to 50

tc = CType(Me.FindControl("tc" & i & "desription"), TableCell)

tc.Visible = False

Next

so I can't use the ClientID on the end.

 
New Post
10/5/2008 10:44 PM
 

Can anyone shed any light on this issue?

 
New Post
10/6/2008 7:31 AM
 

Here is a sample I have made. Make sure on the cell itself you put a unique ID in order to find the control.

You can place this code on a testing page and feel free to play around with the codes.

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim tbl As New Table
        Dim rowHeader As New TableRow()
        tbl.Rows.Add(rowHeader)

        Dim cellHeader As New TableCell()
        cellHeader.Text = "This is header 1"
        cellHeader.ID = "Header1"
        rowHeader.Cells.Add(cellHeader)

        Dim cellHeader2 As New TableCell()
        cellHeader2.Text = "This is header 2"
        cellHeader2.ID = "Header2"
        rowHeader.Cells.Add(cellHeader2)

        Me.Controls.Add(tbl)

        'Sample to find the control
        Dim findCellHeader As New TableCell()
        findCellHeader = CType(tbl.FindControl("Header2"), TableCell)
        If (findCellHeader IsNot Nothing) Then
            Response.Write("I found the cellHeader2 ==> " & findCellHeader.Text)
        End If
       
       
    End Sub

 

Hope this help

 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0FindControl not finding my controlFindControl not finding my control


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out