access itemtemplate controls in ItemDataBind event handler

Tech-Archive recommends: Fix windows errors by optimizing your registry



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

.



Relevant Pages

  • Cant View Item Template in Designer Viewer
    ... I creted a usercontrol which has an ITemplate in it named ItemTemplate. ... When I drag the user control on to my .aspx page everything looks fine. ... Why do these not appear in my designer view? ...
    (microsoft.public.dotnet.framework.aspnet.buildingcontrols)
  • BC30456: DataItem is not a member of System.Web.UI.Control ...
    ... I have a gridview with an updatepanel in the itemtemplate. ... If the above is changed to reference a function that is passed the container ... Public Function IsDroppedSection(ByVal ContainerControl As Control) As ...
    (microsoft.public.dotnet.framework.aspnet.datagridcontrol)
  • Re: Multiple Content Panes / Forms Tags
    ... The way it works is the Page will have a single child control, the master ... need both content tags to have form tags. ... <ItemTemplate> ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: datagrid imagebutton
    ... A TemplateColumn is used in cases where authors need complete control over ... The ItemTemplate can include ... Set the DataGrid control's AutoGenerateColumns property to false. ...
    (microsoft.public.dotnet.framework.aspnet)
  • RE: Actual Date
    ... control is populated programmatically as it is in this case. ... The only thing wrong with that is that now the calendar ... Private Sub cmdMonthDown_Click ... Select Case KeyCode ...
    (microsoft.public.access.gettingstarted)