开发者

Dataview Filteration Problem

开发者 https://www.devze.com 2023-01-22 01:43 出处:网络
Can some one help with with the following code please!! if (DiaryOccasions != null && DiaryOccasions.Rows.Count > 0)

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)开发者_如何学C = {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.

0

精彩评论

暂无评论...
验证码 换一张
取 消