what did I do wrong while passing dateTimePicker value to bindingSource filter?

I have this line of code, to pass a selected date from a dateTimePicker to the bindingSource (for a listbox):

this.BindingSourceDV.Filter = "ServiceDueDate = " + "'" + dateTimePickerDV.Value.ToShortDateString() + "'";

when i run the app, it didn't throw error, but didn't work, the listbox didnt show anything at all.

Then I added a textbox, did it this way:

textBox1.Text = dateTimePickerDV.Value.ToShortDateString();

this.BindingSourceDV.Filter = "ServiceDueDate = " + "'" + textBox1.Text + "'";

It worked!!!!!!!!!!

If the value of dateTimePickerDV.Value.ToShortDateString(); can't be taken by the bindingSource, the value of textBox1.Text should not be taken neither, Is there a way to fix it

thx in advance





Answer this question

what did I do wrong while passing dateTimePicker value to bindingSource filter?

  • Oscar M

    aha, done, I changed it into:

    dateTimePickerDV.Value.ToShortDateString().ToString()

    it worked......

    ToShortDateString() should return a real string value, (in a particular format, but still a real string), how come it has to be converted once more

    confused.......



  • what did I do wrong while passing dateTimePicker value to bindingSource filter?