Sunday, March 18, 2012

Between two dates dataview row filter

The expression contains unsupported operator 'Between'.
Instead of between opertor we can use the ' <= ' and ' >= '

DataView dview_certificates = table.DefaultView;
if (Session["StartDate"] != null && Session["EndDate"] != null)
 {
  //strRowfilter = "(StartDate between '" + DateTime.Parse(Session["StartDate"].ToString()).ToShortDateString();
//strRowfilter += "' and '" + DateTime.Parse(Session["EndDate"].ToString()).ToShortDateString();
//strRowfilter += "') or (FinishDate between '" + DateTime.Parse(Session["StartDate"].ToString()).ToShortDateString();
//strRowfilter += "' and '" + DateTime.Parse(Session["EndDate"].ToString()).ToShortDateString() + "')";
strRowfilter = "(StartDate >= '" + DateTime.Parse(Session["StartDate"].ToString()).ToShort

DateString();
strRowfilter += "' and StartDate <='" + DateTime.Parse(Session["EndDate"].ToString()).ToShort

DateString();
strRowfilter += "') or (FinishDate >= '" + DateTime.Parse(Session["StartDate"].ToString()).

ToShortDateString();
strRowfilter += "' and FinishDate <= '" + DateTime.Parse(Session["EndDate"].ToString()).
ToShortDateString() + "')";
dview_certificates.RowFilter = strRowfilter;
}

1 comment:

  1. Thank You Raghavendhar Reddy Sir...
    Its help me...
    Thank You So Much...

    ReplyDelete

Comments

Search

Custom Search
Protected by Copyscape Plagiarism Software