access itemtemplate controls in ItemDataBind event handler

Discussion in 'ASP .Net Mobile' started by Tomás, Apr 27, 2006.

  1. Tomás

    Tomás Guest

    Hi,

    I am trying to access controls in the ItemTemplate of an objectlist. No
    matter what I try I cannot find them.

    What I'm trying to do: I have a <mobile:TextView> control in the
    ItemTemplate. Then, depending on the value of a particular field when I
    am binding to the objectlist, I want to hide/show that TextView
    control. But as I said, I can't get reference the control in
    ItemDataBind. Here is my code:


    <ItemTemplate>
    <mobile:TextView Visible=true Runat=server
    ID="txtProjectName"></mobile:TextView>
    </ItemTemplate>



    Code Behind:

    Private Sub olTasks_ItemDataBind(ByVal sender As Object, ByVal e As
    System.Web.UI.MobileControls.ObjectListDataBindEventArgs) Handles
    olTasks.ItemDataBind
    Dim tempControl As MobileControls.TextView =
    e.ListItem.FindControl("txtProjectName")
    If e.ListItem("project_name") = prevProjectName Then
    tempControl.Visible = False
    Else
    prevProjectName = e.ListItem("project_name")
    tempControl.Text = e.ListItem("project_name")
    tempControl.Visible = True
    End If
    End Sub


    Any help would be greatly appreciated as are alternative methods of
    doing what I'm trying to do!

    Thanks in advance,

    Tomás
    Tomás, Apr 27, 2006
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bennett Haselton
    Replies:
    1
    Views:
    5,320
    Joe Fallon
    Sep 24, 2004
  2. sonic
    Replies:
    1
    Views:
    526
    John Saunders
    Jan 7, 2005
  3. Replies:
    1
    Views:
    686
    Damien
    Feb 22, 2007
  4. Andy B
    Replies:
    1
    Views:
    980
    bruce barker
    Nov 15, 2008
  5. fnuser
    Replies:
    0
    Views:
    2,290
    fnuser
    Jan 26, 2013
Loading...

Share This Page