My dataGridView_flaggedComments
has, let say, 10 rows. Value in the Comments_Date
column's cell shows dates in the format of 31/12/2014 12:01 PM
, if I choose a date (which is without time portion) from comboBox_stockDates
(e.g. 31/12/2014), I want it to filter (and display) all the rows that have 31/12/2014 xx:xx xx
.
The below code would yield zero result even when the selected date (e.g. 31/12/2014) matches the rows which contain 31/12/2014 xx:xx xx
. Any idea what has gone wrong here?
string dtFilter = string.Format("Comments_Date = #{0}#", comboBox_stockDates.SelectedItem.ToString());
(dataGridView_flaggedComments.DataSource as DataTable).DefaultView.RowFilter = dtFilter;
Alternatively, is there a way to convert both dates to string then compare? I tried to use LIKE operator but error says cannot be used to compare between DateTime and String.
Any help and guidance would be much appreciated! Thank you. :)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…