我正在關注可搜索的網格視圖代碼HERE。我在使用FilterExpression
時遇到問題。我得到異常:C#:SQL FilterExpression - 缺少操作數異常
後缺少操作數「名稱」操作...當發生異常時, FilterExpression =「WHERE名稱如‘斯賓塞%’」
唯一的例外發生在以下代碼:
protected void BindSGVData()
{
//hfSearchText has the search string returned from the grid.
if (hfSearchText.Value != "")
{
RidesSQL.FilterExpression = " WHERE " + hfSearchText.Value; //EXCEPTION HERE!
}
DataView dv = (DataView)RidesSQL.Select(new DataSourceSelectArguments());
//hfSort has the sort string returned from the grid.
if (hfSort.Value != "")
{
dv.Sort = hfSort.Value;
}
RideSGV.DataSource = dv;
try
{
RideSGV.DataBind();
}
catch (Exception exp)
{
//If databinding threw exception bcoz current page index is > than available page index
RideSGV.PageIndex = 0;
RideSGV.DataBind();
}
finally
{
//Select the first row returned
if (RideSGV.Rows.Count > 0)
RideSGV.SelectedIndex = 0;
}
}
有什麼想法?
您正在使用什麼數據庫? – 2012-02-03 01:29:57
@ M.Babcock你先生是我的英雄!大聲笑,這裏是不捕捉明顯的...我已經改變了編輯選擇命令添加一個過濾器,並且yup不需要在哪裏..我太趕上修改操作數注意。得到答覆回答,所以我可以給你一個大胖綠色的複選標記! (: – SHeinema 2012-02-03 01:31:04