Hi
I want if value in Date field in repeater is 1/1/1900 or Null it should be shown as Hyphen
Thanks
Hi
I want if value in Date field in repeater is 1/1/1900 or Null it should be shown as Hyphen
Thanks
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Amit MohantyRank #112 · 20K reputationPosted Oct 28, 2022, 2:11 AM EDT
Try this
On reapeater OnItemDataBound event
protected void OnItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { RepeaterItem item = e.Item; string birthDate = (item.FindControl("lblDOB") as Label).Text; if (string.IsNullOrEmpty(birthDate)) (item.FindControl("lblDOB") as Label).Text = "--"; else if (Convert.ToDateTime(birthDate) == Convert.ToDateTime("1/1/1900 12:00:00 AM")) (item.FindControl("lblDOB") as Label).Text = "--"; } }Where lblDOB is the lebel control in which you have to bind datetime value.
Naresh BeniwalRank #365 · 6.8K reputationPosted Oct 28, 2022, 1:25 AM EDT
Please check it https://stackoverflow.com/questions/15554369/show-empty-string-when-date-field-is-1-1-1900