我正在关注可搜索的网格视图代码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