WebGrid Community Server

Welcome to WebGrid Community Server Sign in | Join | Help
in Search

Setting Where clause

Last post 08-14-2008, 3:15 by lee.s. 2 replies.
Sort Posts: Previous Next
  •  08-12-2008, 23:51 731

    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
  •  08-13-2008, 16:29 735 in reply to 731

    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
  •  08-14-2008, 3:15 736 in reply to 735

    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!
View as RSS news feed in XML
Powered by Community Server, by Telligent Systems