Error converting date and time to string

I get an error when I try to display the date and time value in a text box:

My code is:

txtStartDate.Text = rdrGetUserInfo.IsDBNull(14) ? String.Empty : Convert.ToString(rdrGetUserInfo.GetString(14)); 

Error message: ex.Message = "Unable to overlay object of type 'System.DateTime' on type 'System.String'."

Any ideas how I can resolve this?

+7
source share
1 answer

Try:

 txtStartDate.Text = rdrGetUserInfo.IsDBNull(14) ? String.Empty : Convert.ToString(rdrGetUserInfo.GetDateTime(14).ToString()); 
+7
source share

All Articles