trSearchChar = "Description LIKE" + "%" + strSearchText + "%";
try
{
dvResult = new DataView(((SearchResultSet)Cache["SRSet"]).Tables["SearchResult"],strSearchChar,strOrderWay,DataViewRowState.CurrentRows);
}
catch
{
Response.Cache.SetCacheability(System.Web.HttpCacheability.Private);
Response.Cache.SetExpires(DateTime.Now.AddHours(1.0));
SRSet = (new SearchFacade()).fnGetResult(strSearchText);
Cache.Insert("SRSet",SRSet);
dvResult = new DataView(((SearchResultSet)Cache["SRSet"]).Tables["SearchResult"],strSearchChar,strOrderWay,DataViewRowState.CurrentRows);
}
SearchResultList.DataSource = dvResult;
SearchResultList.DataBind();
写成
trSearchChar = "Description LIKE " + "%" + strSearchText + "%";
yes, it should work, for example, the output is 1 and 1:
DataTable dt = new DataTable();
dt.Columns.Add("Col1",typeof(string));
dt.Columns.Add("Col2",typeof(string));
for (int i=0; i < 3; i++)
{
DataRow dr = dt.NewRow();
dr["Col1"] = i.ToString();
dr["Col2"] = (i+ 1).ToString();
dt.Rows.Add(dr);
}
DataView dv = new DataView(dt, "Col1 like %2%","", DataViewRowState.CurrentRows);
Console.WriteLine(dv.Count);
dv = new DataView(dt, "Col2 like *2","", DataViewRowState.CurrentRows);
Console.WriteLine(dv.Count);