Filtering DataView by DateTime
Just a little code snippet to remind me how to do date comparisons in a DataView using DataView.RowFilter. It needs # characters around the date and you seem to need to generate the date string using InvariantCulture: DataTable table = GetList(); table.DefaultView.RowFilter = string.Format("date = #{0}#", DateTime.Today.ToString(CultureInfo.InvariantCulture)); this.GridView1.DataSource = table.DefaultView; this.GridView1.DataBind();Published in .NET on Saturday, April 5th, 2008
