access itemtemplate controls in ItemDataBind event handler

T

Tomás

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top