Can some one help with with the following code please!!
if (DiaryOccasions != null && DiaryOccasions.Rows.Count > 0)
{
DataTable dtFilteredOccasions = new DataTable();
if (ddlMonths.SelectedItem.Value != string.Empty)
{
string[] selMonthYear = ddlMonths.SelectedItem.Value.Split('/');
if(selMonthYear.Length > 0)
{
dtFilteredOccasions = new DataView(DiaryOccasions,
string.Format("MONTH(OccasionDate) = {0} AND YEAR(OccasionDate) = {1}",
selMonthYear[0].ToString(), selMonthYear[1].ToString()),
string.Empty, DataViewRowState.CurrentRows).ToTable();
}
}
rptrDates.DataSource = dtFilteredOccasions;
rptrDates.DataBind();
}
when tried it throws the following error at runtime:
The expression contains undefined function call MONTH().
Please help !!
Dataview Filters do not work that way. It’s syntax is similar to sql, but that doesn’t mean you are allowed to call sql functions in your filter.