大家下午好,用戶應該可以通過日期和文本進行搜索,我怎樣才能在一個文本框中進行搜索?如何按日期時間或文本過濾表達式?
protected void BtnWinnersSearch_Click(object sender, EventArgs e)
{
string searchText = txtWinnersSearch.Text.Replace("'", "''").Trim();
GridViewWinners.Visible = true;
SqlDataSource4.FilterExpression = "nickname like '%" + searchText + "%' or username like '%" + searchText +
"%' or clubnumber like '%" + searchText + "%' or firstname like '%" +
searchText + "%' or lastname like '%" + searchText +
"%' or email like '%" + searchText + "%' or dob like '%" + Convert.ToDateTime(searchText).ToString("yyyy-MM-dd") + "%'";
}
拋出以下錯誤:
作品!
是dob的日期時間列嗎? –