Date in DataBinding
-
Hi everyone, I have a problem re: DataBindings. I binded a textbox with a database in which I would like to show the date in it, but unfortunately I can't remove the time, so that in the textbox the date only is shown. How can I do it? The following is the code I used for databinding. this.txtDOB.DataBindings.Add("Text", DBHandler.DS, "UserLogInsteacher.DateOfBirth"); Thanks a lot!!
-
Hi everyone, I have a problem re: DataBindings. I binded a textbox with a database in which I would like to show the date in it, but unfortunately I can't remove the time, so that in the textbox the date only is shown. How can I do it? The following is the code I used for databinding. this.txtDOB.DataBindings.Add("Text", DBHandler.DS, "UserLogInsteacher.DateOfBirth"); Thanks a lot!!
-
I didn't understand you quite well. How can I do that?
-
I didn't understand you quite well. How can I do that?
Something like this (not tested):
Binding binding = this.txtDOB.DataBindings.Add("Text", DBHandler.DS, "UserLogInsteacher.DateOfBirth");
binding.Format += new ConvertEventHandler(binding_Format);and
private void binding_Format(object sender, ConvertEventArgs e)
{
DateTime dt = (DateTime)e.Value;
e.Value = dt.ToShortDateString();
}Some error handling etc should be added (like checking for DbNull etc.)