if else in datagrid item template

Discussion in 'ASP .Net Web Controls' started by Allan Ebdrup, Nov 1, 2006.

  1. Allan Ebdrup

    Allan Ebdrup Guest

    I'm using dotNet 2.0 and VS 2005.
    I have a datagrid that I'm binding to an object data source (ODS), the
    objects in the ODS have an FromDate property and an Id property.
    Now I want to display a hyperling if(FromDate>DateTime.Now) and a label if
    not, how do I do this the best way?
    I tried to do a if else in the item template, but that doesn't work:
    ------------------
    <%#
    if(((OFiR.Recruitment.Staffing.Reporting.PositionPostingReporting)Container.DataItem).FromDate
    > DateTime.Now) {%>


    <asp:HyperLink Target="_blank"
    NavigateUrl='<%#"/CPI/V2/Apps/PositionPosting/opening.aspx?id=" + Eval("Id")
    %>' Text='<%# Eval("Title") %>' runat="server"></asp:HyperLink>

    <%# } else {%>

    <asp:Label runat="server" Text='<%# Bind("Title") %>'
    id="Label1"></asp:Label>

    <%# } %>
    ------------------
    How do I accoplish what I'm trying to do the best way?

    Kind Regards,
    Allan Ebdrup
     
    Allan Ebdrup, Nov 1, 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. Replies:
    25
    Views:
    696
    MonkeeSage
    Oct 1, 2006
  2. kj
    Replies:
    15
    Views:
    593
    Lawrence D'Oliveiro
    May 23, 2009
  3. A
    Replies:
    8
    Views:
    830
    James Kanze
    Aug 28, 2010
  4. QUASAR
    Replies:
    6
    Views:
    448
    QUASAR
    Jan 17, 2004
  5. Gergely Kontra
    Replies:
    16
    Views:
    250
    Devin Mullins
    Sep 20, 2005
Loading...

Share This Page