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. Advertisements

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. Luis Esteban Valencia Muñoz

    javascript datagrid events inside item template

    Luis Esteban Valencia Muñoz, Jun 9, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    7,555
    =?Utf-8?B?dmluYXk=?=
    Jun 9, 2005
  2. Replies:
    25
    Views:
    1,006
    MonkeeSage
    Oct 1, 2006
  3. stephen

    Item Template problem in Datagrid

    stephen, Nov 20, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    461
    Mohsin Rizvi
    Nov 21, 2006
  4. =?Utf-8?B?Q2hyaXMgRmluaw==?=

    How to dynamically add control to datagrid item template

    =?Utf-8?B?Q2hyaXMgRmluaw==?=, Aug 20, 2007, in forum: ASP .Net
    Replies:
    1
    Views:
    736
    =?Utf-8?B?TWFuaXNoIEJhZm5h?=
    Aug 21, 2007
  5. kj
    Replies:
    15
    Views:
    823
    Lawrence D'Oliveiro
    May 23, 2009
  6. A
    Replies:
    8
    Views:
    1,087
    James Kanze
    Aug 28, 2010
  7. QUASAR
    Replies:
    6
    Views:
    657
    QUASAR
    Jan 17, 2004
  8. Gergely Kontra
    Replies:
    16
    Views:
    437
    Devin Mullins
    Sep 20, 2005
Loading...