I am getting an error when I attempt to display a datetime value in a textbox:
My code is:
txtStartDate.Text = rdrGetUserInfo.IsDBNull(14) ? String.Empty : Convert.ToString(rdrGetUserInfo.GetString(14));
The error message is: ex.Message = "Unable to cast object of type 'System.DateTime' to type 'System.String'."
Any ideas how I can resolve this?
Try:
txtStartDate.Text = rdrGetUserInfo.IsDBNull(14) ? String.Empty : Convert.ToString(rdrGetUserInfo.GetDateTime(14).ToString());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With