Re: if else in datagrid item template
- From: "Dave Sexton" <dave@jwa[remove.this]online.com>
- Date: Wed, 1 Nov 2006 11:35:12 -0500
Hi Allan,
You can rely on the fact that HyperLink is similar to a Label when NavigateUrl
is empty and use a conditional IF to handle the bool logic inside the
NavigateUrl property itself:
<asp:HyperLink runat="server" Target="_blank" Text='<%# Eval("Title") %>'
NavigateUrl='<%# ((DateTime) Eval("FromDate") > DateTime.Now) ?
"/CPI/V2/Apps/PositionPosting/opening.aspx?id=" + Eval("Id") : string.Empty
%>'
/>
--
Dave Sexton
"Allan Ebdrup" <ebdrup@xxxxxxxxxxxxxxx> wrote in message
news:us$qwuc$GHA.3928@xxxxxxxxxxxxxxxxxxxxxxx
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
.
- Follow-Ups:
- Re: if else in datagrid item template
- From: Allan Ebdrup
- Re: if else in datagrid item template
- References:
- if else in datagrid item template
- From: Allan Ebdrup
- if else in datagrid item template
- Prev by Date: Re: memory leak or not?
- Next by Date: Re: Problems with Interop in C#
- Previous by thread: if else in datagrid item template
- Next by thread: Re: if else in datagrid item template
- Index(es):
Relevant Pages
|