I have a situation where some columns and rows will be empty based on the type of data required for each particular event. Some event may not require time or date as the case may be. So, in some of the columns in my database table, there are situations where some rows are empty. But when I navigate the page where some information are supposed to display, I get an error because of an empty column or row.
String was not recognized as a valid DateTime.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.FormatException: String was not recognized as a valid DateTime.
Please how can I display value even if it is empty?
This is how I display record from database table in the labels
Titled.Text = ds.Tables[0].Rows[0]["EventName"].ToString();
LabelDate.Text = Convert.ToDateTime(ds.Tables[0].Rows[0]["EventDate"]).ToLocalTime().ToString("MMM d, yyyy");
Timed.Text = ds.Tables[0].Rows[0]["EventTime"].ToString();