I'm not convinced that is your exact error message: you do declare a variable called "UploadDate" in your click event handler, but as a
string
. Since a
string
does not have a SelectedDate property, I think you are getting confused.
Look at the line with the error:
DateTime upload_date = UploadDate.SelectedDate.ToShortDateString();
1) UploadDate is a
string
, so it doesn't have a SelectedDate Property, so you probably want a different variable, or a different type
2) Even if it did, since you create an initialize it in the same method, it won't have a SelectedDate that the user wanted.
3) Since you then convert the SelectedDate to a
string
, you can't stick the resulting value into a DateTime anyway unless you Parse or TryParse it.
Take a step back, look a your overall code, and try to work out what you are trying to do. I think you are focusing on details which are hiding the bigger picture.