locked
FK filtering combined with plain text search RRS feed

  • Question

  • User1324974859 posted


    I've been using the 4.0 preview with a web application. I would like to add plain text searching.  Ideally, I would add a textbox and a button below a FilterRepeater, and then code the LinqDataSource to automagically combine the FilterRepeater values with the plain text.  Or add code to the events in GridDataSource_Selecting or btnSearch_OnClick.  But since I haven't been able to make those approaches work, and because there is no 4.0 sample showing FK with plain text search, maybe it's not possible.

    I could use Josh's classes but I'm not sure if Josh's classes work with the new LinqDataSource.  Also, I prefer the style of the FK drop down in 4.0. There was a filtering bug in 3.5 described here
    http://forums.asp.net/p/1313772/2593318.aspx that made me move up to 4.0. Aside from all that, Josh's text search stuff is excellent. 


    If I have to dump the FilterRepeater, would I add drop downs with <asp:DropDownList? It seems like I would call <asp:ForeignKey,  but there isn't one of those in the toolbox. 

    Thanks,

    Sean

    Tuesday, December 9, 2008 9:53 AM

Answers

  • User-330204900 posted

    I could use Josh's classes but I'm not sure if Josh's classes work with the new LinqDataSource
    Yes Joshes classes work at the moment only with LinqSataSource.

    Also the new dataSources that come with 4.0 that allows search dont work with Dynamic Data yet [:(]

    As for Josh's stuff I recommend downloading the source code which has a sample site with search implemented you will need SQL 2008 to run this though [:)]

    Hope this helps [:D]

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, December 9, 2008 12:10 PM
  • User-260435932 posted

    The new preview bits have a QueryBlock in the LinqDataSource and BusinessLogicDataSource that can be used to do advanced filtering. The new dynamic data filter architecture is built on top of this. If you take a look at the BusinessLogicDataSource sample, there is an example on how to use the Search expression to add searching to your page.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, December 10, 2008 4:05 AM

All replies

  • User-330204900 posted

    I could use Josh's classes but I'm not sure if Josh's classes work with the new LinqDataSource
    Yes Joshes classes work at the moment only with LinqSataSource.

    Also the new dataSources that come with 4.0 that allows search dont work with Dynamic Data yet [:(]

    As for Josh's stuff I recommend downloading the source code which has a sample site with search implemented you will need SQL 2008 to run this though [:)]

    Hope this helps [:D]

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, December 9, 2008 12:10 PM
  • User1324974859 posted

    Thanks Steve, and nice work on your site. 

    Tuesday, December 9, 2008 10:49 PM
  • User-260435932 posted

    The new preview bits have a QueryBlock in the LinqDataSource and BusinessLogicDataSource that can be used to do advanced filtering. The new dynamic data filter architecture is built on top of this. If you take a look at the BusinessLogicDataSource sample, there is an example on how to use the Search expression to add searching to your page.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, December 10, 2008 4:05 AM
  • User-330204900 posted

    Hi David is there a new preview out - soon? as I was told by either Rick anderson or Scott Hunter that the search does not work with DD yet?

    Wednesday, December 10, 2008 6:37 AM
  • User1324974859 posted

    Thanks David, I did find that sample.  I couldn't get search to work with a FilterRepeater in the LinqDataSource although maybe it would with individual FilterUserControls.  Also I suppose I could write event code on selecting or gridview prerender. But I'm a VB guy and the samples are C#.  The best option seems to be to wait for the next release.

    Wednesday, December 10, 2008 11:56 AM
  • User660823006 posted

    Stephen, we are going to try and get a new preview release up this week. :-) Watch this space.

    Wednesday, December 10, 2008 12:43 PM
  • User-330204900 posted

    Thanks Scott that's great news [:D]

    Wednesday, December 10, 2008 2:42 PM
  • User1324974859 posted

    I was able to combine search and a FilterRepeater with DD Preview 2.  Thanks to the DD team for the V2 release.

    My search block looks like this:

                 
    <asp:QueryableFilterRepeater runat="server" ID="FilterRepeater">
                        <ItemTemplate>
                            <asp:Label ID="Label1" runat="server" Text='<%# Eval("DisplayName") %>' />
                            <asp:DynamicFilter runat="server" ID="DynamicFilter" OnFilterChanged="DynamicFilter_FilterChanged" /><br />
                        </ItemTemplate>
                    </asp:QueryableFilterRepeater>
                 Search:
                <asp:TextBox ID="Search" Text="" runat="server"></asp:TextBox>
                <asp:Button ID="btnRefresh" runat="server" Text="Search" /><br />  

    There is no code behind the button.  Clicking it runs the search.

    My QueryExtender block looks like this:


    <aspX:QueryExtender TargetControlID="GridDataSource" ID="GridQueryExtender" runat="server">
     <asp:DynamicFilterExpression ControlID="FilterRepeater" />
     <aspX:SearchExpression SearchType="Contains">
      <asp:ControlParameter ControlID="Search"
      Name="Search" PropertyName="Text" Type="String" />
     </aspX:SearchExpression>
    </aspX:QueryExtender>


    The SearchExpression tag requires s a DataFields property.  You can hard code the search columns, or, to keep things dynamic, populate during page_load:


    Sub SetSearchColumns()
     Dim searchexpression As Microsoft.Web.Data.UI.WebControls.Expressions.SearchExpression
     searchexpression = GridQueryExtender.Expressions(1)
     Dim col As System.Web.DynamicData.MetaColumn
     For Each col In table.Columns
      If col.ColumnType.Name = "String" And col.Scaffold Then
       If Len(searchexpression.DataFields) Then
        searchexpression.DataFields = searchexpression.DataFields & "," & col.Name
        Else
        searchexpression.DataFields = col.Name
      End If
      End If
    Next
    End Sub


     

     

    Friday, December 19, 2008 10:06 AM
  • User-260435932 posted

    Very cool [:D]

    Friday, December 19, 2008 11:22 AM