private void BindList() { string fromdate = ToSQL.SQLDateNonHour(txtFromDate.Text); string todate = ToSQL.SQLDateNonHour(txtToDate.Text); DataSet ds = _db.ExecuteQuery("select * from dbo.Contact where (" + fromdate + " is null or DateCreated >=" + fromdate + ") and (" + todate + " is null or DateCreated <= " + todate + ")"); gvContacts.DataSource = ds; gvContacts.DataBind(); this.gvContacts.UseAccessibleHeader = true; this.gvContacts.HeaderRow.TableSection = TableRowSection.TableHeader; }