ASP.NET - Date formate issue
Asked By siv h on 05-Mar-13 05:27 AM
in Grid view(asp.net,c#)
<ItemTemplate>
<asp:Label ID="lblmodified" runat="server" Text='<%#Convert.ToDateTime(Eval("ModifiedDate")).ToString("dd /MM/ yyyy")%>'></asp:Label>
</ItemTemplate>
when it is displaying ----01/01/0001
for that one i wil show simply blank, or message i want to show.
how can i handle this case.
please suggest me.
thanks in advance.
Danasegarane Arunachalam replied to siv h on 06-Mar-13 05:26 AM
1. Handle the Gridview.Rowdatabound Event
2. In the event find the date textbox.
3.
void CustomersGridView_RowDataBound(Object sender, GridViewRowEventArgs e)
{
if(e.Row.RowType == DataControlRowType.DataRow)
{
// Display the company name in italics.
//find the textbox
TextBox txt=e.row.findcontrol("lblmodified");
if (txt.text=="v") //if the cell value is 01/01/2026
{
txt.text="---"; //Display ---
}
//e.Row.Cells[1].Text = "<i>" + e.Row.Cells[1].Text + "</i>";
}
}