Home > Uncategorized > Data Handling in ASP.Net DetailsView

Data Handling in ASP.Net DetailsView

I have a date field in my DetailsView and the date which is coming from DB is the default date which is “1/1/1754 5:00:00 AM”. I need to set the value of this template field to “N/A” if it is default date.

I created below method in my code behind.

protected string ReplaceDefaultDateAsNA(DateTime discontinued)


if (discontinued.ToString() == “1/1/1754 5:00:00 AM”)

{return “N/A”;}


{return discontinued.ToString();}


Template field in DetailsView looks like.


<asp:Label ID=”Label6″ runat=”server”¬†Text=’<%# ReplaceDefaultDateAsNA((DateTime) Eval(“LastPasswordChangedDate”)) %>’></asp:Label>


Reference (very good article): http://static.asp.net/asp.net/files/DataTutorials/datatutorial13cs.pdf

Leave a Reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">


Listed below are links to weblogs that reference
Data Handling in ASP.Net DetailsView from extremeweblog.com