VB asp.net hide a container.DataItem in a Repeater control

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Boney
    New Member
    • Oct 2007
    • 5

    VB asp.net hide a container.DataItem in a Repeater control

    Hi I have a repeater control which has a series of dataBinder items. There are two that show a start date and an end date of an event. Can someone tell me if it is possible to hide the end date if it is empty or contains the same date as the startdate.

    Hope this makes senses.

    Thank you
  • DrBunchman
    Recognized Expert Contributor
    • Jan 2008
    • 979

    #2
    Hi Boney,

    You can call a function inside the repeater item template, passing the start date & end date and returning the HTML to display based on their values. Like this:

    aspx:

    Code:
    <ItemTemplate> 
    	<%#CheckDate(Container.DataItem("StartDate"), Container.DataItem("EndDate"))%>
    </ItemTemplate>
    aspx.vb:

    Code:
     
    Function CheckDate(ByVal sStartDate As String, ByVal sEndDate As String) As String
    If sEndDate  = sStartDate Or sEndDate = "" Then 
    	 Return "<td>&nbsp;</td>"
    Else
    	 Return "<td>" & sEndDate & "</td>"
    End Function
    Does this answer your question? Let me know if it helps,

    Dr B

    Comment

    • Boney
      New Member
      • Oct 2007
      • 5

      #3
      Originally posted by DrBunchman
      Hi Boney,

      You can call a function inside the repeater item template, passing the start date & end date and returning the HTML to display based on their values. Like this:

      aspx:

      Code:
      <ItemTemplate> 
      	<%#CheckDate(Container.DataItem("StartDate"), Container.DataItem("EndDate"))%>
      </ItemTemplate>
      aspx.vb:

      Code:
       
      Function CheckDate(ByVal sStartDate As String, ByVal sEndDate As String) As String
      If sEndDate  = sStartDate Or sEndDate = "" Then 
      	 Return "<td>&nbsp;</td>"
      Else
      	 Return "<td>" & sEndDate & "</td>"
      End Function
      Does this answer your question? Let me know if it helps,

      Dr B
      Thank you so much Dr B. it works great.

      Comment

      Working...