Click here to Skip to main content
15,884,388 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I am using a bound field of gridview.. In it, if the value that comes in boundfield from database is 1/1/1999 , i want null to be displayed in the column. If not, value in this field must be the same as it is database... I tried following tag but it is not working..

<columns><asp:BoundField DataField=" '<% if(Promised_Date_Time == "1/1/1999"? "":Promised_Date_Time) %>>' " HeaderText="Promise Date Time" DataFormatString="{0:MM/dd/yyyy}"/>
any help???
Posted

1 solution

Try this..

ASP.NET
<asp:TemplateField>
               <ItemTemplate>
                   <asp:Label ID="lbl" runat="server" Text='<%#     Eval("Promised_Date_Time") == "1/1/1999"? "":Eval("Promised_Date_Time")  %>'></asp:Label>
               </ItemTemplate>
           </asp:TemplateField>
 
Share this answer
 
Comments
Codes DeCodes 3-Jan-14 2:00am    
it did not worked karthik.. actually value of Promised_Date_Time is "1/1/0001 12:00:00 AM".. I tried it this way.
<asp:TemplateField HeaderText="Promise Date Time">
<itemtemplate>
<asp:Label ID="lblPromisedDateTime" runat="server" Text='<%# Eval("Promised_Date_Time")=="1/1/0001 12:00:00 AM"?"":Eval("Promised_Date_Time") %>'>



but the value 1/1/0001 12:00:00 AM is still shown.. can it not be done using template field???
Karthik_Mahalingam 3-Jan-14 2:03am    
Eval("Promised_Date_Time").ToString()

try like this...
Karthik_Mahalingam 3-Jan-14 2:07am    
if ur issue is resolved, pls close this post...
Codes DeCodes 3-Jan-14 2:08am    
thanks for the solution man,,
Karthik_Mahalingam 3-Jan-14 3:43am    
welcome jackson :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900