WebGrid Community Server
Welcome to WebGrid Community Server
Sign in
|
Join
|
Help
in
WebGrid general questions (forum)
WebGrid - plug and play datagrid (group)
(Entire Site)
Search
Home
Forums
WebGrid Community Server
»
WebGrid - plug and play datagr...
»
WebGrid general questions
»
Re: Setting Where clause
Setting Where clause
Last post 08-14-2008, 3:15 by
lee.s
. 2 replies.
Sort Posts:
Oldest to newest
Newest to oldest
Previous
Next
08-12-2008, 23:51
731
lee.s
Joined on 05-06-2008
Posts 32
Setting Where clause
I'd like to set the where clause to Contains(description, 'search'); this invokes a freetext search method used by SQL Server.
Here is the code:
Protected Sub grd_Tools_Search(ByVal sender As Object, ByVal e As WebGrid.Events.SearchChangedEventArgs) Handles grd_Tools.SearchChanged
Dim searchText As String
searchText = grd_Tools.Search
searchText = searchText.Replace(" ", " and ")
grd_Tools.Where = " contains(description, '" + searchText + "')"
End Sub
Here is the error:
WebGrid.Design.GridDataSourceException: Failed to select from DataTable ---> System.Data.EvaluateException: The expression contains undefined function call contains().
at System.Data.FunctionNode..ctor(DataTable table, String name)
at System.Data.ExpressionParser.Parse()
at System.Data.DataExpression..ctor(DataTable table, String expression, Type type)
at System.Data.Select..ctor(DataTable table, String filterExpression, String sort, DataViewRowState recordStates)
at System.Data.DataTable.Select(String filterExpression, String sort)
at WebGrid.Data.Database.DataSourcesNet.ReadDataTable(Int32 rows, DataTable table, Grid grid)
--- End of inner exception stack trace ---
at WebGrid.Data.Database.DataSourcesNet.ReadDataTable(Int32 rows, DataTable table, Grid grid)
at WebGrid.Data.Database.DataSourcesNet.LoadDatasource(Object datasource, DataTable columnSettings, Boolean onlyColumnSettings, Grid grid)
at WebGrid.Data.Table.GetData(Boolean forceGetData, Boolean getAllRows)
at WebGrid.Data.Table.GetData(Boolean forceGetData)
at WebGrid.Grid.OnPreRender(EventArgs e)
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)undefined
Report abuse
08-13-2008, 16:29
735
in reply to
731
admin
Joined on 02-25-2006
Posts 327
Re: Setting Where clause
Try to debug the grid to see which sql is being generated. How are your data source set up ?
Olav Botterli, WebGrid Founding Developer
Report abuse
08-14-2008, 3:15
736
in reply to
735
lee.s
Joined on 05-06-2008
Posts 32
Re: Setting Where clause
I got it fixed up, checking the datasource reminded me that I needed to change my stored procedure. The where clause worked great on table-driven grids. Thanks for the pointer!
Report abuse
2006 WebGrid. All rights reserved.